How to use "global" inside IF statements ? Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
User avatar
xMaxrayx
Posts: 164
Joined: 06 Dec 2022, 02:56
Contact:

How to use "global" inside IF statements ?

Post by xMaxrayx » 03 Jun 2023, 22:05

Hi, I made a global variable, and idk how to use the "IF" statement with it without making a new local variable.

I tired this and I got error with this code

Code: Select all

if (global aa=1)

I tried this looks strange idk if it works but no error msg

Code: Select all

 global  
            if ( aa=1)
                {
                    Send "^{End}"
                    return
                }
but with "else if" give me err

Code: Select all

   
   global  
   else if (aa=2)
                {
                    Send ("{Right 3}{Space}")
                    
                    return
                }

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: How to use "global" inside IF statements ?  Topic is solved

Post by swagfag » 03 Jun 2023, 23:00

if ure only ever gonna read the variable(as seems to be the case based on the code uve shown so far), then u dont need to declare anything global

otherwise, write global aa somewhere before the beginning of ur if-elif-else block

User avatar
xMaxrayx
Posts: 164
Joined: 06 Dec 2022, 02:56
Contact:

Re: How to use "global" inside IF statements ?

Post by xMaxrayx » 04 Jun 2023, 05:01

@swagfag
Oh, I see thank you so much.
-----------------------ヾ(•ω•`)o------------------------------
https://github.com/xmaxrayx/

Post Reply

Return to “Ask for Help (v2)”