egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

New "can't read variable" error in Bogustrivia

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
Exedore
Halfop


Joined: 27 Jan 2008
Posts: 43

PostPosted: Thu Jan 05, 2012 9:55 pm    Post subject: New "can't read variable" error in Bogustrivia Reply with quote

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
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Fri Jan 06, 2012 3:01 pm    Post subject: Re: New "can't read variable" error in Bogustrivia Reply with quote

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...
Code:
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.
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Sun Apr 22, 2012 7:21 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber