Set a variable to two different values Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
SPabs
Posts: 11
Joined: 15 Jun 2014, 03:20

Set a variable to two different values

04 Nov 2016, 19:36

I want to make a script for a card game in which an Ace equals 1 or 11. The only thing I can think to do is have a variable, call it "Ace," and set it equal to 1 and/or 11; however, I can't figure out how to do this... I can make Ace:=1 or Ace:=11, but not Ace:=1 or 11. How would I go about this? Would there be a better method?
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: Set a variable to two different values  Topic is solved

04 Nov 2016, 19:45

what about an array

Code: Select all

Ace := [ 1, 11 ]

msgbox % Ace.1 " or " Ace.2
If Ace must equal either 1 or 11 based on "some other factor" you could use ternary something like this

Code: Select all

SomeOtherFactor := 1

Ace := ( SomeOtherFactor = 1 ) ? 1 : 11

msgbox % Ace

Ace := ( SomeOtherFactor = 0 ) ? 1 : 11

msgbox % Ace
If this a static string manipulation, you could simply go

Code: Select all

Ace := 11

msgbox % SubStr( Ace, 1, 1 ) " or " Ace
SPabs
Posts: 11
Joined: 15 Jun 2014, 03:20

Re: Set a variable to two different values

13 Nov 2016, 07:54

Thanks, that's more than I could have asked for

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Mateusz53, peter_ahk, Rohwedder and 196 guests