VBScript: how to refer to several variables at once?[solved]

This forum is meant for requesting technical support or reporting bugs.

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

VBScript: how to refer to several variables at once?[solved]

Postby Mystery » Fri Apr 21, 2006 2:43 pm

Hi
I haven't found a clue in the help files (though I may have overlooked something).

My simple question is: How to refer to several variables in VBScript?
E.g. I have the variables P1, P2, .... , P12. Now if I want something to happen if all of them are equal to 1, how can I make it shorter than to use:
if P1=1 and P2=1 and P3=1 (etc.) Then

Is there a way by putting brackets somewhere to have a shorter version to say that "if P1-12=1 then"?
Last edited by Mystery on Fri Apr 21, 2006 4:27 pm, edited 1 time in total.
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

Postby Candle » Fri Apr 21, 2006 4:09 pm

Wish I could help you with this but I suck at doing variables.
Please don't PM me questions, ask here in the forums!
``````````````
Between grand theft and a legal fee, there only stands a law degree.
User avatar
Candle
Administrator
 
Posts: 3077
Joined: Sat Feb 07, 2004 2:21 am
Location: Rudy's Bar

Postby Mystery » Fri Apr 21, 2006 4:13 pm

Anyway, thank you for your answer, Candle. :)

Maybe there is somebody who is better in these things than we are and has a solution to my question. Let's hope for the best. :idea:
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

Postby Candle » Fri Apr 21, 2006 4:17 pm

pm Shadow maybe he can help you.
Please don't PM me questions, ask here in the forums!
``````````````
Between grand theft and a legal fee, there only stands a law degree.
User avatar
Candle
Administrator
 
Posts: 3077
Joined: Sat Feb 07, 2004 2:21 am
Location: Rudy's Bar

Postby ShadowHunter » Fri Apr 21, 2006 4:20 pm

Hi,

If you are using just 0 or 1 you can just add them and check if the sum equals the amount of variables.

Example:

All 5 variables should be 1:

Code: Select all
If P1+P2+P3+P4+P5 = 5 Then


You can also solve this by making a loop (easy when using a lot more than 5 variables, this example 100 variables) and adding the the values by approaching the variables by there reference name.

Code: Select all
For k = 1 to 100
    Check = Check + VarByRef(P&k)
Next k

If Check = 100 Then ...


k will be 1,2,3,4,5,...,100 hence P1, P2, P3...P100

Please note that VarByRef is not the correct command, I know it can be done but can't remember the correct function... GM has posted it once :oops:

Kind regards,

ShAdOwHuNtEr
User avatar
ShadowHunter
Forum Admin and Games Page admin
 
Posts: 1304
Joined: Fri Jun 06, 2003 10:37 pm
Location: Belgium

Postby Mystery » Fri Apr 21, 2006 4:27 pm

Hi ShadowHunter,

Thank you very much. I should have come by myself to first solution of adding them together (what a simple solution!), but somehow it didn't come into my mind.
This method will do it for me perfectly for the moment! And if I ever want to try the other method, I will look for the post of GM to find the correct expression.

Thank you very much for your help! :)
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland


Return to Adventure Maker Technical Support and Bug Reports

Who is online

Users browsing this forum: No registered users and 0 guests