| View previous topic :: View next topic |
| Author |
Message |
tic
Joined: 22 Apr 2007 Posts: 1318
|
Posted: Sat Jan 26, 2008 10:23 am Post subject: Functions not working in expression |
|
|
| Code: | Var = Hello,world,test
Loop, Parse, Var, `,
MsgBox, %A_LoopField% |
works, but:
| Code: | Loop, Parse, Function(), `,
MsgBox, %A_LoopField%
Function()
{
Return, "Hello,world,test"
} |
does not |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5009 Location: imaginationland
|
Posted: Sat Jan 26, 2008 11:06 am Post subject: |
|
|
| InputVar wrote: | | The name of the variable whose contents will be analyzed. Do not enclose the name in percent signs unless you want the contents of the variable to be used as the name. |
_________________
RegExReplace("irc.freenode.net/autohotkey", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2") |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1318
|
Posted: Sat Jan 26, 2008 11:38 am Post subject: |
|
|
yes....and....??
the returned value of Function() is the name of the variable. |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5009 Location: imaginationland
|
Posted: Sat Jan 26, 2008 11:45 am Post subject: |
|
|
It doesn't matter what is returned, Function() is not a variable name. _________________
RegExReplace("irc.freenode.net/autohotkey", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2") |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1318
|
Posted: Sat Jan 26, 2008 11:58 am Post subject: |
|
|
i think it still should be changed as it is inconsistent.
| Code: | Loop, % Function()
MsgBox, %A_Index%
Return
Function()
{
Return, 3
} |
works |
|
| Back to top |
|
 |
Obi-Wahn
Joined: 20 Apr 2006 Posts: 23 Location: Vienna
|
Posted: Tue Apr 08, 2008 11:35 am Post subject: |
|
|
I was ready to start a topic, but as I can see, there's allready a topic existing.
I'd also be happy, if it'd be possible to use a function or even a literal string in the parse-loop, like a for-loop using in batch.
Because (from my point of view) it would be more failsafe (one variable less) and I like code that doesn't function right, it should also look nice. (call me a geek )
Long story short: I'd be pleased if this would be changed.
Thanks
Obi-Wahn |
|
| Back to top |
|
 |
Rabiator
Joined: 17 Apr 2005 Posts: 264 Location: Sauerland
|
Posted: Tue Apr 08, 2008 3:06 pm Post subject: |
|
|
| tic wrote: | | i think it still should be changed as it is inconsistent. | It is not inconsistent.
As described in the help, Loop takes the value from a variable reference (like %Var%), not from a variable (like Var). Overtaking this term, % Function() is a variable reference. |
|
| Back to top |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 383 Location: Berlin
|
Posted: Tue Apr 08, 2008 9:35 pm Post subject: |
|
|
| Quote: | | Overtaking this term, % Function() is a variable reference. |
No this is not a variable reference. The percent sign just puts it into an expression. |
|
| Back to top |
|
 |
Rabiator
Joined: 17 Apr 2005 Posts: 264 Location: Sauerland
|
Posted: Wed Apr 09, 2008 6:20 pm Post subject: |
|
|
What is the the correct word for %Var%? Traditional and variable reference are often used in the documentation.
| Tuncay wrote: | | No this is not a variable reference. The percent sign just puts it into an expression. | You'll agree that in AutoHotkey %Var% is the same as % Var. From the help for MsgBox: | Quote: | | This parameter will not be recognized if it contains an expression or a variable reference such as %option%. |
Possibly you refer to a comment in the example given in that chapter: | Quote: | | By preceding any parameter with "% ", it becomes an expression. | Maybe this is an unfortunate formulation. "% " followed by an expression is a traditional style parameter.
I think this construction was originally most notably intended to easily identify placeholders for string replacement in a text, as you can see it in the options dialogs of many programs. In the sense of write-as-you-speak:
| Code: | MsgBox Hello %Name%, how are you?
; is more comfortable than
MsgBox("Hello " Name ", how are you?") |
__________________________________________
Created with BBCodeWriter 7.0 - the one and only  |
|
| Back to top |
|
 |
|