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.

[SOLVED] catch errors, dont make eggy die

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 »

The code still expects the supplied data to be a list, so using a string with the loadscript proc would still be "improper". Still, as long as you're very careful, you'll be safe.

The list commands used with uplevel (since user's fix) is used to avoid something known as double-evaluation, it does not affect the data passed to the foreach command, which still has to be a valid list.

The problem you are facing with "set scripts [list ... ]" is that you don't properly escape the newline character using \
Wrong:

Code: Select all

set scripts [list
scripts/script1.tcl
scripts/script2.tcl
scripts/script3.tcl
]
Correct:

Code: Select all

set scripts [list \
scripts/script1.tcl \
scripts/script2.tcl \
scripts/script3.tcl \
]
It is vital that there is no space or other charactes after the \ before the newline.

Whenever a string is evaluated (in this case due to []), a newline means end of command-line, and the first word on the next line is treated as a new command. Escaping the newline prevents this, and lets us span a single command-line over several lines.
NML_375
r
raider2k
Op
Posts: 140
Joined: Tue Jan 01, 2008 10:42 am

Post by raider2k »

well, know what? lol

i put a space after \ because of two reasons:

1. it seemed quite logic to me to escape a space char with \ so its really being treated as one

2. try to select that code of yours with your mouse and you'll notice that \[code\] puts a space after the \

plus, i made an important mistake, i didnt put a \ after the first line that contains "set scripts [list"

but wow .. im impressed because everything is working again and the mistakes were more of a minor matter. thx again for help :) (cant say that often enough ^^)
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Ahh, one more converted ;)

I believe those spaces were due to your browser; I've seen some browsers adding them on the fly, while others (like mine) don't. Unfortunately, it becomes a somewhat complicated structure when you want to do it proper, yet have one item per line.
NML_375
r
raider2k
Op
Posts: 140
Joined: Tue Jan 01, 2008 10:42 am

Post by raider2k »

k-meleon here ^^
and yup, thats probably why then, weird things are happening on the internet lol
Post Reply