Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ VBscript ➜ Adding to a variable

Adding to a variable

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Metsuro   USA  (389 posts)  Bio
Date Sun 08 Aug 2004 04:32 AM (UTC)
Message
Trying to get a trigger to get a varialbe ane have it add to the vairable

Your power level increases by 4 points.

of of this, the levels can go into the millions using commas where they should be in the number order. And i am not really sure how i would even attempt to do this

Everything turns around in the end
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #1 on Sun 08 Aug 2004 05:51 AM (UTC)
Message
Im not quite sure what youre asking.

SetVariable "Number", Cint(GetVariable("Number"))+%1
will add the variable "Number" to %1 and store it as number.

About commas, Do you mean you can get a number with commas? I believe someone has a script snippet to get rid of them with a bunch of bells and whistles. But, Im not quite sure what youre asking for.


If you want to do that, I believe this should work:
SetVariable "Number", Cint(GetVariable("Number"))+CInt(Replace(%1, ",", ""))

This will remove the commas from a number, before adding it to the variable.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #2 on Sun 08 Aug 2004 05:58 AM (UTC)

Amended on Sun 08 Aug 2004 06:02 AM (UTC) by Metsuro

Message
yea i meant cause the numbers in the promt can be like 1,000 and 100,100 and stuff like that was just trying to figure out if i could make it add the numbers without the commas. And i tried what you suggest it didn't work

Everything turns around in the end
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #3 on Sun 08 Aug 2004 06:03 AM (UTC)
Message
You mean without the commas? That replace function should work. Assuming youre using VBscript. Replace is a VBscript function, not a MC one.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #4 on Sun 08 Aug 2004 06:06 AM (UTC)
Message
Error number: -2146828275
Event: Execution of line 1 column 1
Description: Type mismatch: '[string: ""]'
Line in error:

Called by: Immediate execution

Thats what i get

Everything turns around in the end
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #5 on Sun 08 Aug 2004 06:09 AM (UTC)
Message
Try this:

SetVariable "Number", Cint(GetVariable("Number"))+CInt(Replace("%1", ",", ""))

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #6 on Sun 08 Aug 2004 06:11 AM (UTC)
Message
Ok yes not it works wonders thank you greatly

Everything turns around in the end
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #7 on Sun 08 Aug 2004 06:13 AM (UTC)
Message
Error number: -2146828282
Event: Execution of line 1 column 1
Description: Overflow: 'Cint'
Line in error:

Called by: Immediate execution

Spoke to soon heh. After it ran a few times this poped up

Everything turns around in the end
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #8 on Sun 08 Aug 2004 06:19 AM (UTC)
Message
It works fine till hitting about 33727 before i get that error

Everything turns around in the end
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #9 on Sun 08 Aug 2004 06:47 AM (UTC)
Message
32767. Thats the unsigned integer limit.
Youll get that error if you try and CInt something larger than that.

If you wont get a number larger than that (per gain) you could try this:

SetVariable "Number", GetVariable("Number")+CInt(Replace("%1", ",", ""))

That should still work. However, if your %1 is larger than that number... Youll get the error.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #10 on Sun 08 Aug 2004 06:51 AM (UTC)
Message
Try this:
SetVariable "Number", CLng(GetVariable("Number"))+CLng(Replace("%1", ",", ""))

If you have decimals, it will round. But with just integers, you'll have no funny answers.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


27,603 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.