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.

Where I did wrong?

Old posts that have not been replied to for several years.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Here is your original problem:
Hi. This is a smal part of a proc from where I can't find where is the error. It seems that he dosen't remove $nick from the list and I can't see why is doing so. Can someone please point me the mistake? Thanks.
If $nick isn't being removed from the list, there are only a few possibilities:

1. The proc isn't even being called to remove that nick
2. It is being called, but removing it incorrectly
3. The nick is added more than once

Those are the only 3 possibilities, right? So first, add debugging statements to see which one of them it is. The first one is easy to find out, use putlog at the top of the proc to say "Hello I am being called to remove $nick". The second one is also easy, just use putlog to display the list at the top and then at the bottom, and you can verify that the nick is being removed. The third one is easy as well, add putlogs to wherever you add nicks to the list, saying "Hello I am adding $nick to the list".

This is common debugging strategy: find all places where the error might be occurring, and inspect the data at those places.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Ok. Thanks for the tips. I'll do this ASP and reply with the results, if any.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Is there a diference betwin set voicelist [lreplace $voicelist $index $index ] and lreplace $voicelist "$index $index"] or set voicelist [lreplace $voicelist "$index $index"]? The part and the sign where binded in the same proc, when a user was parting the channel he/she was removed.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

The last 2 are both invalid. The first 1 is right. By the way, for future reference, you can easily test small statements likes these yourself with tclsh:

Code: Select all

% set voicelist [list a b c d e f g]
a b c d e f g
% set index 2
2
% set voicelist [lreplace $voicelist $index $index ]
a b d e f g
% lreplace $voicelist "$index $index"]
extra characters after close-quote
% set voicelist [lreplace $voicelist "$index $index"]
wrong # args: should be "lreplace list first last ?element element ...?"
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I said lreplace next(list) "$index $index", without the "]" :) You have put in your test: % lreplace $voicelist "$index $index"] , modify and test again please. I don't have my pc home and I can't test right now nothing :( Catch you later. Thanks for replys.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Code: Select all

1:
% lreplace $voicelist "$index $index"] 
extra characters after close-quote 
2:
% set voicelist [lreplace $voicelist "$index $index"] 
wrong # args: should be "lreplace list first last ?element element ...?"
What you ask for is the same as number 2, which produces the error shown in number 2.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I've said to put lreplace $voicelist "$index $index" without the "]". I've sow in a tcl an lappend that is looking like: lappend something "$foo $bar". Isnt' the same thing?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

It's people like you that even fail to look at a post above, instead of commenting what the first thing ou see that gets to me.

OK - take the line.

Code: Select all

set list [lreplace $list "$index $index"]
You have asked for this to be done without the "]"

OK - you do that

Code: Select all

set list [lreplace $list "$index $index"
Woops, this produces and error that the "]" is missing.

Lets remove the "["

Code: Select all

set list lreplace $list "$index $index"
Band, another error stating the set command has too many arguments.

What exactly is your problem, apart from trying to waste our time.

Maybe if you spoke in whole sentaces it would help..
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Humm.. I've said to test only the lreplace next(list) "$index $index" , without the set next(list) part. I'm sorry if I haven't made myself understood and if I'm wasting your precious time.

PS: Don't take the last sentence as a sign of rudeness.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Caesar,

Learn to test things yourself buddy. The whole point of my last post was to show you how easy it is to test things with tclsh. You start tclsh, make some test data, and then experiment with all the lreplace stuff you want. You can test 10 different statements in about 2 minutes.

Right now you are just being 100% lazy, asking other people to test a SINGLE tcl statement that has nothing to do with eggdrop, rather than doing it yourself. It is a monumental waste of time. It would take far less time to test it yourself than coming here and saying "you didn't test THIS statement" or "well does THIS work then?"

Now, on to the details.
I've said to put lreplace $voicelist "$index $index" without the "]". I've sow in a tcl an lappend that is looking like: lappend something "$foo $bar". Isnt' the same thing?
You have got to be kidding if you think lreplace and lappend are the same thing. Look in the Tcl manual for the differences, but the short answer is "no."

Next...
Humm.. I've said to test only the lreplace $list "$index $index" , without the set next(list) part. I'm sorry if I haven't made myself understood.
Dude, do you even read other posts? I already tested that with set voicelist [lreplace $voicelist "$index $index"]. The set makes no difference, we're not testing that command, and it's not causing an error. It c learly showed that the lreplace command was causing an error (wrong # args) and that doesn't change if the set is there or not.

Finally...
Ok. Thanks for the tips. I'll do this ASP and reply with the results, if any.
Did you ever add the debugging statements? That is what started this whole thread after all.

So here's my new advice for you. Get some self confidence man! You don't need us to test simple tcl statements for you. You Can Do It! First, for questions of syntax (like lreplace, lappend), go to the Tcl manual. Second, for "does this work?" try it yourself in tclsh. It's very easy. You can do it all night long!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Oups, sorry for my mistake guys. I have resolved the problem with the quit. Many thanks for the effort to point me my mistake with the lreplace thing. Sorry again..
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Another satisfied customer.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I didn't was lazy, I just don't have a pc at home any more. Right now I'm at a friend and I was replyng the topics in a very huge hurry. 'm sorry for the mistake. I've realised my mistakle. Thanks and sorry again.[/code]
Locked