Page 1 of 1

Getting text out of a field

Posted: Sat Feb 09, 2008 3:13 pm
by Andycal
I've got a text file that I've got the first line out of by using this:

Code: Select all

    put fld "TemplatePath" into sFile
    open file sFile for read
    read from file sFile at 1 until EOF
    put it into fld "fldContent"
    put the first line of fld "fldContent" into wTitle


How do I now get the rest of the file into another variable? I thought it might be as simple as:

Code: Select all

put line 2 to eof into fld "fldRest"
But it's not.

Posted: Sat Feb 09, 2008 3:45 pm
by Klaus
Hi Andy,

you can save some typing by using the "url" syntax:

Code: Select all

...
    put fld "TemplatePath" into sFile 
    put URL("file:" & sFile) into fld "fldContent" 
    
    ## Use "file:" for text files and "binfile:" for binary data

    put the line 1 of fld "fldContent" into wTitle
    put line 2 to -1 of fld "fldContent" into "fldRest"
   # Yes you can start counting from the end of fields/text :-)
   # line -1 = last line
   # line -2 = last but one line etc...
Best

Klaus

Posted: Sat Feb 09, 2008 4:15 pm
by Andycal
Brilliant, cheers!