Display Array element in MsgBox Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
WalkerOfTheDay
Posts: 313
Joined: 24 Mar 2016, 03:01

Display Array element in MsgBox

23 Feb 2018, 05:06

Hi there,

It's been some time i've used ahk, and I'm a little rusty :)

Could you guys help me out ?

How do I display the values in 'EditList' ?

Small snippet of bigger code:

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

Voornaam := "John"
EditList := [Voornaam|Achternaam|Status|Geboortedatum|Geslacht|Adres|Postcode|Woonplaats|Toevoeging|Telefoonnummer|Mobielnummer|Emailadres|DatumInDienst|DatumUitDienst|Dienstverband|Uitzendnummer|Uren|Maandag|Dinsdag|Woensdag|Donderdag|Vrijdag|Huisarts|Huisartsnummer|Contact|Contactnummer|BGG|BGGnummer]
MsgBox, % Voornaam ;this works
;below doesn't work
MsgBox, % EditList
MsgBox, % EditList[1]
MsgBox, % EditList[2]
MsgBox, % EditList[3]
User avatar
Xeo786
Posts: 185
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Display Array element in MsgBox

23 Feb 2018, 05:44

predefined array

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

EditList := ["Voornaam","Achternaam","Status","Geboortedatum","Geslacht","Adres","Postcode","Woonplaats","Toevoeging","Telefoonnummer","Mobielnummer","Emailadres","DatumInDienst","DatumUitDienst","Dienstverband","Uitzendnummer","Uren","Maandag","Dinsdag","Woensdag","Donderdag","Vrijdag","Huisarts","Huisartsnummer","Contact","Contactnummer","BGG","BGGnummer"]

MsgBox, % EditList
MsgBox, % EditList[1]


or create array with loop

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

List := "Voornaam|Achternaam|Status|Geboortedatum|Geslacht|Adres|Postcode|Woonplaats|Toevoeging|Telefoonnummer|Mobielnummer|Emailadres|DatumInDienst|DatumUitDienst|Dienstverband|Uitzendnummer|Uren|Maandag|Dinsdag|Woensdag|Donderdag|Vrijdag|Huisarts|Huisartsnummer|Contact|Contactnummer|BGG|BGGnummer"
array := []
for a, b in StrSplit(List, "`|")
array.Insert(b)

MsgBox, % array[1]
loop
MsgBox, % array[a_index]
"When there is no gravity, there is absolute vacuum" -Game changer theory
WalkerOfTheDay
Posts: 313
Joined: 24 Mar 2016, 03:01

Re: Display Array element in MsgBox

23 Feb 2018, 06:02

Thank you Xeo786, but the values of the array are actually variables taken from a gui.
How would I go about it in this case ?
User avatar
jeeswg
Posts: 4492
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Display Array element in MsgBox

23 Feb 2018, 06:36

This should cover the essentials.

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

WalkerOfTheDay
Posts: 313
Joined: 24 Mar 2016, 03:01

Re: Display Array element in MsgBox

23 Feb 2018, 10:27

Thanks jeeswg,

I think I understand a little better now.

Is it okay if I expand my question a little ?

I have a gui in which I want to prevent semicolons getting saved that are typed in edit boxes.
My code save a .csv and and extra ; - symbol messes it up.

To replicate I have below code:

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



So what I basically want to achieve is to remove all semicolons that are in the EditList variables and update them
to the new value.
User avatar
jeeswg
Posts: 4492
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Display Array element in MsgBox  Topic is solved

23 Feb 2018, 13:24

How about this?

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

WalkerOfTheDay
Posts: 313
Joined: 24 Mar 2016, 03:01

Re: Display Array element in MsgBox

26 Feb 2018, 02:14

jeeswg wrote:How about this?

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



Thanks, but then it throws an error:

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

---------------------------
remove semicolon.ahk
---------------------------
Error: The following variable name contains an illegal character:
"Jo;hn"

Line#
---> 015: %A_LoopField% := StrReplace(%A_LoopField%, ";")



The error makes perfect sense of course, but a user can still type the ; in an editbox..
User avatar
jeeswg
Posts: 4492
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Display Array element in MsgBox

26 Feb 2018, 02:44

I tested again and my script works, you should probably post your full script, you might be doing something different to me.

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

q:: ;test double-deref
var1 := "hello"
var2 := "var1"
MsgBox, % var1 ;hello
MsgBox, % var2 ;var1 ;deref
MsgBox, % %var2% ;hello ;double-deref
%var2% := "new"
MsgBox, % var1 ;new
return
WalkerOfTheDay
Posts: 313
Joined: 24 Mar 2016, 03:01

Re: Display Array element in MsgBox

26 Feb 2018, 03:15

You are right jeeswg, sorry for the confusion. I made a typo in the array.

Thanks again.

Return to “Ask For Help”

Who is online

Users browsing this forum: Elequosoraptor, SexyEarl and 21 guests