Jump to content

Help with calling variables with a FOR...


Recommended Posts

Hello first of all, and thanks in advance. The issue is the following.

For a work that I have I needed to assign an extremely large amount of GUICtrlCreatePic objects (About 80) and I need to call an specific amount of them to be used; but I didn´t fount a method to to something like the following:

Global $imGr1, $imGr2, $imGr3, $imGr4, $imGr5, $imGr6, $imGr7, $imGr8, $imGr9, $imGr10 = GUICtrlCreatePic(0, 0, 0, 0, 0)
Global $imGr11, $imGr12, $imGr13, $imGr14, $imGr15, $imGr16, $imGr17, $imGr18, $imGr19, $imGr20 = GUICtrlCreatePic(0, 0, 0, 0, 0)
Global $imGr21, $imGr22, $imGr23, $imGr24, $imGr25, $imGr26, $imGr27, $imGr28, $imGr29, $imGr30 = GUICtrlCreatePic(0, 0, 0, 0, 0)
Global $imGr31, $imGr32, $imGr33, $imGr34, $imGr35, $imGr36, $imGr37, $imGr38, $imGr39, $imGr40 = GUICtrlCreatePic(0, 0, 0, 0, 0)
Global $imGr41, $imGr42, $imGr43, $imGr44, $imGr45, $imGr46, $imGr47, $imGr48, $imGr49, $imGr50 = GUICtrlCreatePic(0, 0, 0, 0, 0)
Global $imGr51, $imGr52, $imGr53, $imGr54, $imGr55, $imGr56, $imGr57, $imGr58, $imGr59, $imGr60 = GUICtrlCreatePic(0, 0, 0, 0, 0)
Global $imGr61, $imGr62, $imGr63, $imGr64, $imGr65, $imGr66, $imGr67, $imGr68, $imGr69, $imGr70 = GUICtrlCreatePic(0, 0, 0, 0, 0)
Global $imGr71, $imGr72, $imGr73, $imGr74, $imGr75, $imGr76, $imGr77, $imGr78, $imGr79, $imGr80 = GUICtrlCreatePic(0, 0, 0, 0, 0)
Global $imGr81, $imGr82, $imGr83, $imGr84, $imGr85, $imGr86, $imGr87, $imGr88, $imGr89, $imGr80 = GUICtrlCreatePic(0, 0, 0, 0, 0)

; altoGrilla and anchoGrilla are the amount of objects in the 2 axis, alto is for objects in vertical and ancho for horizontal
; The margins and amount of objects had been calculated using a function

Func CrearGrilla()
    Local $posWidth = $marginWidth + $boxSize[0]
    Local $posHeigh = $marginHeigh + $boxSize[1]
    For $colocar = 0 To ($altoGrilla * $anchoGrilla) Step 1
;~      GUICtrlSetPos([IN HERE THERE SHOULD BE THE NAME OF 1 OF THE 80 IMAGE BOXES], $posAncho, $posAlto, 96, 96)
    Next
EndFunc   ;==>CrearGrilla

Basically I require a way to call specifically one of the already created objects, like " $imGr & [$colocar+1] " or something that allows me to modify the name of the variable that is going to edited. There´s a way to do so?

Link to comment
Share on other sites

You have a couple of options.  You can utilize an array to house the Pic controls instead of having a variable for each control.
 

;Untested
Global $arrImGr[90]

For $iIdx = 0 to UBound($arrImGr)-1
    $arrImGr[$iIdx] = GUICtrlCreatePic(0,0,0)
Next

 

Else, you should be able use the Execute() function to reference a control via a literal string  Look up Execute() in the Help FIle
 

Link to comment
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
 Share

  • Recently Browsing   0 members

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