How to know whether parameter expects an expression? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Avtem
Posts: 43
Joined: 01 Jun 2021, 02:20

How to know whether parameter expects an expression?

Post by Avtem » 10 Jan 2022, 09:31

Take for example StringReplace function. How should I know that OutputVar (first parameter) should be an expression? There is no such thing in the documentation that says: "this parameter must be an expression" or "this parameter must use legacy syntax".
Does user have to guess/deduce/try whether treat parameter as expression/legacy syntax?

User avatar
mikeyww
Posts: 27139
Joined: 09 Sep 2014, 18:38

Re: How to know whether parameter expects an expression?

Post by mikeyww » 10 Jan 2022, 09:41

That command is deprecated, but an output variable is simply a variable name and nothing more or less. Fortunately, all of the commands come with examples in the documentation.
OutputVar. The name of the variable in which to store the result of the replacement process.
Last edited by mikeyww on 10 Jan 2022, 09:42, edited 2 times in total.

gregster
Posts: 9070
Joined: 30 Sep 2013, 06:48

Re: How to know whether parameter expects an expression?  Topic is solved

Post by gregster » 10 Jan 2022, 09:41

In short:
Outputvar parameters: never expressions (but variable names)
all other parameters: just force expression mode (% with a space following) for them, if you are unsure.

Details:
Spoiler

User avatar
Avtem
Posts: 43
Joined: 01 Jun 2021, 02:20

Re: How to know whether parameter expects an expression?

Post by Avtem » 19 Jan 2022, 00:05

@gregster Thank you so much, gregster for your detailed answer. So now i can see why it was confusing to me, because i use commands with "output var name" parameters very often.

So i want to learn how to use everything, because not everyone always forces an expression, right? And i want to be able to understand the other's people code.

But now i think i understand pretty much everything about this topic, so this topic can be closed now.

User avatar
boiler
Posts: 17131
Joined: 21 Dec 2014, 02:44

Re: How to know whether parameter expects an expression?

Post by boiler » 19 Jan 2022, 04:55

Avtem wrote: So i want to learn how to use everything, because not everyone always forces an expression, right? And i want to be able to understand the other's people code.
The times you see an expression in a command parameter without forcing an expression are when the documentation states that a particular parameter “can be an expression.” See the documentation for Sleep, for example. That allows for the following without a forced expression:

Code: Select all

Sleep, Minutes * 60 * 1000

Post Reply

Return to “Ask for Help (v1)”