Jump to content

Recommended Posts

Posted (edited)

I have a bit of a problem that ive been trying to sort out, and cant seem to find the information.

I have a situation like this:

$Array1[3] = [ "List1", "List2", "List3" ]
$List1 = _FileListToArray("xxx")$List2 = _FileListToArray("yyy")
$List3 = _FileListToArray("zzz")

Rather than pointing specifically to the List I want to access, I want to use the string from Array1 to access the List Arrays...

How can I access any elements in $List1, $List2, or $List3 with only the STRING "List1", "List2" or "List3" from the Array1 variable.

 

Edited by jedd999
  • Moderators
Posted

jedd999,

You can do it like this: ;)

Local $Array1[3] = [ "List1", "List2", "List3" ]

Local $List1[3] = [1, 2, 3]
Local $List2[3] = [4, 5, 6]
Local $List3[3] = [7, 8, 9]

$aArray = Eval($Array1[0])
MsgBox(4096, $Array1[0], $aArray[0] & " - " & $aArray[1] & " - " & $aArray[2])

$aArray = Eval($Array1[1])
MsgBox(4096, $Array1[1], $aArray[0] & " - " & $aArray[1] & " - " & $aArray[2])

$aArray = Eval($Array1[2])
MsgBox(4096, $Array1[2], $aArray[0] & " - " & $aArray[1] & " - " & $aArray[2])
But I think it is very ugly code. :(

What exactly are you trying to do? We might be able to suggest something a little more elegant. :)

 

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

The Eval function is exactly what I was looking for.

Basically, I have 4 folders with a bunch of files in them.
I wanted to create 4 different groups in a GUI with the list of all the files organized by group.

Eval works great!

Thanks

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...