Jump to content

Quick Questions


Recommended Posts

What would be the best way to assign an operator to a variable?

What I'm trying to do is assign a '+' or '-' to a variable depending on the output of a random number.

Many thanks in advance.

Edit:Spellcheck...

Edited by Lithium
Link to comment
Share on other sites

What would be the best way to assign an operator to a variable?

What I'm trying to do is assign a '+' or '-' to a variable depending on the output of a random number.

Many thanks in advance.

Edit:Spellcheck...

Like this?

Local $var

If Random(1, 10) < 5 Then
    $var = "+"
Else
    $var = "-"
EndIf

If $var = "+" Then
    MsgBox(0, "", 1 + 1)
Else
    MsgBox(0, "", 1 - 1)
EndIf

You can't use a variable as an operator, so you'll have to use an If Then to check the variable and then change the operator used.

Edited by Hawkwing

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...