Sign in to follow this  
Followers 0
KatoXY

Incorrect variables

9 posts in this topic

Hi,

I create a GUI according to the following code. I have an array. I do some operations. I want to make the results were entered in the specified label.

I do not know what I'm doing wrong, but I cannot enter data using GUICtrlSetData in _CheckAll() function.

Probably I incorrect declare variables: "$sDesc" & $j, "$sSL" & $j, etc.

How to repair?

This script its only example.

#Include <String.au3>
#Include <Array.au3>
#include <GUIConstantsEx.au3>
#Include <Clipboard.au3>

Global $aArray[4] =["Running", "Swimming", "Cycling", "Skating"]

;Create a GUI
$hGUI = GUICreate("Score cards", 700, 350)

$Labelx = GUICtrlCreateLabel("Name", 10, 15, 75, 25)
$Label0 = GUICtrlCreateLabel("Anna", 10, 45, 75, 25)
$Label1 = GUICtrlCreateLabel("Carol", 10, 75, 75, 25)
$Label2 = GUICtrlCreateLabel("Peter", 10, 105, 75, 25)
$Label3 = GUICtrlCreateLabel("John", 10, 135, 75, 25)

$sDescx = GUICtrlCreateLabel("Sport", 80, 15, 150, 25)
$sDesc0 = GUICtrlCreateLabel("-", 80, 45, 150, 25)
$sDesc1 = GUICtrlCreateLabel("-", 80, 75, 150, 25)
$sDesc2 = GUICtrlCreateLabel("-", 80, 105, 150, 25)
$sDesc3 = GUICtrlCreateLabel("-", 80, 135, 150, 25)

$sSLx = GUICtrlCreateLabel("Start List", 235, 15, 90, 25)
$sSL0 = GUICtrlCreateLabel("-", 235, 45, 90, 25)
$sSL1 = GUICtrlCreateLabel("-", 235, 75, 90, 25)
$sSL2 = GUICtrlCreateLabel("-", 235, 105, 90, 25)
$sSL3 = GUICtrlCreateLabel("-", 235, 135, 90, 25)

$sLocx = GUICtrlCreateLabel("Place", 330, 15, 130, 25)
$sLoc0 = GUICtrlCreateLabel("-", 330, 45, 130, 25)
$sLoc1 = GUICtrlCreateLabel("-", 330, 75, 130, 25)
$sLoc2 = GUICtrlCreateLabel("-", 330, 105, 130, 25)
$sLoc3 = GUICtrlCreateLabel("-", 330, 135, 130, 25)

$sCountx = GUICtrlCreateLabel("Counter", 500, 15, 60, 20)
$sCount0 = GUICtrlCreateInput("total", 500, 45, 60, 20, 0x0100)
$sCount1 = GUICtrlCreateInput("total", 500, 75, 60, 20, 0x0100)
$sCount2 = GUICtrlCreateInput("total", 500, 105, 60, 20, 0x0100)
$sCount3 = GUICtrlCreateInput("total", 500, 135, 60, 20, 0x0100)

$sCopyx = GUICtrlCreateLabel("Clipboard", 565, 15, 60, 20)
$sCopy0 = GUICtrlCreateButton("Copy", 565, 45, 60, 20, 0x00020000)
$sCopy1 = GUICtrlCreateButton("Copy", 565, 75, 60, 20, 0x00020000)
$sCopy2 = GUICtrlCreateButton("Copy", 565, 105, 60, 20, 0x00020000)
$sCopy3 = GUICtrlCreateButton("Copy", 565, 135, 60, 20, 0x00020000)

