Page 1 of 1

dc_tokenarray() regression

Posted: Thu Jan 27, 2011 2:23 pm
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..

Re: dc_tokenarray() regression

Posted: Thu Jan 27, 2011 5:02 pm
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.)

Re: dc_tokenarray() regression

Posted: Thu Jan 27, 2011 6:51 pm
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..

Re: dc_tokenarray() regression

Posted: Thu Jan 27, 2011 7:15 pm
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.

Re: dc_tokenarray() regression

Posted: Thu Jan 27, 2011 7:27 pm
by bwolfsohn
That was what i was planning on doing..

great minds think alike... (are you on percoset also ?? )

Re: dc_tokenarray() regression

Posted: Sun Jan 30, 2011 12:22 pm
by rdonnay
I wish I had percoset. That was the best drug ever. I used it after an operation.

Re: dc_tokenarray() regression

Posted: Fri Feb 04, 2011 10:16 am
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

Re: dc_tokenarray() regression

Posted: Fri Feb 04, 2011 10:37 am
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

Re: dc_tokenarray() regression

Posted: Fri Feb 04, 2011 2:29 pm
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....