PDA

View Full Version : Text File


brm
09-01-2005, 01:33 AM
I Have A Text File Which A List Of Number In Order But Any Number There Are Not.
For Example :
1
2
3
5
6
8
10
How Can I Find The Missing Number And Writing In Another Text File.
For Example:
4
7
9
Thanks.

John Scheffel
09-02-2005, 09:58 AM
Do you want a ME10/Drafting macro that will do this? If so it shouldn't be too difficult, but I just want to make user I understand what you want.

brm
09-04-2005, 09:57 PM
Yes by an M10 drafting macro if it's possible.

John Scheffel
09-06-2005, 09:46 AM
I think this macro will do what you want. You will need to set Source_file and Target_file to the file names you want to use, or use READ statements to prompt the user for the file names.
DEFINE Missing_numbers
LOCAL Count
LOCAL Source_file
LOCAL Target_file
LOCAL Source_line
LET Source_file 'path\name of source file'
LET Target_file 'path\name of target file'
TRAP_ERROR
OPEN_INFILE 1 Source_file
IF (CHECK_ERROR)
DISPLAY ('ERROR: Source file "'+Source_file+'" is not readable.')
ELSE
OPEN_OUTFILE 2 DEL_OLD Target_file
LET Count 1
LOOP
READ_FILE 1 Source_line
EXIT_IF (Source_line='END-OF-FILE')
LET Source_line (TRIM Source_line)
WHILE ((VAL Source_line) <> Count)
WRITE_FILE 2 Count
LET Count (Count+1)
END_WHILE
LET Count (Count+1)
END_LOOP
CLOSE_FILE 1
CLOSE_FILE 2
END_IF
END_DEFINE