What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Public variables...

Public variables...
Author: Message:
Toneo
Junior Member
**

Avatar
Epic.

Posts: 35
Reputation: 2
29 / Male / Flag
Joined: Jul 2007
O.P. Huh?  Public variables...
Hi, I need help...

I have a variable declared outside of my function. However, it reads this variable from inside the function but in that function or any other function it won't change it. I have a boolean...

allow = true;

function blahBlah()
{
...stuff
if (stuff) { if (allow = true) { stuff } else { stuff } }
}

function otherStuff()
{
allow = false;
}

So when I do blahBlah() it works perfectly, When I change it however to false using otherStuff, and then use blahBlah, it still thinks that allow is true. Which it shouldn't be..
[Image: signature-user=291&back=4&clr=12,102,237&size=80.png]
11-04-2007 06:45 PM
Profile E-Mail PM Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
RE: Public variables...
try "var allow = true"

and also, in your if statement, it should be == and not = otherwise it will always return true. ;)
[quote]
Ultimatess6
: What a noob mod
11-04-2007 06:54 PM
Profile PM Web Find Quote Report
Toneo
Junior Member
**

Avatar
Epic.

Posts: 35
Reputation: 2
29 / Male / Flag
Joined: Jul 2007
O.P. Grin  RE: Public variables...
I already have var in front.

Ha, I'm such an idiot. I should have == not =. I always make those mistakes... :D
[Image: signature-user=291&back=4&clr=12,102,237&size=80.png]
11-04-2007 06:55 PM
Profile E-Mail PM Find Quote Report
FlashTato
New Member
*


Posts: 1
Joined: Nov 2007
RE: Public variables...
As said by roflmao456, if you use the EQUAL (=) operator that will return always true as you are going to assign a value to the var.

For comparing 2 vars you should use the IS_EQUAL operator (==).

code:
var foo = true;  //Declare a variable statement

if(foo == true){ //or simply if(foo)...
//Your code
}


quote:
I already have var in front.

That doesn't matter. ;)

This post was edited on 11-04-2007 at 07:20 PM by FlashTato.
11-04-2007 07:18 PM
Profile PM Find Quote Report
Toneo
Junior Member
**

Avatar
Epic.

Posts: 35
Reputation: 2
29 / Male / Flag
Joined: Jul 2007
O.P. RE: Public variables...
Yes. I hate making these mistakes. Heh, Thanks for pointing it out though. Works perfectly.

= is the variable assignment operator
== checks equality of one to the other
[Image: signature-user=291&back=4&clr=12,102,237&size=80.png]
11-04-2007 07:21 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On