This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Save array to file / restore array from file

Help for those learning Tcl or writing their own scripts.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Using upvar, I can control at which level I should access the variable, and with a fixed name, while global only access the variable under the same name in globalspace. You could probably modify the code with ease to use global instead.

I'll give you a simple example, as I'm not sure you are keeping the array index name and it's value apart...

Code: Select all

set var "Testing
Testing
Testing"
set myArray($var) "This is a value
spanning multiple lines
and containing several words...
The array index holding this value also has several newlines"

##or simpler:
set myArray(line\ 1\nline\ 2) "Some\ndata..."
Both versions will add values to the myArray array, each value containing at least one newline, and each array index name also containing both newlines and spaces...
NML_375
Post Reply