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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looking for a CRLF in a field with substr

Status
Not open for further replies.

MikeL91

Programmer
Feb 8, 2001
100
US
I used to have some code that would split a field on the HEX value of a comma (2C), but I cant find it. I need to split a address field that has HEX 0D 0A in it. I thought it was X0D for Hex 0D, but I can not get it to work.

Anyone know the correct format?


thanks in advance,
Mike

actual line:
IF SUBSTR(file.afix,nCounter,1)=X0D
 
Mike,
Close - try:
Code:
IF SUBSTR(file.afix,nCounter,1)=0x0D
That's a zero-ex (digit letter) in front of the hex string. You can also use:[/code]
IF SUBSTR(file.afix,nCounter,1)=chr(13) && CR
[/code]
Rick

 
Mike,
Oops, I got so wrapped up in the syntax for a hex number, I forgot that it's still a number and you were checking against a character! Soo...
Code:
IF ASC(SUBSTR(file.afix,nCounter,1))=0x0D
or
IF SUBSTR(file.afix,nCounter,1)=chr(0x0D)
would have also worked!

Rick

 
As for splitting on CRLF's, try:
Code:
#DEFINE crlf Chr(0x0D)+chr(0x0A)
LOCAL laArr[1],lnCnt, lcStringToSplit
lcStringToSplit = "Line one"+crlf+"Line Two"+crlf+"Line Three"
lnCnt = ALINES( laArr, lcStringToSplit )
for lnI = 1 to lnCnt
  ?"Line ",lnI,laArr[lnI]
endfor

* to split on commas:
lcStringToSplit = "Line one,Line Two,Line Three"
lnCnt = ALINES( laArr, StrTran(lcStringToSplit,[,],crlf) )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top