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 

$var

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
dutch1918
Voice


Joined: 30 Jul 2014
Posts: 14

PostPosted: Fri Oct 03, 2014 7:17 pm    Post subject: $var Reply with quote

I have a $var that has data +###.## or -###.##. What I want to do is "if the $var has +###.## then do something. This is what I have thus far but it doesn't work...

Code:

if {[$change]!="+"} {
        putserv "PRIVMSG $channel :\[\00304DJIA\017]\00303 --> $last $change\017 | $timestamp"
        } else {
      putserv "PRIVMSG $channel :\[\00304DJIA\017]\00304 --> $last $change\017 | $timestamp"
        }   
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Sat Oct 04, 2014 3:16 am    Post subject: Reply with quote

Hi,

you should use string first to get what you want:
Code:

if {[string first "+" $var] == 0]} {
   putserv "PRIVMSG $channel :\[\00304DJIA\017]\00303 --> $last $change\017 | $timestamp"
} elseif {[string first "-" $var] == 0]} {
   putserv "PRIVMSG $channel :\[\00304DJIA\017]\00304 --> $last $change\017 | $timestamp"
}

_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
dutch1918
Voice


Joined: 30 Jul 2014
Posts: 14

PostPosted: Sat Oct 04, 2014 8:33 am    Post subject: Reply with quote

I get the following error back:

Tcl error [pub:test]: invalid character "]" in expression "...irst "+" $change] == 0]"

After further research I resolved it. Here is the correct syntex:

Code:

set plus [string first "+" $change]
set minus [string first "-" $change]
   if {$plus == !1} {
        putserv "PRIVMSG $channel :\[\00312DJIA\017]\002 -->\017 \00303$last $change\017 | $timestamp"
        } elseif {$minus == !1} {
      putserv "PRIVMSG $channel :\[\00312DJIA\017]\002 --> \017\00304$last $change\017 | $timestamp"
        } else {
      putserv "PRIVMSG $channel :\[\00312DJIA\017]\002 --> $last \017 | $timestamp"
   }
}
Back to top
View user's profile Send private message
Fire-Fox
Master


Joined: 23 Sep 2006
Posts: 270
Location: /dev/null

PostPosted: Sat Oct 04, 2014 3:41 pm    Post subject: Reply with quote

Code:
{$minus == !1}


is wrong the !

it should with == as in != ex
_________________
GreatZ
Fire-Fox | Denmark

Scripts: Relay | Store Text | TvMaze
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help 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