Guidance
指路人
g.yi.org
Guidance Forums / Reginald Rexx / LOADTEXT - option 'S'

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. 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
Message2. 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
Message3. Re: LOADTEXT - option 'S'
#5096
Posted by: Jeff Glatt 2004-09-16 07:54:36
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 not use APPEND if
  you want to erase the previous contents of the file */
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 • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
¥860.00 ·
 
 
¥900.00 ·
 
 
¥810.00 ·
 
 
¥317.00 ·
 
 
¥1,370.00 ·
 
 
¥660.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0