$sysAll = GUICtrlCreateButton("Check all", 10, 315, 120, 20, 0x00020000)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $sCopy0
            $sCount0 = GUICtrlRead($sCount0, 1) ; return the text of the menu item
            _ClipBoard_SetData($sCount0)
        Case $sCopy1
            $sCount1 = GUICtrlRead($sCount1, 1) ; return the text of the menu item
            _ClipBoard_SetData($sCount1)
        Case $sCopy1
            $sCount2 = GUICtrlRead($sCount2, 1) ; return the text of the menu item
            _ClipBoard_SetData($sCount2)
        Case $sCopy2
            $sCount3 = GUICtrlRead($sCount3, 1) ; return the text of the menu item
            _ClipBoard_SetData($sCount3)
        Case $sysAll
            _CheckAll()
EndSwitch
WEnd

Func _CheckAll()
For $j = 0 to 4

GUICtrlSetData("$sDesc" & $j, $aArray[$j])  ;Sport label

$sLis = Random(1, 4, 1) ;Start list
GUICtrlSetData("$sSL" & $j , $sLis)

$sPla = Random(1, 4, 1)     ; Final Position
GUICtrlSetData("$sLoc" & $j, $sPla)

$sCou = Random(30, 550)     ;Counter
GUICtrlSetData("$sCount" & $j, $sCou)
Sleep(3000)
Next

EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

GUICtrlSetData("$sLoc" & $j, $sPla)

Have a look at Execute in the Help File. But honestly I would add the ControlID's to an Array too and then loop from 0 to 3 not 0 to 4!! Any problems let me know :huh2: Or perhaps I mis-understood the code above.

Your Script deconstructed to the minimal parts of your problem:

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ; Use to Debug your Script.
#include <GUIConstantsEx.au3>

Global $aArray[4] = ["Running", "Swimming", "Cycling", "Skating"], $aControlID[4], $hGUI, $iCheckAll

$hGUI = GUICreate("Score cards", 700, 350)

GUICtrlCreateLabel("Name", 10, 15, 75, 25)
GUICtrlCreateLabel("Anna", 10, 45, 75, 25)
GUICtrlCreateLabel("Carol", 10, 75, 75, 25)
GUICtrlCreateLabel("Peter", 10, 105, 75, 25)
GUICtrlCreateLabel("John", 10, 135, 75, 25)

$aControlID[0] = GUICtrlCreateLabel("Sport", 80, 15, 150, 25)
GUICtrlCreateLabel("-", 80, 45, 150, 25)
GUICtrlCreateLabel("-", 80, 75, 150, 25)
GUICtrlCreateLabel("-", 80, 105, 150, 25)
GUICtrlCreateLabel("-", 80, 135, 150, 25)

$aControlID[1] = GUICtrlCreateLabel("Start List", 235, 15, 90, 25)
GUICtrlCreateLabel("-", 235, 45, 90, 25)
GUICtrlCreateLabel("-", 235, 75, 90, 25)
GUICtrlCreateLabel("-", 235, 105, 90, 25)
GUICtrlCreateLabel("-", 235, 135, 90, 25)

$aControlID[2] = GUICtrlCreateLabel("Place", 330, 15, 130, 25)
GUICtrlCreateLabel("-", 330, 45, 130, 25)
GUICtrlCreateLabel("-", 330, 75, 130, 25)
GUICtrlCreateLabel("-", 330, 105, 130, 25)
GUICtrlCreateLabel("-", 330, 135, 130, 25)

$aControlID[3] = GUICtrlCreateLabel("Counter", 500, 15, 60, 20)
GUICtrlCreateInput("total", 500, 45, 60, 20, 0x0100)
GUICtrlCreateInput("total", 500, 75, 60, 20, 0x0100)
GUICtrlCreateInput("total", 500, 105, 60, 20, 0x0100)
GUICtrlCreateInput("total", 500, 135, 60, 20, 0x0100)

GUICtrlCreateLabel("Clipboard", 565, 15, 60, 20)
GUICtrlCreateButton("Copy", 565, 45, 60, 20, 0x00020000)
GUICtrlCreateButton("Copy", 565, 75, 60, 20, 0x00020000)
GUICtrlCreateButton("Copy", 565, 105, 60, 20, 0x00020000)
GUICtrlCreateButton("Copy", 565, 135, 60, 20, 0x00020000)

