| Forum List • Thread List • Refresh • New Topic • Search • Previous • Next 1 | 1. LOADTEXT - option 'S' #3957 Posted by: misi01 2004-04-29 20:53:51 | Jeff - experimenting with the following code
next = MATCHNAME(,"mstools", file_name, , )
DO WHILE next <> 'DONE'
rc = LOADTEXT("Ms.", full_path||'usage\'||mstools, 'TLB')
rc = LOADTEXT("Ms.", full_path||'usage\appended.txt', 'S')
next = MATCHNAME(,"mstools", file_name, , )
END
and I get the impression that the 'S' options ALWAYS writes from record 1 (ie, this is NOT an option to append the contents of multiple files to one file). Am I correct ??Michael | 2. Re: LOADTEXT - option 'S' #3958 Posted by: misi01 2004-04-29 21:00:55 | Ha !!! Found the answer myself after mucking around:
DO WHILE next <> 'DONE'
rc = LOADTEXT("Ms.", full_path||'usage\'||mstools, 'TLB')
CALL STREAM(fileout, 'C', 'OPEN WRITE APPEND')
rc = LOADTEXT("Ms.", fileout, 'S')
next = MATCHNAME(,"mstools", file_name, , )
END
Neat
Michael | 3. Re: LOADTEXT - option 'S' #5096 | Right. If you have opened the file yourself (prior to calling LOADTEXT), then LOADTEXT will append saved data upon each call. The implication of this is, of course, if you open a file yourself, then you also need to close it yourself if you don't want this behavior.
I should note that it is best to open the file once outside of your loop. And then of course, close it when done with your loop. Also, you should use DO UNTIL instead of DO WHILE. Otherwise, your loop will not execute even once if "next" happens to be initially set to the value 'DONE'. And since you've omitted error checking, you really should be using the NOTREADY condition:STREAM(fileout, 'C', 'OPEN WRITE APPEND')
DO UNTIL next \== ""
LOADTEXT('Ms.', full_path||'usage\'||mstools, 'TLB')
LOADTEXT('Ms.', fileout, 'S')
next = MATCHNAME(, 'mstools', file_name)
CATCH NOTREADY
CONDITION('M')
FINALLY
STREAM(fileout, 'C', 'CLOSE')
END | Forum List • Thread List • Refresh • New Topic • Search • Previous • Next 1 |
|
|