Greetings!
In most other scripting languages there is a command that turns a text
string into an array and vice versa. Say you have a variable txt that contains:
fname=Scott
lname=Raney
company=MetaCard Corp.
Then
split txt with cr
would turn txt into an array with the line numbers as keys... and
split txt with cr and "="
would turn txt into an array with the keys "fname", "lname", and
"company" and the values "Scott", "Raney", and "MetaCard Corp.".
The syntax may need some rework as the two delimiter types are not
easily distinguished and "and" may prove to be ambiguous.
Accordingly that array could be turned back into a string using the join command:
join txt with cr and "="
A built-in commmand could have a better syntax and would be faster,
but now (MC2.3) that arrays can be passed and returned, we have written two
functions that do that (although you can't define the line delimiter):
on split @a,del
local o,L
if del is empty then put "=" into del
set the itemDelimiter to del
repeat for each line L in a
put item 2 to -1 of L into o[item 1 of L]
end repeat
put o into a
end split
on join @a,del
local o,L
if del is empty then put "=" into del
repeat for each line L in keys(a)
put L&del&a[L]&cr after o
end repeat
put o into a
end join
Note: The variable is converted in type... not shure if this is a future
safe technique.
There is one point left: What happens when you join an array that
contains values with returns?
Regards
R�diger
--
GINIT Technology GmbH [EMAIL PROTECTED]
Ruediger zu Dohna
phone: +49-721-96681-0
Technologiepark fax: +49-721-96681-11
Emmy-Noether-Str. 9
D-76131 Karlsruhe www.ginit-technology.de