IF / ELSE statement

Get help with using AutoHotkey and its commands and hotkeys
euras
Posts: 265
Joined: 05 Nov 2015, 12:56

IF / ELSE statement

21 Nov 2017, 07:07

A simple question why the first example works and the second one not?

Code: [Select all] [Download] GeSHi © Codebox Plus

uf = 1
If (uf = 1)
uf = New Text
ufa := uf
MsgBox % ufa ; this one works


Code: [Select all] [Download] GeSHi © Codebox Plus

uf = 1
ufa := (uf = 1)?(uf = New Text):("") ; this one doesn't give me any value
MsgBox % ufa


While this example works..

Code: [Select all] [Download] GeSHi © Codebox Plus

count = 5
result := (count > 2 and count < 10)?(count + 3):(count <= 2)?(count - 1):("10")
MsgBox % result
User avatar
divanebaba
Posts: 208
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: IF / ELSE statement

21 Nov 2017, 07:34

ufa := (uf = 1)?(ufa = New Text):("") ; this one doesn't give me any value

This (ufa = New Text) is not a value, string or something else, you can store in a variable.

Try this:

Code: [Select all] [Download] GeSHi © Codebox Plus

uf = 1
ufa := (uf = 1)?("New Text"):("") ; this one will give you a value
MsgBox % ufa
return
"New Text" is storable into a variable.


[Starklichtbirne IQ >> 250!!] Dank deutscher Lehrerempfehlung, nur Superdepp und Hartz4-Bezieher, statt Abiturient und Einkommensbezieher.
[Strong light bulb IQ >> 250!!] Thanks to german teacher's recommendation, willful and welfare recipient, instead of high school graduate and moneymaker.

Entering high school for foreign children is not prohibited in GERMANY, it's only made nearly impossible by government.
Virtually the only way - visiting high school abroad.
euras
Posts: 265
Joined: 05 Nov 2015, 12:56

Re: IF / ELSE statement

21 Nov 2017, 16:34

so using this method I cannot create a new variable, just change the active one?
A_AhkUser
Posts: 625
Joined: 06 Mar 2017, 16:18
Location: France

Re: IF / ELSE statement

21 Nov 2017, 16:58

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Video Game Reader
Image
github
demo
euras
Posts: 265
Joined: 05 Nov 2015, 12:56

Re: IF / ELSE statement

22 Nov 2017, 12:22

thank you! now it makes sense for me :)

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 48 guests