| View previous topic :: View next topic |
| Author |
Message |
Exedore Halfop

Joined: 27 Jan 2008 Posts: 43
|
Posted: Thu Jan 05, 2012 9:55 pm Post subject: New "can't read variable" error in Bogustrivia |
|
|
| Code: | | 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: | question1*answer
question2*answer |
No special characters in questions/answers.
....aaand show must go on. |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Fri Jan 06, 2012 3:01 pm Post subject: Re: New "can't read variable" error in Bogustrivia |
|
|
| Exedore wrote: | | Code: | | 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: | | while {![eof $qesfil]} { set qline [gets $qesfil] |
Above it add...
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. _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Sun Apr 22, 2012 7:21 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
|