$iCheckAll = GUICtrlCreateButton("Check all", 10, 315, 120, 20, 0x00020000)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

        Case $iCheckAll
            _CheckAll()
    EndSwitch
WEnd

Func _CheckAll()
    For $A = 0 To 3 ; Not to 4!
        GUICtrlSetData($aControlID[$A], Random(1, 4, 1))
    Next
EndFunc   ;==>_CheckAll
Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Try this way:

#Include <String.au3>
#Include <Array.au3>
#include <GUIConstantsEx.au3>
#Include <Clipboard.au3>

Global $aArray[4] =["Running", "Swimming", "Cycling", "Skating"]

;Create a GUI
$hGUI = GUICreate("Score cards", 700, 350)

$Labelx = GUICtrlCreateLabel("Name", 10, 15, 75, 25)
$Label0 = GUICtrlCreateLabel("Anna", 10, 45, 75, 25)
$Label1 = GUICtrlCreateLabel("Carol", 10, 75, 75, 25)
$Label2 = GUICtrlCreateLabel("Peter", 10, 105, 75, 25)
$Label3 = GUICtrlCreateLabel("John", 10, 135, 75, 25)

$sDescx = GUICtrlCreateLabel("Sport", 80, 15, 150, 25)
$sDesc0 = GUICtrlCreateLabel("-", 80, 45, 150, 25)
$sDesc1 = GUICtrlCreateLabel("-", 80, 75, 150, 25)
$sDesc2 = GUICtrlCreateLabel("-", 80, 105, 150, 25)
$sDesc3 = GUICtrlCreateLabel("-", 80, 135, 150, 25)

$sSLx = GUICtrlCreateLabel("Start List", 235, 15, 90, 25)
$sSL0 = GUICtrlCreateLabel("-", 235, 45, 90, 25)
$sSL1 = GUICtrlCreateLabel("-", 235, 75, 90, 25)
$sSL2 = GUICtrlCreateLabel("-", 235, 105, 90, 25)
$sSL3 = GUICtrlCreateLabel("-", 235, 135, 90, 25)

$sLocx = GUICtrlCreateLabel("Place", 330, 15, 130, 25)
$sLoc0 = GUICtrlCreateLabel("-", 330, 45, 130, 25)
$sLoc1 = GUICtrlCreateLabel("-", 330, 75, 130, 25)
$sLoc2 = GUICtrlCreateLabel("-", 330, 105, 130, 25)
$sLoc3 = GUICtrlCreateLabel("-", 330, 135, 130, 25)

$sCountx = GUICtrlCreateLabel("Counter", 500, 15, 60, 20)
$sCount0 = GUICtrlCreateInput("total", 500, 45, 60, 20, 0x0100)
$sCount1 = GUICtrlCreateInput("total", 500, 75, 60, 20, 0x0100)
$sCount2 = GUICtrlCreateInput("total", 500, 105, 60, 20, 0x0100)
$sCount3 = GUICtrlCreateInput("total", 500, 135, 60, 20, 0x0100)

$sCopyx = GUICtrlCreateLabel("Clipboard", 565, 15, 60, 20)
$sCopy0 = GUICtrlCreateButton("Copy", 565, 45, 60, 20, 0x00020000)
$sCopy1 = GUICtrlCreateButton("Copy", 565, 75, 60, 20, 0x00020000)
$sCopy2 = GUICtrlCreateButton("Copy", 565, 105, 60, 20, 0x00020000)
$sCopy3 = GUICtrlCreateButton("Copy", 565, 135, 60, 20, 0x00020000)

