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!

DELIMITER

Status
Not open for further replies.

Volkmaniac

Technical User
Mar 19, 2003
104
US
I've already used several of the delimiters from aspectscripting.com but I'd like to know if you can cut (or delimit) everything before a character. For instance, I'm using a PICK statement that produces the following output.

21805:75766:478890YRTRZ X788900 906.93
24092:78046:491657YRTRZ X916579 1272.50
980:05735:4808273:YRTRZ X808273 980.44

I plan on saving this in a capture file:

This is how I'd like my output to look.

YRTRZ X788900 906.93
YRTRZ X916579 1272.50
YRTRZ X808273 980.44

Is there anyway I can have it find the first instance of a text character and then delimit it from there. The first letter wouldn't always be a "Y".

 
Here's a script that worked for the three pieces of data you posted. The ugly if statement checks to see if the ASCII value of the current character read from the string is between the values for uppercase letters or lowercase letters. If so, the substr command is used to copy the remaining data from the string to sOut.

proc main
string sIn, sOut
integer iLen, iCount, iVal

sIn = "980:05735:4808273:YRTRZ X808273 980.44"
strlen sIn iLen
for iCount = 0 upto iLen-1
strgetc sIn iCount iVal
if (((iVal >= 65) && (iVal <= 90)) || ((iVal >= 97) && (iVal <= 122)))
substr sOut sIn iCount iLen-iCount
exitfor
endif
endfor
endproc

aspect@aspectscripting.com
 
knob,

You're programming is beyond me. This worked perfect.

proc main
string sLine, sOut
integer iLen, iCount, iVal


if fopen 0 &quot;test.txt&quot; READ TEXT ;open the snapshot file
while not feof 0

fgets 0 sLine

strlen sLine iLen
for iCount = 0 upto iLen-1
strgetc sLine iCount iVal
if (((iVal >= 65) && (iVal <= 90)) || ((iVal >= 97) && (iVal <= 122)))
substr sOut sLine iCount iLen-iCount
usermsg &quot;%s&quot; sOut
exitfor
endif
endfor

endwhile
endif
fclose 0


endproc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top