1. Splitting text up
- Posted by James W <james at whitwell.co.nz> Jan 16, 2006
- 478 views
- Last edited Jan 17, 2006
Hi i was woundering if it was possible to split some text up and then storing them in differint variables for example T e x t | | | | c1 c2 c3 c4 Thanks
2. Re: Splitting text up
- Posted by ags <eu at 531pi.co.nz> Jan 16, 2006
- 476 views
- Last edited Jan 17, 2006
James W wrote: > > > Hi i was woundering if it was possible to split some text up and then storing > > them in differint variables > > for example > > T e x t > | | | | > c1 c2 c3 c4 > > Thanks Hi James Euphoria's treatment of "strings" of text is quite nice as it is just a flat sequence. i.e.
text = "Text" -- is equivalent to text = {'T', 'e', 'x', 't'} -- nb this is a sequence of character _values_, ie text = {84, 101, 120, 116} -- same thing
Therefore
atom c1, c2, c3, c4 c1 = text[1] c2 = text[2] c3 = text[3] c4 = text[4]
I don't know why you would want to do this though, as any results you get you would surely want to store in a sequence, as in:
sequence vals vals = {} -- important to initialise to empty sequence before using append() for i = 1 to length(text) do vals = append(vals, text[i]) end for -- the variable 'vals' is now identical to 'text'!![]()
Far be it from me to guess why you asked the question though :) You would want to do this more often for calculating values within the for loop. Gary