$sysAll = GUICtrlCreateButton("Check all", 10, 315, 120, 20, 0x00020000)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $sCopy0
            $sCount0 = GUICtrlRead($sCount0, 1) ; return the text of the menu item
            _ClipBoard_SetData($sCount0)
        Case $sCopy1
            $sCount1 = GUICtrlRead($sCount1, 1) ; return the text of the menu item
            _ClipBoard_SetData($sCount1)
        Case $sCopy1
            $sCount2 = GUICtrlRead($sCount2, 1) ; return the text of the menu item
            _ClipBoard_SetData($sCount2)
        Case $sCopy2
            $sCount3 = GUICtrlRead($sCount3, 1) ; return the text of the menu item
            _ClipBoard_SetData($sCount3)
        Case $sysAll
            _CheckAll()
EndSwitch
WEnd

Func _CheckAll()
    For $j = 0 to 3

        GUICtrlSetData(Execute("$sDesc" & $j),  $aArray[$j])  ;Sport label

        $sLis = Random(0, 3, 1) ;Start list
        GUICtrlSetData(Execute("$sSL" & $j), $sLis)

        $sPla = Random(0, 3, 1)     ; Final Position
        GUICtrlSetData(Execute("$sLoc" & $j), $sPla)

        $sCou = Random(30, 550)     ;Counter
        GUICtrlSetData(Execute("$sCount" & $j), $sCou)
;~      Sleep(3000)
    Next

EndFunc

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Thanks @guinness for your answer.

Maybe I expressed wrong in my description.

I finally want to get sth like this:

@UEZ it is probably correct solution

post-60731-0-63195800-1308129663_thumb.j

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

In your screenshot the counter numbers are rounded. You can change the line 83 to

$sCou = Round(Random(30, 550), 1)

to get the same results as shown in your screenshot.

Btw, start list and final postitions are not unique. If this is not intended you can use an array with 1-4 as values and shuffle it. You will have random start and final positions which are unique.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thanks @guinness for your answer.

Maybe I expressed wrong in my description.

OK, but in the future I would recommend the Array approach rather than Execute. Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

I agree with guinness. You should use an array instead of doing the execute stuff as shown here.

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Hello again,

I replaced my script for arrays. I think that it look like you wrote me earlier.

GUI, labels, inputs and buttons are creating automatically and depend on size of array.

I have new problem :huh2: : I'm not sure how to assign _ClipBoard_SetData to buttons?

Generally I can use solution from earlier example:

Case $sCopy0
            $sCount0 = GUICtrlRead($sCount0, 1) ; return the text of the menu item
            _ClipBoard_SetData($sCount0)

Because I know size of array and I know how many buttons I have, but I want create script where I only resize $aArray[$x] (maybe I get data from different source) and all buttons will work correctly without my interference to number of Case $sCopyX in Switch function.

#Include <String.au3>
#Include <Array.au3>
#include <GUIConstantsEx.au3>
#Include <Clipboard.au3>

Global $aArray[4] =["Anna", "Carol", "Peter", "John"]
Global $newArray[6][UBound($aArray)]
Global $sCopy[UBound($newArray)]
MsgBox(4,"Start", "Run program?")

;Creating scores
    For $j = 0 to (UBound($aArray)-1)

        $newArray[0][$j] = Random(1, 9, 1)
        $newArray[1][$j] = Random(1, 9, 1)
        $newArray[2][$j] = Random(1, 9, 1)
        $newArray[3][$j] = Random(1, 9, 1)
        $newArray[4][$j] = Random(1, 9, 1)
        $newArray[5][$j] = Random(1, 90)
    Next


;Returns the size of array dimensions
$rows = UBound($newArray)
$cols = UBound($newArray, 2)
$dims = UBound($newArray, 0)
MsgBox(0, "The " & $dims & "-dimensional array has", _
    $rows & " rows, " & $cols & " columns")
_ArrayDisplay($newArray,"tab")

