Jump to content
Martin_Bauer

Arrays (with changing Numbers) into different input boxes.

Recommended Posts

Hi there my name is Martin, i started autoit not that long ago.

I have a small problem in which i would need some ideas from you guys.

 

Goal with my script should be to input Array  to different input boxes

like : Array 1 0 = Input27

Array 11 = input28

Array 20 = Input30... and so on.

 

Problem is.

I just can not wrap my had around on how to get it into the input boxes.

doing it by hand like :

GUICtrlSetData($Input27, $aArray[1][0])
  GUICtrlSetData($Input28, $aArray[1][1])

  GUICtrlSetData($Input29, "Key: " & $aArray[2][0])
  GUICtrlSetData($Input30, $aArray[2][1])

    GUICtrlSetData($Input31, "Key: " & $aArray[3][0])
  GUICtrlSetData($Input32, $aArray[3][1])

    GUICtrlSetData($Input33, "Key: " & $aArray[4][0])
  GUICtrlSetData($Input34, $aArray[4][1])

    GUICtrlSetData($Input35, "Key: " & $aArray[$i][0])
  GUICtrlSetData($Input36, $aArray[$i][1])

    GUICtrlSetData($Input37, "Key: " & $aArray[$i][0])
  GUICtrlSetData($Input38, $aArray[$i][1])

works of course up to the point until we run out of Arrays ... but still asking for the next.

I was trying things like

for $i = 1 To $aArray[0][0] 
 for $j = $Input27 To $input60  

   GUICtrlSetData($j, "Key: " & $aArray[$i][0])
  GUICtrlSetData($j, $aArray[$i][1])
  next
  next

but then of course it draws the value to every input box

 

Also which we should take into consideration, i am deleting the INI section once Label count reaches 0

;Checks if there are less or more then 1 labels saved in the INI file. if less then one, key and Value will be deleted
  Local $aArray = IniReadSection("INI_Files\Live_Label\Labels.ini", "Labels")

For $i = 1 To $aArray[0][0]
if $aArray[$i][1] < 1 then
IniDelete ( "INI_Files\Live_Label\Labels.ini", "Labels" ,$aArray[$i][1] )
IniDelete ( "INI_Files\Live_Label\Labels.ini", "Labels" ,$aArray[$i][0] )

 

can someone push my head into the right direction ?

maybe my approach is wrong from the very beginning . ( which would be good, because i just started with it )

anyway. thank you for your help.

Share this post


Link to post
Share on other sites

Hey Martin,

Not exactly sure of what you want but, if you are trying to iterate all elements of array then this should work. Adjust numbers to your need.

if $array[0][0] holds only counts, start $i from 1.

$idArray ; an array holding id's for inputboxes
$iInputIndex = 20 ; starting index of inputboxes that you want to modify

for $i = 1 to ubound($array)-1
    GUICtrlSetData($idArray[$iInputNumber], "Key: " & $aArray[$i][0])
    GUICtrlSetData($idArray[$iInputNumber + 1], $aArray[$i][1])
    
    ; Maybe delete the ini here?
    $iInputNumber += 2 ; increment to next set of inputboxes
next

Edit: Fixed some stuff, leaving this as well, for array of more than 2 columns

$idArray ; an array holding id's for inputboxes
$iInputIndex = 20 ; starting index of inputboxes that you want to modify

for $i = 0 to ubound($array)-1
    GUICtrlSetData($idArray[$iInputNumber], "Key: " & $aArray[$i][0])
    $iInputNumber + = 1
    for $j = 1 to ubound($array,2)-1
        ; Do stuff with $array[$i][$j]
        GUICtrlSetData($idArray[$iInputNumber], $aArray[$i][$j])
        
        $iInputNumber += 1 ; increment to next inputbox
    next
next

 

Edited by GokAy
Original post was not very accurate

Share this post


Link to post
Share on other sites

Thank you Sir.

You gave me the right push.

So far this does the trick for me

Local $aArray = IniReadSection("INI_Files\Live_Label\Labels.ini", "Labels")
$iInputIndex = $Input27 ; starting index of inputboxes that you want to modify

for $i = 1 to $aArray[0][0]
    GUICtrlSetData($iInputIndex, $aArray[$i][0])
    GUICtrlSetData($iInputIndex + 1, $aArray[$i][1])

    ; Maybe delete the ini here?
    $iInputIndex += 2 ; increment to next set of inputboxes
next

thank you once again, i can finally continue, and get stuck with the next problem, which hopefully is far away.

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...