Need help for what could be an array? ? Just sequences of numbers

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
blad4
Posts: 315
Joined: 07 Oct 2015, 11:06

Re: Need help for what could be an array? ? Just sequences of numbers

22 Jun 2020, 06:37

Hi Rohwedder, all has been working great, thank you.

I have encountered a small problem when reaching the upper limit of the numbers.

A is max 268, this is fine, but B needs to still be 3 more than A, so max 271

and changing

Code: Select all

ch2:=1+Mod(ch2+=267+Delta,268)
obviously gives big errors.

Essentially I am trying to get

Code: Select all

if ch1(209,221) ; let's assume A is 216
	D(52,1)
To yield A: 268 and B: 271
Rohwedder
Posts: 7628
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Need help for what could be an array? ? Just sequences of numbers

22 Jun 2020, 06:58

Hallo,
only a try (untested):

Code: Select all

D(Delta,Exit:=False)
{ ;A+=Delta,if A>268 then A-=268,Else if A<1 then A+=268
  ;B+=Delta,if B>271 then B-=268,Else if B<4 then B+=268
	A:=1+Mod(A+=267+Delta,268)
	B:=4+Mod(B+=264+Delta,268)
	IF Exit
		Exit ;makes a Return
}
blad4
Posts: 315
Joined: 07 Oct 2015, 11:06

Re: Need help for what could be an array? ? Just sequences of numbers

22 Jun 2020, 07:11

Thank you for the try, but nothing seems to work with that in place.
Rohwedder
Posts: 7628
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Need help for what could be an array? ? Just sequences of numbers

22 Jun 2020, 09:03

Try:

Code: Select all

Global A:=216, B:=219
Return
q::
MsgBox,% Text := "A  >  B`n" A " > " B
D(52)
MsgBox,% Text .= "`nD(52):`n" A " > " B
D(1)
MsgBox,% Text .= "`nD(1):`n" A " > " B
Return
D(Delta,Exit:=False)
{ ;A+=Delta,if A>268 then A-=268,Else if A<1 then A+=268
  ;B+=Delta,if B>271 then B-=268,Else if B<4 then B+=268
	A:=1+Mod(A+=267+Delta,268)
	B:=4+Mod(B+=264+Delta,268)
	IF Exit
		Exit ;makes a Return
}
blad4
Posts: 315
Joined: 07 Oct 2015, 11:06

Re: Need help for what could be an array? ? Just sequences of numbers

22 Jun 2020, 09:49

Delete
Last edited by blad4 on 24 Jun 2020, 05:29, edited 1 time in total.
Rohwedder
Posts: 7628
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Need help for what could be an array? ? Just sequences of numbers

24 Jun 2020, 04:07

I have no idea what this is all about and I do not know your function ch1( , ).
The modulo function Mod( , ) https://www.autohotkey.com/docs/commands/Math.htm#Mod
is elementary mathematics which really everybody can learn!
blad4
Posts: 315
Joined: 07 Oct 2015, 11:06

Re: Need help for what could be an array? ? Just sequences of numbers

24 Jun 2020, 05:28

Code: Select all

D(Delta,Exit:=False)
{
	A:=1+Mod(A+=267+Delta,268)
	B:=4+Mod(B+=264+Delta,268)
Thanks, I understand Modulo! I just do not understand 'Delta,268' in this case

We start with

A:=8, B:=11

When we get to

A:=216, B:=219

if A(209,221)
D(52,1)


A becomes 268

B does not become 271

My try at the equation so you can see where my understanding fails:

4+Mod(483+(Difference between 483 and 268??))
Rohwedder
Posts: 7628
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Need help for what could be an array? ? Just sequences of numbers

24 Jun 2020, 07:39

Try:

Code: Select all

Global A:=8, B:=11
Return
q::
MsgBox,% Text := "A  >  B`n" A " > " B
D(208)
MsgBox,% Text .= "`n with D(208) we get:`n" A " > " B
IF A(209,221)
	D(52)
MsgBox,% Text .= "`n with D(52) we get:`n" A " > " B
Return

D(Delta,Exit:=False)
{ ;A+=Delta,if A>268 then A-=268,Else if A<1 then A+=268
  ;B+=Delta,if B>271 then B-=268,Else if B<4 then B+=268
	A:=1+Mod(A+=267+Delta,268)
	B:=4+Mod(B+=264+Delta,268)
	IF Exit
		Exit ;makes a Return
}
A(Min:=1,Max:=268)
{ ;Return A between Min and Max
	Return, A>=Min And A<=Max
}
and you will see: A becomes 268 and B becomes 271.

Explanation of the syntax used:

Code: Select all

A:=1+Mod(A+=267+Delta,268)
B:=4+Mod(B+=264+Delta,268)
is a short form of:

Code: Select all

A := A + 267 + Delta
A := 1 + Mod(A, 268)
B := B + 264 + Delta
B := 4 + Mod(B, 268)
blad4
Posts: 315
Joined: 07 Oct 2015, 11:06

Re: Need help for what could be an array? ? Just sequences of numbers

24 Jun 2020, 08:58

Thanks so much for the explanation. Now I understand what is happening and why it doesn't work, because it keeps going into negative nubers before I can get to A being >=209!

Remember I have 6 strings, here are 5 and 6 to show the example that this function needs to work uniformly across all numbers below 271:

Code: Select all

#IF String = 5
Left::
if A(222,234)
	D(-65,1)
if A(157,169)
	D(-65,1)
if A(92,104)
	D(-78,1)
if A(14,26)
	D(230,1)
if A(235,260)
	D(-13,1)
Right::
if A(222,247)
	D(13,1)
if A(248,260)
	D(-234,1)
if A(14,26)
	D(78,1)
if A(92,104)
	D(65,1)
if A(157,169)
	D(65,1)
Return
#IF String = 6
Left::
if A(261,273)
	D(-52,1)
if A(209,221)
	D(-39,1)
if A(170,182)
	D(-65,1)
if A(105,117)
	D(-78,1)
if A(27,39)
	D(208,1)
if A(209,247)
	D(26,1)
Right::
if A(261,273)
	D(-26,1)
if A(235,247)
	D(-208,1)
if A(27,39)
	D(78,1)
if A(105,117)
	D(65,1)
if A(170,182)
	D(39,1)
if A(209,221)
	D(52,1)
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Descolada, Fredrik F, maxkill, RandomBoy, ShatterCoder and 325 guests