|
word$()
Jul 5, 2008 10:05:38 GMT -5
Post by kokenge on Jul 5, 2008 10:05:38 GMT -5
Trying to find stuff before a separator with nothing before it, does not return nothing. It returns the separator you used.
fields$ = "pageId, pageSeq, newWindow" fieldName$ = "pageId"
print "No leading Space. Find stuff before:";word$(fields$,1,fieldName$) print "No leading Space. Find stuff after:";word$(fields$,2,fieldName$)
' placing a space in front makes it work fields$ = " pageId, pageSeq, newWindow"
print " Leading Space. Find stuff before:";word$(fields$,1,fieldName$) print " Leading Space. Find stuff after:";word$(fields$,2,fieldName$) wait
|
|
|
word$()
Jul 5, 2008 11:21:02 GMT -5
Post by Carl Gundel - admin on Jul 5, 2008 11:21:02 GMT -5
Trying to find stuff before a separator with nothing before it, does not return nothing. It returns the separator you used. fields$ = "pageId, pageSeq, newWindow" fieldName$ = "pageId"
print "No leading Space. Find stuff before:";word$(fields$,1,fieldName$) print "No leading Space. Find stuff after:";word$(fields$,2,fieldName$)
' placing a space in front makes it work fields$ = " pageId, pageSeq, newWindow"
print " Leading Space. Find stuff before:";word$(fields$,1,fieldName$) print " Leading Space. Find stuff after:";word$(fields$,2,fieldName$) wait
Okay, but let's clarify that the parameter is not supposed to be a field name, but a delimiter. "," for example. -Carl
|
|
|
word$()
Jul 5, 2008 11:47:24 GMT -5
Post by kokenge on Jul 5, 2008 11:47:24 GMT -5
This gives the same error using a ","
fields$ = ",pageId, pageSeq, newWindow" fieldName$ = ","
print "No leading Space. Find stuff before:";word$(fields$,1,fieldName$) print "No leading Space. Find stuff after:";word$(fields$,2,fieldName$)
' placing a space in front makes it work fields$ = " ,pageId, pageSeq, newWindow"
print " Leading Space. Find stuff before:";word$(fields$,1,fieldName$) print " Leading Space. Find stuff after:";word$(fields$,2,fieldName$) wait
|
|
|
word$()
Jul 5, 2008 12:45:18 GMT -5
Post by Carl Gundel - admin on Jul 5, 2008 12:45:18 GMT -5
Sure. I was just trying to clarify the purpose of the function. Thanks for the bug report. This gives the same error using a "," fields$ = ",pageId, pageSeq, newWindow" fieldName$ = ","
print "No leading Space. Find stuff before:";word$(fields$,1,fieldName$) print "No leading Space. Find stuff after:";word$(fields$,2,fieldName$)
' placing a space in front makes it work fields$ = " ,pageId, pageSeq, newWindow"
print " Leading Space. Find stuff before:";word$(fields$,1,fieldName$) print " Leading Space. Find stuff after:";word$(fields$,2,fieldName$) wait
|
|
|
word$()
Jul 5, 2008 12:59:39 GMT -5
Post by kokenge on Jul 5, 2008 12:59:39 GMT -5
Actually this happens inside a string. Might as well mention it just to cover all bases.
When I get data from a DB, I like to use the "|" separator because I may have commas in my data. If you DB has null data it will return a "|" using word$(). For example if sql returned 3 fields and the middle is null you get "one||three". using this command result$ = #sql nextrow$("|") then using word$() for the second field you get "|" a2$ = word$(result$,2,"|") To get around the problem I always use a separator of "blank" and |" as in result$ = #sql nextrow$(" |"). Now using a trim$() with word$() using only the "|" will give you the blank you expect as in a2$ = trim$(word$(result1$,2,"|"))
HTH
|
|
|
word$()
Jul 5, 2008 14:12:26 GMT -5
Post by kokenge on Jul 5, 2008 14:12:26 GMT -5
I went back and read the definition of word$(), and didn't see where it mentions a single character delimiter.
However, I'm a little concerned because most of the time when I use it, I have multiple characters as a delimiter. For example data from a spread sheet usually has each data surrounded with a single quote and separated with a comma. So data like 1 2 3 4 5 6 .... will be exported from a spread sheet as '1','2','3','4','5','6' So when reading the data I add stuff to the front and end as dataIn$ = "'." + inputData$ + "." Then to get the data I use something like data$ = word$(dataIn$,i,"','") Also if you read stuff like the sqlite_master schema from your DB, you will find there is no other way to separate data other than using the field names themselves as delimiters.
I guess what I need to know is - will word$() in the future be restricted to a single character delimiter. If so I'll have to write my own word$() function.
Thanks for the help.. Have a great day.
|
|
|
word$()
Jul 6, 2008 19:09:39 GMT -5
Post by Carl Gundel - admin on Jul 6, 2008 19:09:39 GMT -5
Well first of all the bug will be fixed. I'll have to consider whether or not not support delimiters of more than one character. I don't forsee any reason why not.
-Carl
|
|