objects: 0-based array, shift key numbers by an offset

Get help with using AutoHotkey and its commands and hotkeys
User avatar
jeeswg
Posts: 2039
Joined: 19 Dec 2016, 01:58
Location: UK

objects: 0-based array, shift key numbers by an offset

17 Jul 2017, 10:54

I recently wanted to make an array with a 0-based index. (Although generally I prefer a 1-based index.) I wondered if anyone had any other ideas re. this issue. Thanks.

I've also tried here to shift an array to start at key -5 or 6, although to shift it upwards appears to be more difficult, if anyone can better the script below, although I did find a reasonably good solution, if a StrRept function is used.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



==================================================

[EDIT:] I just thought of a simpler more general method, although the earlier methods can be useful, if you want to modify an existing array.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



==================================================

[EDIT:] Re. a 1-based index, so maybe I agree with the dog.
« What's on your mind? » - Page 168 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=17&t=52&p=156027#p156027
Last edited by jeeswg on 17 Jul 2017, 13:00, edited 1 time in total.
User avatar
Xtra
Posts: 780
Joined: 02 Oct 2015, 12:15

Re: objects: 0-based array, shift key numbers by an offset

17 Jul 2017, 12:17

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Helgef
Posts: 2089
Joined: 17 Jul 2016, 01:02
Contact:

Re: objects: 0-based array, shift key numbers by an offset

17 Jul 2017, 18:55

Hello.
You might be interested in ComObjArray.
To make an i-indexed based array, we can do arr:={(i-1):""}. But that messes up the enumerator. An attempt to make a i-indexed based array with working enumerator:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


I guess it is sort of a misnomer to call an ahk array i-indexed based, it is i-indexed based w.r.t. to the enumerator perhaps. :think:

Cheers.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Flipeador, gregster, Phasecoder and 42 guests