;Creating GUI with scores
$hGUI = GUICreate("Score cards", 750, (($cols+3)*30))

    For $k=0 to $cols-1
        GUICtrlCreateLabel($aArray[$k], 10, (15+($k*30)), 75, 25)
        GUICtrlCreateLabel($newArray[0][$k], 80, (15+($k*30)), 150, 25)
        GUICtrlCreateLabel($newArray[1][$k], 235, (15+($k*30)), 90, 25)
        GUICtrlCreateLabel($newArray[2][$k], 330, (15+($k*30)), 130, 25)
        GUICtrlCreateLabel($newArray[3][$k], 465, (15+($k*30)), 30, 20, 0x0100)
        GUICtrlCreateLabel($newArray[4][$k], 500, (15+($k*30)), 75, 25)
        GUICtrlCreateInput($newArray[5][$k], 580, (15+($k*30)), 60, 20, 0x0100)
        $sCopy[$k] = GUICtrlCreateButton("Copy", 645, (15+($k*30)), 60, 20, 0x00020000)
    GUISetState(@SW_SHOW)
    Sleep(400)
    Next

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Something like this?? >>

#include <String.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <Clipboard.au3>

Global $aArray[4] = ["Anna", "Carol", "Peter", "John"]
Global $aNewArray[6][UBound($aArray)]
Global $aCopyButton[UBound($aNewArray)]
Global $aCopyInput[UBound($aNewArray)]
Global $iMsg
;~ MsgBox(4, "Start", "Run program?")

;Creating scores
For $j = 0 to (UBound($aArray) - 1)

    $aNewArray[0][$j] = Random(1, 9, 1)
    $aNewArray[1][$j] = Random(1, 9, 1)
    $aNewArray[2][$j] = Random(1, 9, 1)
    $aNewArray[3][$j] = Random(1, 9, 1)
    $aNewArray[4][$j] = Random(1, 9, 1)
    $aNewArray[5][$j] = Random(1, 90)
Next


;Returns the size of array dimensions
$iRows = UBound($aNewArray)
$iCols = UBound($aNewArray, 2)
$iDims = UBound($aNewArray, 0)

;~ MsgBox(0, "The " & $iDims & "-dimensional array has", _
;~      $iRows & " rows, " & $iCols & " columns")
;~ _ArrayDisplay($aCopyButton, "tab")

;Creating GUI with scores
$hGUI = GUICreate("Score cards", 750, (($iCols + 3) * 30))
For $i = 0 To $iCols - 1
    GUICtrlCreateLabel($aArray[$i], 10, (15 + ($i * 30)), 75, 25)
    GUICtrlCreateLabel($aNewArray[0][$i], 80, (15 + ($i * 30)), 150, 25)
    GUICtrlCreateLabel($aNewArray[1][$i], 235, (15 + ($i * 30)), 90, 25)
    GUICtrlCreateLabel($aNewArray[2][$i], 330, (15 + ($i * 30)), 130, 25)
    GUICtrlCreateLabel($aNewArray[3][$i], 465, (15 + ($i * 30)), 30, 20, 0x0100)
    GUICtrlCreateLabel($aNewArray[4][$i], 500, (15 + ($i * 30)), 75, 25)
    $aCopyInput[$i] = GUICtrlCreateInput($aNewArray[5][$i], 580, (15 + ($i * 30)), 60, 20, 0x0100)
    $aCopyButton[$i] = GUICtrlCreateButton("Copy", 645, (15 + ($i * 30)), 60, 20, 0x00020000)
Next
GUISetState(@SW_SHOW)

While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case Else
            If $iMsg > 0 Then ; Check the Msg is higher than 0
                For $i = 0 To $iRows - 1 ; Loop the ButtonID's and if there is a Match.
                    If $iMsg = $aCopyButton[$i] Then
                        ConsoleWrite($i + 1 & " Button Pushed!" & @CRLF)
                        _ClipBoard_SetData(GUICtrlRead($aCopyInput[$i])) ; Get the Data from the Input which is in an Array too.
                        ExitLoop
                    EndIf
                Next
            EndIf
    EndSwitch
WEnd

I didn't want to deviate to much away from your code because of course I want you to understand. But I would highly recommend reading my post about _ReDim() in my signature to see the best way to work with effectively with Arrays. I tend not to use Ubound(), but instead opt for using Index 0 as the row count.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

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