Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple string question 1

Status
Not open for further replies.

pragmatic

Programmer
Aug 23, 2001
31
US
This is probably really simple, but here's my question anyway.

I've got a tab delimited text file with three columns of data (3 letters,2 numbers,3 numbers)

I'm trying to read these in to 3 strings, then output (in a dialog box) the combined strings.

I'm getting an "Error 5: Invalid Identifier" message as soon as I run this.

Thanks.

string strOutput

proc main

string sLine

string sTemp1, sTemp2, sTemp3


if isfile "C:\test.txt"

fopen 0 "test.txt" READ TEXT ;Open our data file
while not feof 0 ;While the file still has data
fgets 0 sLine ;Read a line of data
strtok sTemp1 sLine "`t" 1 ;Get the first field
strtok sTemp2 sLine "`t" 1 ;Get the second field
strtok sTemp3 sLine "`t" 1 ;Get the third field

strcat sTemp1 " "
strcat sTemp2 " "

strinsert strOutput sTemp1 0
strinsert strOutput sTemp2 0
strinsert strOutput sTemp3 0

call test


endwhile
fclose 0


endif

endproc

proc test

dialogbox 0 8 20 264 169 2 "Caption"

pushbutton 1 45 80 164 35 "Okay" cancel

text 2 16 5 232 59 strOutput left

enddialog

endproc
 
Arrrgg! Thanks for the help. That was the problem. I knew it had to be something simple, I just couldn't see it.
 
One thing I like to do is replace fopen calls with if fopen ..., then have an else clause that fires if the file could not be opened that pops up a usermsg box with an error message.


aspect@aspectscripting.com
 
I will do that thanks, this is my first attempt to use Aspect as the engine behind my programing. Up till now I used vb to build the basic (aspect) scripts for me. The more I use Aspect, the more uses I'm finding.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top