Sign in to follow this  
Followers 0
Bert

Array inside of a array?

10 posts in this topic

Here is the setup:

  • I have a ini file that has about 12 entries under one section. That number can change over time. I use inireadsection to access it.
  • in each key, I have a name listed twice. Once for one ticket system I use, and the other for a email for that same user. Example would be like this:

    [ini section]

    1 = Doe, John a.|Doe.John

    2 = Smith, George W.|Smith.Willam

What I'm looking to do is have a GUI that shows the first part of each key in a list. You select the name, and click assign. . The first part of the key is used to populate the program field of a different program we use to work tickets. The second part of the key is then used to email the user. The names are different depending on the system.

I'm not sure on just how to get things to match up after a selection is made so I get what I need. Some direction would be helpful. The code I have so far is this:

#include <array.au3>
#include <GuiConstants.au3>
GuiCreate("USD ticket Assigner", 392, 158,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$List_1 = GUICtrlCreateCombo("", 60, 40, 270, 39)
$Button_2 = GuiCtrlCreateButton("Assign", 60, 90, 90, 30)
$Button_3 = GuiCtrlCreateButton("Cancel", 200, 90, 130, 30)
$ini_4 = IniReadSection(@ScriptDir&"/list.ini", "1")
$array_1 = _ArrayCreate("")
For $i = 1 To $ini_4[0][0]
    $strsplit = StringSplit($ini_4[$i][1],"|")
    _ArrayAdd($array_1, $strsplit[1])
next
$string_1 = _ArrayToString($array_1, "|")
GUICtrlSetData($List_1, $string_1)
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_2
        $read = GUICtrlRead($List_1)
        MsgBox(0, "the user selected is "&$read, "The email needs to be sent to the same person but the other part of the ini key. How do I get that so it shows up here??")
    Case Else
        ;;;
    EndSelect
WEnd
Exit

Share this post


Link to post
Share on other sites



:(

Arrays are like kryptonite to me, so I need it in simple terms..can I get a example with my code so I can see how it is done?

Oh, you just want me to fix it for you.. :P Why didn't you say so in your first post..

Ok, just a second. :shocked:

Share this post


Link to post
Share on other sites

I came up with this...and it works. but...is there a better way?

#include <array.au3>
#include <GuiConstants.au3>
GuiCreate("USD ticket Assigner", 392, 158,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$List_1 = GUICtrlCreateCombo("", 60, 40, 270, 39)
$Button_2 = GuiCtrlCreateButton("Assign", 60, 90, 90, 30)
$Button_3 = GuiCtrlCreateButton("Cancel", 200, 90, 130, 30)
$ini_4 = IniReadSection(@ScriptDir&"/list.ini", "1")
$array_1 = _ArrayCreate("")
$array_2 = _ArrayCreate("")
For $i = 1 To $ini_4[0][0]
    $strsplit = StringSplit($ini_4[$i][1],"|")
    _ArrayAdd($array_1, $strsplit[1])
    _ArrayAdd($array_2, $strsplit[2])
next
$string_1 = _ArrayToString($array_1, "|")
$index = _ArrayMaxIndex($string_1)
GUICtrlSetData($List_1, $string_1)
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE or $msg = $Button_3
        ExitLoop
    Case $msg = $Button_2
        $read = GUICtrlRead($List_1)
        $search_1 = _ArraySearch($array_1, $read)
        $email = $array_2[$search_1]
        MsgBox(0, "the user selected is "&$read, "The email was sent to "&$email)
    Case Else
        ;;;
    EndSelect
WEnd
Exit

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Here's my solution...

#include <array.au3>
#include <GuiConstants.au3>
GuiCreate("USD ticket Assigner", 392, 158,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$List_1 = GUICtrlCreateCombo("", 60, 40, 270, 39)
$Button_2 = GuiCtrlCreateButton("Assign", 60, 90, 90, 30)
$Button_3 = GuiCtrlCreateButton("Cancel", 200, 90, 130, 30)
$ini_4 = IniReadSection(@ScriptDir&"/list.ini", "1")

Dim $Array[$ini_4[0][0]][2] ; initialize the array with the proper amount of places..

For $i = 1 To $ini_4[0][0] ; this loop puts all the correct values in the right places
    $strsplit = StringSplit($ini_4[$i][1],"|")
    $Array[$i-1][0] = $strsplit[1]
    $Array[$i-1][1] = $strsplit[2]
next

For $i = 1 To $ini_4[0][0] ; this loop puts them into a GUI.. they could be fit together, but I didn't for clarity.
    GUICtrlSetData($List_1, $Array[$i-1][0])
    GUICtrlSetData($List_1, $Array[$i-1][1]) ; comment either of these
Next

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_2
        $read = GUICtrlRead($List_1)
        MsgBox(0, "the user selected is "&$read, "The email needs to be sent to the same person but the other part of the ini key. How do I get that so it shows up here??")
    Case Else
        ;;;
    EndSelect
WEnd
Exit

Edit: I absolutely hate the _Array functions, for purposes other then testing..

Edit 2: Commented some stuff..

Edited by Manadar

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Ummm, it adds both parts of the stringsplit to the combo. I only need the left part of the split there. Run mine, and you will see what I mean.

I am sure that with 30 seconds, you've got it working exactly as you want it to..

Edit: Never mind, I'll fix you up completely..

Edit 2:

#include <array.au3>
#include <GuiConstants.au3>
GuiCreate("USD ticket Assigner", 392, 158,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$List_1 = GUICtrlCreateCombo("", 60, 40, 270, 39)
$Button_2 = GuiCtrlCreateButton("Assign", 60, 90, 90, 30)
$Button_3 = GuiCtrlCreateButton("Cancel", 200, 90, 130, 30)
$ini_4 = IniReadSection(@ScriptDir&"/list.ini", "1")

Dim $Array[$ini_4[0][0]][2]

For $i = 1 To $ini_4[0][0]
    $strsplit = StringSplit($ini_4[$i][1],"|")
    $Array[$i-1][0] = $strsplit[1]
    $Array[$i-1][1] = $strsplit[2]
next

For $i = 1 To $ini_4[0][0]
    GUICtrlSetData($List_1, $Array[$i-1][0])
    ;GUICtrlSetData($List_1, $Array[$i-1][1])
Next

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_2
        $read = GUICtrlRead($List_1)
        For $x = 1 to $ini_4[0][0]
            If $read = $Array[$x-1][0] Then
                MsgBox(0, "the user selected is "&$read, "The email needs to be sent to the same person but the other part of the ini key. How do I get that so it shows up: " & $Array[$x-1][1])
                ExitLoop
            EndIf
        Next
    Case Else
        ;;;
    EndSelect
WEnd
Exit
Edited by Manadar

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0