PDA

View Full Version : Macro ME10 open files


lukam
04-13-2006, 07:43 AM
I have to write a macro in ME10 for automatically open a range of files.
The file names to open are stored in a text file.
Anyone have an example to do it?

Thanks a lot

John Scheffel
04-14-2006, 09:44 AM
I don't have a macro which does exactly what you want, but this might help you get started. It shows how to open and read the lines from a text file one at a time. This macro expects the file name to be passed as a parameter, but Filename could also be defined as a local variable if you want to specify it in the macro.


DEFINE Open_and_read_file
PARAMETER Filename

LOCAL Fileline

TRAP_ERROR
OPEN_INFILE 1 Filename END
IF (CHECK_ERROR)
BEEP
DISPLAY('ERROR: Could not open file: "'+Filename+'"')
ELSE
LOOP
READ_FILE 1 Fileline
EXIT_IF (Fileline='END-OF-FILE')
{process each Fileline as needed}
END_LOOP
END_IF
CLOSE_FILE 1
END_DEFINE