strtok
Richard Kreiss
rkreiss at gccconsulting.net
Wed Aug 26 06:21:51 PDT 2009
> -----Original Message-----
> From: Kenneth Brody [mailto:kenb at fptech.com]
> Sent: Tuesday, August 25, 2009 3:01 PM
> To: rkreiss at gccconsulting.net
> Cc: 'FilePro Mailing List'
> Subject: Re: strtok
>
> Richard Kreiss wrote:
> > Noted something and I wanted to check if this is the correct behavior.
> >
> > I am importing data from a csv file and need to edit some of the import
> > fields as they are not quite right.
> >
> > One field is a phone # field which can be in the form:
> >
> > EXT 111
> >
> > EXT 111 (212) 555-1212
> >
> > (212) 555-1212
> >
> > This is in foobar(5)
> >
> > I can do a if: mid(foobar(5),"1","1") = "E" and this works fine.
> >
> > However if I do d=strtok(foobar(5),"(","1") to get the position of the open
> > paran, to extract the phone #, d = "0".
> >
> > Had to do f=foobar(5){"" and then d=strtok(f,"(","1") to get the starting
> > position to extract the phone #.
> >
> > Mid on foobar(5) works but apparently strtok on foobar(5) won't work.
> >
> > Is this the correct behavior?
>
> "It works here."
>
> Can you post some actual code, along with the version of the program you are
> using?
>
> --
> Kenneth Brody
Working Code:
39 ------- - - - - - - - - - - - - - - - -
◄ If:
Then: f=gotit(5){""
40 ------- - - - - - - - - - - - - - - - -
◄ If:
Then: d=strtok(f,"(","1")
41 ------- - - - - - - - - - - - - - - - -
◄ If: d = "0"
Then: GOTO mo_fone
42 ------- - - - - - - - - - - - - - - - -
◄ If:
Then: fone=mid(f,d,d+"14")
43 ------- - - - - - - - - - - - - - - - -
mo_fone◄ If: mid(gotit(5),"1","1") = "(" ◄
Then: fone=gotit(5) ◄
44 ------- - - - - - - - - - - - - - - - -
Not Working code:
40 ------- - - - - - - - - - - - - - - - -
◄ If: ◄
Then: d=strtok(gotit(5),"(","1") ◄
41 ------- - - - - - - - - - - - - - - - -
◄ If: d = "0" ◄
Then: GOTO mo_fone ◄
In this case d was always "0" even when gotit(5)'s value was EXT 123 (212) 555-1212.
The program posts the ext number and phone numbers to separate fields.
This is just one place where I need to use strtok to divide an import field into separate fields or to remove unwanted commas from a field.
In all cases the import field must be set to a dummy variable and then strtok used.
Note mid does work on the import field, see line 43, I can test to see if this is just a phone # in the field as all have an area code with an opening (.
Richard
More information about the Filepro-list
mailing list