This works with the two cases you described. I've heard that "repeat while" isn't the fastest option, but it sounded like 6 repeats would be an extreme case, so it probably doesn't matter.
on testingTesting -- 10.26.12.47.38.52.71 -- 10.26 0.12 0.47 0.38 0.52 0.71 -- put "80.26.12" into tBlerg -- put "10.26.12.47.38.52.71" into tBlerg put "10.26" into tBlerg put convertWordToNumbers(tBlerg) into tBlergBlerg end testingTesting function convertWordToNumbers pWordN put pWordN into tWord split tWord by "." if the number of lines of the keys of tWord > 2 then put tWord[1] & "." & tWord[2] into tAll put 3 into tCounter repeat while tCounter <= the number of lines of the keys of tWord put " 0."& tWord[tCounter] after tAll put tCounter + 1 into tCounter end repeat return tAll end if return pWordN end convertWordToNumbers On Tue, Nov 10, 2015 at 5:07 PM, Alejandro Tejada <capellan2...@gmail.com> wrote: > Hi All, > > Recently, while updating Ian's SVGL > to import some SVG archives that > you could download from OpenClipart.org > I found an error processing this number: > 80.26.12 > > This looks like a number with two decimal points > but it's a shorthand for two numbers that some > SVG editors use to save space by replacing two numbers > like 80.26 0.12 with a single word like this: 80.26.12 > Notice that two characters: " 0" (a space and > number zero) are missing. > > Quickly, I scripted a workaround like this: > > Function ConvertWordtoNumbers pWordN > > put pWordN into tWordNumber -- pWordN contains "80.26.12" > > if "." is in tWordNumber > then > > replace "." with cr in tWordNumber > if the number of lines of tWordNumber = 3 > then > return line 1 of tWordNumber & "." & line 2 of tWordNumber && "0." & line 3 > of tWordNumber > else return pWordN -- unchanged word or unchanged number > end if > > else > return pWordN > end if > > end ConvertWordtoNumbers > > My question is: > How could you rewrite this code > to make it more elegant, faster, > efficient and cover an extreme > case like this: > 10.26.12.47.38.52.71 > (6 numbers in a single word) > 10.26 0.12 0.47 0.38 0.52 0.71 > > Autotracing applications could produce > curves as unusual as these. > > Thanks in advance! > > Al > _______________________________________________ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode