Home page Home page Home page Home page
Pixel
Pixel Header R1 C1 Pixel
Pixel Header R2 C1 Pixel
Pixel Header R3 C1 Pixel
Pixel
By Sprezz | Wednesday 19 June 2013 22:42 | 0 Comments
There's a slight chance that the first part of the above playground call may not travel well for those that never played marbles at school. But given the average age of the Rev community this is probably not a lot of us.

Anyway a quick "whoops" that hit us recently which with hindsight is obvious but at the time surprised slightly.

Consider the following code



   string = "'John','','','','','Smith'"
   swap ",'',"  with ",null," in string



   if youExpectedTheResultantStringToBe = "'John',null,null,null,null,'Smith'" then
      goSub carryOnReading
   end
return

carryOnReading:

Well of course (if you're here) it wasn't - it was actually "'John',null,'',null,'','Smith'" and now we've pointed that out it will be painfully obvious won't it? The swap command traverses the string left to right looking for comma apostrophe apostrophe comma and replaces it with comma null comma so with the first pass

"'John','','','','','Smith'" becomes "'John',null,'','','','Smith'"

So swap continues from the last "touched" character +1 (effectively col2() + 1 - or in this case apostrophe (not comma)  and looks for the next comma apostrophe apostrophe comma, so with this pass
 
"'John',null,'','','','Smith'" becomes "'John',null,'',null,'','Smith'"

So the simple answer? Instead of swapping comma apostrophe apostrophe comma just swap comma apostrophe apostrophe. - so :-

   string = "'John','','','','','Smith'"
   swap ",''"  with ",null" in string

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]



<< Home

Pixel
Pixel Footer R1 C1 Pixel
Pixel
Pixel
Pixel