Indirect reference Mod() error

Get help with using AutoHotkey and its commands and hotkeys
TAC109
Posts: 213
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Indirect reference Mod() error

16 Jun 2015, 18:11

Code: [Select all] [Download] (Untitled.ahk)GeSHi © Codebox Plus

y:="ur"
ur:=2, ur=mod(++ur,3) ; Works; ur=0
MsgBox %ur%
ur:=2, %y%=mod(++%y%,3) ; Error; ur=3?
MsgBox %ur%
ur:=2, %y%:=mod(++%y%,3) ; Works; ur=0
MsgBox %ur%

The failing code uses valid, allowable syntax.
My programs:-
ReClip - a Text Reformatting and Clip Management utility
XRef - Produces Cross Reference lists for scripts

hd0202
Posts: 61
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: Indirect reference Mod() error

16 Jun 2015, 23:56

You must use ":=mod(..." in all three cases --> expression

Hubert
guest3456
Posts: 2313
Joined: 09 Oct 2013, 10:31

Re: Indirect reference Mod() error

17 Jun 2015, 00:03

TAC109 wrote:The failing code uses valid, allowable syntax.


oh really?

TAC109
Posts: 213
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Indirect reference Mod() error

17 Jun 2015, 01:27

See help, scripts, variables and expressions, expression operators table
,
Comma (multi-statement) [v1.0.46+]. Commas may be used to write multiple sub-expressions on a single line. This is most commonly used to group together multiple assignments or function calls. For example: x:=1, y+=2, ++index, func(). Such statements are executed in order from left to right. Note: A line that begins with a comma (or any other operator) is automatically appended to the line above it. See also: comma performance.

In v1.0.46.01+, when a comma is followed immediately by a variable and an equal sign, that equal sign is automatically treated as an assignment (:=). For example, all of the following are assignments: x:=1, y=2, a=b=c.
Last edited by TAC109 on 17 Jun 2015, 02:05, edited 1 time in total.
My programs:-
ReClip - a Text Reformatting and Clip Management utility
XRef - Produces Cross Reference lists for scripts

just me
Posts: 5396
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Indirect reference Mod() error

17 Jun 2015, 01:51

%y% isn't a variable, it's a reference.
TAC109
Posts: 213
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Indirect reference Mod() error

17 Jun 2015, 23:30

just me wrote:%y% isn't a variable, it's a reference.

Yes, that is probably causing the unexpected result.
My programs:-
ReClip - a Text Reformatting and Clip Management utility
XRef - Produces Cross Reference lists for scripts


Return to “Ask For Help”

Who is online

Users browsing this forum: Monoxide3009, TomL and 19 guests