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.

New "can't read variable" error in Bogustrivia

Support & discussion of released scripts, and announcements of new releases.
Post Reply
User avatar
Exedore
Halfop
Posts: 43
Joined: Sun Jan 27, 2008 10:04 pm

New "can't read variable" error in Bogustrivia

Post by Exedore »

Code: Select all

Tcl error [TAdd]: can't read "wrotetoerr": no such variable
This is after adding a question file with 2 lines to test the script.

Code: Select all

question1*answer
question2*answer
No special characters in questions/answers.

....aaand show must go on.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Re: New "can't read variable" error in Bogustrivia

Post by speechles »

Exedore wrote:

Code: Select all

Tcl error [TAdd]: can't read "wrotetoerr": no such variable
The script isn't initializing that variable for all instances. Rather than set a 0 at top and when an error occurs, set a 1. It is setting the 0's and 1's itself manually. So to avoid that error, you can init that error variable before it enters it's while loop to iterate the file contents.

Noticing though, this script does a very poor job of initializing variables it uses. These "no such variable" errors are rife in this script because of this. It tries to figure out success and fail conditions and sets the variable accordingly. A normal script would initialize the variable as success. Now all the script has to do is detect fail. The var is pre-initialized for success. This is the reason for everyone's issues with "no such variable" errors. The way the logic is written, does not cover every possible outcome, and there are times when it will fail trying to read an uninitialized variable. It's too bad...

But.. You can force it to initialize the variables as you come across them, and fix this glaring problem.. For your first one..

Find the line below...

Code: Select all

while {![eof $qesfil]} {  set qline [gets $qesfil]
Above it add...

Code: Select all

set wrotetoerr 0
This should solve your issue. I'm guessing you didn't use a newline before you cause the EOF for the very last line of the file (ie, you didn't press ENTER after every line, even the last one). The code appears to expect a blank line at the end of the file containing the EOF marker by itself.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

BogusTrivia .add and .addk commands require all new trivia files to have 3 questions or more. The file you tried to add had only 2.

Next time add only files with 3 or more questions each.

Goodluck, SpiKe^^
mytclscripts.com
Post Reply