Notifications
Clear all
[Closed] String Parsing Help
Dec 05, 2006 11:20 pm
I am having a hard time finding a good way to parse a string and store it in an array… here is an example:
I parsed this from a file:
(320 -192 448) (0 -192 448) (0 -192 0)"
the original string of text in the file looked like this:
"id1" "(320 -192 448) (0 -192 448) (0 -192 0)"
I would like to have that string end up in an array like this:
#([320,-192,448],[0,-192,448],[0,-192,0])
any help would be greatly appreciated
Thanks
-Baker
4 Replies
Dec 05, 2006 11:20 pm
Hi Jonathan,
I think that the best solution is to use filterString method in string class like this :
parsedLine = "(320 -192 448) (0 -192 448) (0 -192 0)"
filteredLine = filterString parsedLine "() "
pointArray = #()
for i = 1 to filteredLine.count by 3 do
(
point = Point3 (filteredLine[i] as float) (filteredLine[i+1] as float) (filteredLine[i+2] as float)
append pointArray point
)
print pointArray
Dec 05, 2006 11:20 pm
Hi Jonathan,
It’s my own code. I’ve coded it for you :).
Moreover filterString is a very handy method when parsing strings.
Dec 05, 2006 11:20 pm
thank you very much I am very appreciative … not much else to say except thanks alot I need the help
-Baker