dc_tokenarray() regression

This forum is for eXpress++ general support.
Post Reply
Message
Author
bwolfsohn
Posts: 648
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

dc_tokenarray() regression

#1 Post by bwolfsohn »

Now, i'm still on a lot of percoset, so i could be wrong, but here's what i've got:

version 251 and 254 return different results for:


cText:="Bob,Baune,141 South 5th Street,Bird Island,MN,55310,USA,Bob's Auto,bbaune@q.com,Ba406770,320-212-1991,,,1131"
myarray:=dc_tokenarray(cText,",",.t.)

the apostrophe on bob's auto creates improper results for version 254. 251, it's correct..
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: dc_tokenarray() regression

#2 Post by rdonnay »

Try this for now until I get dig into this deeper.

cText:="Bob,Baune,141 South 5th Street,Bird Island,MN,55310,USA,Bob's Auto,bbaune@q.com,Ba406770,320-212-1991,,,1131"
myarray:=dc_tokenarray(cText,",",.FALSE.)
The eXpress train is coming - and it has more cars.

bwolfsohn
Posts: 648
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: dc_tokenarray() regression

#3 Post by bwolfsohn »

rdonnay wrote:Try this for now until I get dig into this deeper.

cText:="Bob,Baune,141 South 5th Street,Bird Island,MN,55310,USA,Bob's Auto,bbaune@q.com,Ba406770,320-212-1991,,,1131"
myarray:=dc_tokenarray(cText,",",.FALSE.)
The problem with this approach is i don't know what else it might break elsewhere in the software..
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: dc_tokenarray() regression

#4 Post by rdonnay »

Then my next suggestion is to copy DC_TokenArray() from _DCTOKEN.PRG of build 251 and put it in your own library for now. When I get home I will work on a permanent fix for you. I don't have a quick solution.
The eXpress train is coming - and it has more cars.

bwolfsohn
Posts: 648
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: dc_tokenarray() regression

#5 Post by bwolfsohn »

That was what i was planning on doing..

great minds think alike... (are you on percoset also ?? )
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: dc_tokenarray() regression

#6 Post by rdonnay »

I wish I had percoset. That was the best drug ever. I used it after an operation.
The eXpress train is coming - and it has more cars.

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: dc_tokenarray() regression

#7 Post by rdonnay »

Brian -

I ran the below code and it gives the proper output.
What is it that you are expecting?

Roger

Code: Select all

#INCLUDE "dcdialog.CH"

FUNCTION Main()

LOCAL cText, aTokens

cText:="Bob,Baune,141 South 5th Street,Bird Island,MN,55310,USA,Bob's Auto,bbaune@q.com,Ba406770,320-212-1991,,,1131"

aTokens := DC_TokenArray(cText,',')

WTF aTokens pause

RETURN nil


PROC appsys ; return
The eXpress train is coming - and it has more cars.

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: dc_tokenarray() regression

#8 Post by rdonnay »

Ok, I fixed the problem. It was caused by using the 3rd (lQuote) parameter and having a single quote in the text.

I changed DC_TokenArray() to ignore single-quotes when using the lQuote parameter and only strip double-quotes.

This will be in build 255 to be released later today.

Code: Select all

FUNCTION dc_tokenarray( cString, cDelims, lQuote )

LOCAL nFound, i, lStart, lDoubleQuoteOn, cInString, cChar, nCount := 0, ;
      aTokens[0], lSingleQuoteOn

DEFAULT lQuote := .f.

cDelims := IIF(Valtype(cDelims)='C',cDelims,_DCTokenDelims() )
IF EMPTY(cString)
  RETURN aTokens
ENDIF
IF lQuote
  lDoubleQuoteOn := .F.
//  lSingleQuoteOn := .F.
  cInString := cString
  cString := ''
  FOR i := 1 TO Len(cInString)
    cChar := cInString[i]
    IF cChar == '"'
      lDoubleQuoteOn := !lDoubleQuoteOn
//    ELSEIF cChar == "'"
//      lSingleQuoteOn := !lSingleQuoteOn
    ELSEIF !lDoubleQuoteOn .AND. cChar $ cDelims // .AND. !lSingleQuoteOn
      cChar := Chr(0)
    ENDIF
    cString += cChar
  NEXT
  cString := StrTran(cString,'"','')
ELSE
  FOR i := 1 TO LEN(cDelims)
    cString := Strtran(cString,SubStr(cDelims,i,1),CHR(0))
  NEXT
ENDIF
IF Len(cDelims) > 1
  IF CHR(0)+CHR(0) $ cString
    cString := StrTran(cString,CHR(0)+CHR(0),CHR(0))
  ENDIF
ENDIF
DO WHILE .t.
  nFound := AT(CHR(0),cString)
  IF nFound = 1 //.AND. Len(aTokens)=0
    AADD( aTokens,'' )
    cString := Substr(cString,2)
  ELSEIF nFound > 0
    AADD( aTokens, SubStr(cString,1,nFound-1) )
    cString := SubStr(cString,nFound+1)
  ELSE
    AADD( aTokens, cString )
    EXIT
  ENDIF
ENDDO
RETURN aTokens
The eXpress train is coming - and it has more cars.

bwolfsohn
Posts: 648
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: dc_tokenarray() regression

#9 Post by bwolfsohn »

thanks...

How's your recovery coming ??
Mine's coming along "normally"

I'm doing kissimmee remotely this year.. running two machines via pcanywhere and using a remote ip phone....
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

Post Reply