Charles maby im on right track to string extractor.
So next code present current shape of extractor which i use .
My question is how i can extract arguments into string array using
number of arguments as size of array.This sounds ok for me,right?
I know that i can use normal For/next loop...
but what with qouted string ,i mean how detect in this
for loop
qouted string as one argument and extract complet quoted string as one
argument even is coma character inside this quoted string?
As you see i use coma as delimiter....
Any idea if you have time for this....
this is modified code:
'---------------------------------------------
function fieldcount(string s, string d) as sys
'=============================================
sys a,b,c,le,i
'
'EXCLUDE EMPTY STRINGS
'
le=len s
if le=0 then return 0
if d="" then return 1
'
b=asc d 'delimiter ascii code
c=1 'at least 1 field
i=0 'char index
while i<le
i+=1
a=asc s,i
'
'SKIP QUOTED TEXT " ' `
'
if a=34 or a=39
while i<le
i+=1
if i>le then exit while
if asc(s,i)=a then exit while
wend
end if
if a=b then c+=1
wend
return c
end function
INT numArg 'number of Arguments
STRING src,d$
d$=","
src="arg1,arg2,arg3,arg4,'and with coma, quoted field',arg6"
'call function
numArg=FieldCount(src,d$)
Print Str(numArg)
'extract arguments ******************************************
INT EPos,SPos
STRING arg1,arg2
EPos=0
SPos=0
'==========================================================
'first argument
IF numArg>0
SPos=1
EPos = InStr(SPos,src, ",")-1
Print "EPos:"+str(EPos)
If EPos <= 0 Then EPos = Len(src)
arg1 = RTrim(LTrim(Mid(src, SPos, EPos - SPos + 1)))
END IF
Print "ARG:"+arg1
'=============================================================
'second argument
IF numArg>1
SPos = EPos+2
EPos = InStr(SPos,src, ",") - 1
Print "EPos:"+str(EPos)
If EPos <= 0 Then EPos = Len(src)
arg2 = RTrim(LTrim(Mid(src, SPos, EPos - SPos + 1)))
END IF
Print "ARG:"+arg2