Can I automatically see the variable from my if statement?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Pepper Potato
Posts: 8
Joined: 22 Jun 2021, 06:08

Can I automatically see the variable from my if statement?

03 Aug 2021, 20:32

I want something like this:

Code: Select all

if (VERIFY_FIRST_NAME(wholename))
   {msgbox, the verified first name is %v%
   }
Is it possible to do this like this?

I'm trying to avoid doing this:

Code: Select all

v:=VERIFY_FIRST_NAME(wholename))
if (v)
   {msgbox, the verified first name is %v%
   }
Thank you.
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Can I automatically see the variable from my if statement?

03 Aug 2021, 20:51

Is this what you want? Maybe I don't understand the question, Is VERIFY_FIRST_NAME(wholename) a function in your program?

Code: Select all

v := "ahk"
if (v = "ahk")
   {msgbox, the verified first name is %v%
   }
User avatar
mikeyww
Posts: 26938
Joined: 09 Sep 2014, 18:38

Re: Can I automatically see the variable from my if statement?

03 Aug 2021, 20:51

Code: Select all

If ((v := VERIFY_FIRST_NAME(wholename)) > "")
 MsgBox, The verified first name is %v%.
   
VERIFY_FIRST_NAME(wholename) {
 Return "Jim"
}
Pepper Potato
Posts: 8
Joined: 22 Jun 2021, 06:08

Re: Can I automatically see the variable from my if statement?

03 Aug 2021, 21:04

Code: Select all

If ((v := VERIFY_FIRST_NAME(wholename)) > "")
That works perfectly!

But if anyone finds a shorter way please let me know.

> Is VERIFY_FIRST_NAME(wholename) a function in your program?

Yes. A custom function.
User avatar
Chunjee
Posts: 1422
Joined: 18 Apr 2014, 19:05
Contact:

Re: Can I automatically see the variable from my if statement?

03 Aug 2021, 21:54

Pepper Potato wrote:
03 Aug 2021, 21:04
But if anyone finds a shorter way please let me know
if (v := VERIFY_FIRST_NAME("wholename")) { is slightly shorter if your function can return false :thumbup:
User avatar
mikeyww
Posts: 26938
Joined: 09 Sep 2014, 18:38

Re: Can I automatically see the variable from my if statement?

03 Aug 2021, 22:38

That's all good, but I've decided to change my full name to 0.

:)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, Google [Bot], wineguy and 342 guests