Jump to content
Jibberish

GUICtrlCreateEdit with Arrays in Case Statements

Recommended Posts

Jibberish

I am working on a Video Player Test Script. I am reading a text file into a 3d array to be displayed in a GUI.

Array Content:

[x][0]FileName.mp4

[x][1]UsageCount -> Up to a 4 digit number

[x][2]EnableUsageCount (True/False)

In the GUI the user can check the filename box, edit the number of usages and check EnableUsageCount to turn on the UsageCount control using the UsageCount number for the maximum number of plays.

To make this easier to deal with I have removed the EnableUsageCount section, and am just concentrating on getting a method to put the edited (or unchanged) UsageCount in the array. Currently nothing is read into the array, due to my using the wrong method in the Case statement.

Here are code snippets of what I am trying to do:

; Snippets from script
; I read the text file at the bottom and put the .mp4 filenames in $aManifest[x][0] and UsageCount in $aManifest[x][1]
; Then I create a GUI to display the .mp4 filenames with checkboxes and the UsageCount to the right. UsageCount is editable by the user.
; If the filename is checked, I want to read the filename into $aCheckedVideos[x][0] and the updated UsageCount in $aCheckedVideos[x][1]
; The GUICtrlRead($aVideoName[$i]) with Case $GUI_CHECKED & UNCHECKED works for the checkboxes

; This section puts the filenames in the GUI with a checkbox
For $i = 0 to $iMMCount Step 1
        $sMP4Text = $aManifest[$i][0]
        $iMP4Length = StringLen($sMP4Text)
        $aVideoName[$i] = GUICtrlCreateCheckbox($sMP4Text,$iLeft, $iTop)
        $iTop += 30
    Next

; This section reads numbers from the Manifest array, and I want to be able to change the number and have them saved.
; So the Case $GUI_CHECKED & UNCHECKED won't work here, and I can't figure out what I should be doing here.
    For $i = 0 to $iMMCount Step 1
        $sUsageText = $aManifest[$i][1]
        $aUsageCount[$i] = GUICtrlCreateInput($sUsageText,$iLeft, $iTop, 50,18, $GUI_DOCKAUTO)
        GUICtrlSetPos($aUsageCount[$i],200)
        $iTop += 30
    Next

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

            Case $idCloseGUI
                For $i = 0 To $iMMNewCount Step 1
                    Switch GUICtrlRead($aVideoName[$i])
                        Case $GUI_CHECKED
                            $aCheckedVideos[$i][0] = $aManifest[$i][0]  ; If checked, I put the results into a two D array
                        Case $GUI_UNCHECKED                             ; where Video Name is $aCheckedVideos[x][0]
                    EndSwitch
                    Switch GUICtrlRead($aUsageCounter[$i])
                        Case $GUI_CHECKED
                            $aCheckedVideos[$i][1] = $aUsageCount[$i]   ;I want to put the text (numbers) in $aCheckedVideos[x][1]
                        Case $GUI_UNCHECKED                             ;but what is returned is blank, probably due to
                    EndSwitch                                           ; $GUI_CHECKED being the wrong thing.
                Next
                ExitLoop
        EndSwitch
    WEnd

;The txt file I'm reading has the following:
;~ /** Title #1: Big Buck Bunny 1080p **/
;~ "Name": "Big Buck Bunny",
;~ "URI": "..\\MediaFiles\\bbb_1080_60s.mp4",
;~ "UsageCount": 9999,
;~ "URI": "..\\MediaFiles\\bbb_1080_60s_enc1.mp4",
;~ "UsageCount": 45,
;~ "URI": "..\\MediaFiles\\bbb_1080_60s_enc1.mp4",
;~ "UsageCount": 2,
;~ /** Title #2: Tears of Steel 4K **/
;~ "Name": "Tears of Steel 4K",
;~ "URI": "..\\MediaFiles\\tos_4K_60s_HEVC.mp4",
;~ "UsageCount": 9876,
;~ "URI": "..\\MediaFiles\\tos_4K_60s_HEVC_enc2.mp4",
;~ "UsageCount": 0,
;~ "URI": "..\\MediaFiles\\tos_4K_60s_HEVC_enc2.mp4",
;~ "UsageCount": 5,

I am certain that the section

                    Switch GUICtrlRead($aUsageCounter[$i])
                        Case $GUI_CHECKED :lmao:
                            $aCheckedVideos[$i][1] = $aUsageCount[$i]    ;I want to put the text (numbers) in $aCheckedVideos[x][1]
                        Case $GUI_UNCHECKED                                ;but what is returned is blank, probably due to
                    EndSwitch                                            ; $GUI_CHECKED being the wrong thing.


is wrong, and this is what I am looking for help with. Instead of $GUI_CHECKED what should I be looking for?

The worst part of this is I had this working late last night, and then lost my changes and cannot for the life of me remember how I had this working. :(

Help is truly appreciated!

Jibberish

 

Share this post


Link to post
Share on other sites
Jibberish

OK I created a new script that can be run so you can see my problem. I need to display the updated number in the final display.

 

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;
;   This script reads a text file into an array and displays the Name and Number from the text file.
;       The user can check a name and change the number, and the results are displayed in _ArrayDisplay.
;       Only the Checked names are displayed in their original position. This is necessary for future
;           plumbing.
;
;   The problem with this script is the original number is returned, not the changed number. I cannot
;       figure out how to get the updated number to be displayed.
;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


#include-once
#include <MsgBoxConstants.au3>
#include <array.au3>
#include <Date.au3>
#include <WinAPIFiles.au3>
#include <AutoItConstants.au3>
#include <Misc.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

Local $iMax = 6 ;Default number of Videos - 1 for the array counter
Dim $aTextFile[$iMax][2]    ; [start with 5 entries][Name, Number]  Don't get confused! [Row][Column]
Local $i = 0
Local $iLeft = 30
Local $iTop = 30
Local $sName
Local $sNumber
Local $aArray
Local $iMaxCol = 5
Local $iRow = 0
Local $iCol = 0
Local $aNumberCount[$iMaxCol][2]



$aArray1 = ReadFile()
$aNamesNumbers = DisplayNames($aArray1)
_ArrayDisplay($aNamesNumbers)

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;
;   ReadFile() places the contents of the NameNumber.txt file in an array
;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Func ReadFile()
Local $sFileData = @ScriptDir & "\NameNumber.txt"
Local $iStrReturn = 0
Local $aArrayFile
Local $aTextFile[$iMaxCol][2]
Local $aName
Local $sCheckBox1
Const $iL = 10  ; Count from Left for GUI so all buttons line up
Local $sFill
Local $iA = 0, $iN = 0

    ; Put the Names into an Array
    _FileReadToArray($sFileData, $aArrayFile)
    For $iA = 0 To $aArrayFile[0]   ; Step through the array looking for Names
        If StringInStr($aArrayFile[$iA], "Name:") Then
            $aName = StringSplit($aArrayFile[$iA],":")
            $sFill = $aName[2]
            If UBound($aTextFile) <= $iRow Then
                ; Resize the array when $iRow is equal to the element count in the array to prevent subscript error
                ReDim $aTextFile[UBound($aTextFile) + 1][$iMaxCol]
            EndIf
            $aTextFile[$iRow][$iCol] = $sFill
            $iRow += 1
        EndIf
    Next

    $iCol = 1
    $iRow = 0
    $sFill = ""
    For $iA = 1 To $aArrayFile[0]   ; Step through the array looking for Numbers
        If StringInStr($aArrayFile[$iA], "Number:") Then
            $aName = StringSplit($aArrayFile[$iA],":")
            $sFill = $aName[2]
            If UBound($aTextFile) <= $iRow Then
                ; Resize the array when $iRow is equal to the element count in the array to prevent subscript error
                ReDim $aTextFile[UBound($aTextFile) + 1][$iMaxCol]
            EndIf
            $aTextFile[$iRow][$iCol] = $sFill
            $iRow += 1
        EndIf
    Next
    Return $aTextFile

EndFunc

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;
;   Display the Name and Number
;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Func DisplayNames($aArray1)
    Local $aName[$iMax]
    Local $aNumbers[$iMax]
    $iMMCount = UBound($aArray1)
    $iMMCount -=1


    Local $iWidth = 300
    Local $iLength = 300;$iMMCount * 30
    GUISetFont(12)
    $hGUI = GUICreate("Edit / Update Number Test", $iWidth, $iLength, -1, -1)
    GUICtrlCreateLabel("         Name                                          Number",1,5)
    ;$iTop += 30
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;
;   Display Name with a Checkbox. Only Checked Names should be saved.
;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    For $i = 0 to $iMMCount Step 1
        $sNameText = $aArray1[$i][0]
        $iNameLength = StringLen($sNameText)
        $aName[$i] = GUICtrlCreateCheckbox($sNameText,$iLeft, $iTop)
        $iTop += 30
    Next

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;
;   Display the number from the text file below each name. Allow the user to change the number and display the
;       new number.
;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    $iLeft = 60
    GUIStartGroup()
        $iTop = 28
    For $i = 0 to $iMMCount Step 1
        $sNumberText = $aArray1[$i][1]
        $aNumberCount[$i][1] = $sNumberText
        $aNumberCount[$i][0] = GUICtrlCreateInput($sNumberText,$iLeft, $iTop, 50,18, $GUI_DOCKAUTO)
        GUICtrlSetPos($aNumberCount[$i][0],200)
        $iTop += 30
    Next

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;
;   Read the checked names and (possibly updated) number
;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    $iMMCount = UBound($aNumberCount)
    $iMMNewCount = $iMMCount - 1
    Local $aGUICheckbox[$iMMCount]
    Local $aCheckedNameNumber[$iMMCount][2]


    $iLeft = 30
    Local $idCloseGUI = GUICtrlCreateButton("Close",$iLeft, $iTop)

    GUISetState(@SW_SHOW)
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit

            Case $idCloseGUI
                For $i = 0 To $iMMNewCount Step 1
                    Switch GUICtrlRead($aName[$i])
                        Case $GUI_CHECKED
                            $aCheckedNameNumber[$i][0] = $aArray1[$i][0]
                        Case $GUI_UNCHECKED
                    EndSwitch
                    Switch GUICtrlRead($aNumberCount[$i][0])
                        Case $aCheckedNameNumber[$i][1] = GUICtrlRead($aNumberCount[$i][1])


                    EndSwitch
                Next
                ExitLoop
        EndSwitch
    WEnd

    For $i = 0 to $iMMNewCount step 1
        GUICtrlRead($aNumberCount[$i][0])
        If $aCheckedNameNumber[$i][0] <> "" Then
            $aCheckedNameNumber[$i][1] = $aNumberCount[$i][1]
        EndIf
    Next
    GUIDelete($hGUI)

    Return $aCheckedNameNumber
EndFunc

The text file that is read is here:

* This is a dummy file with Somebody.name and Number
* The only purpose of this file is to read the updated Number.
Name:Taggart
Number:916
Name:Mongo
Number:90
Name:Hedley Lamarr
Number:22
Name:Bart
Number:9999
Name:The Waco Kid
Number:2244

Copy the text above into NameNumber.txt and store the file in your script directory.

Run the script, Check a Checkbox and change that associated number and continue. You will see the original number is displayed, not the one you just modified.

How do I get the updated data from the GUI?

Share this post


Link to post
Share on other sites
Melba23

Jibberish,

You are using the wrong element of the $aNumberCount array to get the ControlID of the inputs. Try this:

#include <GUIConstantsEx.au3>
#include <Array.au3>
#include <File.au3>

Local $iMax = 6 ;Default number of Videos - 1 for the array counter
Local $aTextFile[$iMax][2] ; [start with 5 entries][Name, Number]  Don't get confused! [Row][Column]
Local $i = 0
Local $iLeft = 30
Local $iTop = 30
Local $sName
Local $sNumber
Local $aArray
Local $iMaxCol = 5
Local $iRow = 0
Local $iCol = 0
Local $aNumberCount[$iMaxCol][2]

$aArray1 = ReadFile()
$aNamesNumbers = DisplayNames($aArray1)
_ArrayDisplay($aNamesNumbers, "", Default, 8)

Func ReadFile()
    Local $sFileData = @ScriptDir & "\NameNumber.txt"
    Local $iStrReturn = 0
    Local $aArrayFile
    Local $aTextFile[$iMaxCol][2]
    Local $aName
    Local $sCheckBox1
    Const $iL = 10 ; Count from Left for GUI so all buttons line up
    Local $sFill
    Local $iA = 0, $iN = 0

    ; Put the Names into an Array
    _FileReadToArray($sFileData, $aArrayFile)
    For $iA = 0 To $aArrayFile[0] ; Step through the array looking for Names
        If StringInStr($aArrayFile[$iA], "Name:") Then
            $aName = StringSplit($aArrayFile[$iA], ":")
            $sFill = $aName[2]
            If UBound($aTextFile) <= $iRow Then
                ; Resize the array when $iRow is equal to the element count in the array to prevent subscript error
                ReDim $aTextFile[UBound($aTextFile) + 1][$iMaxCol]
            EndIf
            $aTextFile[$iRow][$iCol] = $sFill
            $iRow += 1
        EndIf
    Next

    $iCol = 1
    $iRow = 0
    $sFill = ""
    For $iA = 1 To $aArrayFile[0] ; Step through the array looking for Numbers
        If StringInStr($aArrayFile[$iA], "Number:") Then
            $aName = StringSplit($aArrayFile[$iA], ":")
            $sFill = $aName[2]
            If UBound($aTextFile) <= $iRow Then
                ; Resize the array when $iRow is equal to the element count in the array to prevent subscript error
                ReDim $aTextFile[UBound($aTextFile) + 1][$iMaxCol]
            EndIf
            $aTextFile[$iRow][$iCol] = $sFill
            $iRow += 1
        EndIf
    Next
    Return $aTextFile

EndFunc   ;==>ReadFile

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;
;   Display the Name and Number
;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Func DisplayNames($aArray1)
    Local $aName[$iMax]
    Local $aNumbers[$iMax]
    $iMMCount = UBound($aArray1)
    $iMMCount -= 1


    Local $iWidth = 300
    Local $iLength = 300 ;$iMMCount * 30
    GUISetFont(12)
    $hGUI = GUICreate("Edit / Update Number Test", $iWidth, $iLength, -1, -1)
    GUICtrlCreateLabel("         Name                                          Number", 1, 5)
    ;$iTop += 30
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ;
    ;   Display Name with a Checkbox. Only Checked Names should be saved.
    ;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    For $i = 0 To $iMMCount Step 1
        $sNameText = $aArray1[$i][0]
        $iNameLength = StringLen($sNameText)
        $aName[$i] = GUICtrlCreateCheckbox($sNameText, $iLeft, $iTop)
        $iTop += 30
    Next

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ;
    ;   Display the number from the text file below each name. Allow the user to change the number and display the
    ;       new number.
    ;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    $iLeft = 60
    ;GUIStartGroup()
    $iTop = 28
    For $i = 0 To $iMMCount Step 1
        $sNumberText = $aArray1[$i][1]
        $aNumberCount[$i][1] = $sNumberText
        $aNumberCount[$i][0] = GUICtrlCreateInput($sNumberText, $iLeft, $iTop, 50, 18, $GUI_DOCKAUTO)
        GUICtrlSetPos($aNumberCount[$i][0], 200)
        $iTop += 30
    Next

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ;
    ;   Read the checked names and (possibly updated) number
    ;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    $iMMCount = UBound($aNumberCount)
    $iMMNewCount = $iMMCount - 1
    Local $aGUICheckbox[$iMMCount]
    Local $aCheckedNameNumber[$iMMCount][2]


    $iLeft = 30
    Local $idCloseGUI = GUICtrlCreateButton("Close", $iLeft, $iTop)

    GUISetState(@SW_SHOW)
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit

            Case $idCloseGUI
                For $i = 0 To $iMMNewCount Step 1
                    If GUICtrlRead($aName[$i]) = $GUI_CHECKED Then ; Only read the checked items <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                        $aCheckedNameNumber[$i][0] = $aArray1[$i][0] ; The name... <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                        $aCheckedNameNumber[$i][1] = GUICtrlRead($aNumberCount[$i][0]) ; ...and the current input value <<<<<<<<<<<<<<
                    EndIf
                Next
                ExitLoop
        EndSwitch
    WEnd

    ;For $i = 0 To $iMMNewCount Step 1
    ;   GUICtrlRead($aNumberCount[$i][0])
    ;   If $aCheckedNameNumber[$i][0] <> "" Then
    ;       $aCheckedNameNumber[$i][1] = $aNumberCount[$i][1]
    ;   EndIf
    ;Next
    GUIDelete($hGUI)

    Return $aCheckedNameNumber
EndFunc   ;==>DisplayNames

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 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

 

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

  • Similar Content

    • lattey
      By lattey
      hi,
      i have checkboxes and each checkbox that checked, i put in array. 
      now, im stuck on how to loop the checked array and store in in one variable. what i can do now, is only write the result into a text file. 
      below is the code:
      #include <GUIConstantsEx.au3> ;~ #include <MsgBoxConstants.au3> #include <ButtonConstants.au3> #include <Array.au3> Global $Count = 3 Global $CheckBoxP[$Count] Global $step[$Count] global $array1[1] Global $ExitResult $hGUI = GUICreate("Summary Steps", 500, 400) GUISetFont(12, 400, "Tahoma") GUICtrlCreateLabel( "Please Select the Summary Steps for Script Check", 70, 20) GUISetFont(10, 400, "Tahoma") Global $array_Pstep[3] = ["fix2","fix1","fix3"] global $step[3] = ["2","3","4"] $Spacing = 50 For $i = 0 To UBound($array_Pstep) - 1 $CheckBoxP[$i] = GUICtrlCreateCheckbox($array_Pstep[$i], 80, $Spacing + (20 * $i), 65, 17) Next $submit = GUICtrlCreateButton("Submit",180, 280, 80, 30) $exit = GUICtrlCreateButton("Exit",180, 320, 80, 30) GUISetState() While 1 $Msg = GUIGetMsg() Select case $Msg=$submit For $i = 0 To $Count - 1 If GUICtrlRead($CheckBoxP[$i]) = $GUI_CHECKED Then _ArrayAdd($array1, $step[$i]) EndIf Next Global $logfilerray = @WorkingDir & "\checkedlist.txt" FileDelete ($logfilerray) Global $readlogfile = FileOpen($logfilerray,1) for $a = 1 to UBound($array1) - 1 ;~ $var=$array1[$a] FileWriteLine($readlogfile,$array1[$a]) Next FileClose($readlogfile) Exit case $Msg=$exit $ExitResult = MsgBox(1,"Summary Step", "Continue to Exit ?") if $ExitResult = 1 Then ;ok Exit EndIf Exit EndSelect WEnd  
    • omicron
      By omicron
      How do you perform a nested loop function with a multidimensional array from 2 lists.
      for i in list1
      (open file) extract variable
          while open for i in list 2
          (open file2) extract variable
       
      var1 + var2 = (search term)

      The list sizes will more than likely consist of different lengths.
       
      What is the best approach to accomplishing this method?
             
    • omicron
      By omicron
      Hello!

      I am working on a function that I am just getting lost on. The goal is a multiple nested loop.

      Here are the steps:
      Contents of file1.txt::
      [topic] var1=Name var2=OtherName var3=SomeotheName Contents of file2.txt::
      [subTopic] top=sub1 top2=sub2 top3=sub3 The Shell I am working from::
      #include <file.au3> $file = "c:\yourfile.txt" FileOpen($file, 0) For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) msgbox(0,'','the line ' & $i & ' is ' & $line) Next FileClose($file) Understanding however that the "msgbox" needs to then become a variable. in example the following::
      $file = "c:\yourfile.txt" FileOpen($file, 0) While true( prog.exe is running && "WinName" is open) do For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) ;Open File to log "current location of file 1" FileWriteLine ("filename", $i & ' is ' & $line) var = $line Next $file2 = "c:\yourfile.txt" FileOpen($file, 0) For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) ; OpenFile to log "Current location of file 2" FileWriteLine ("filename", $i & ' is ' & $line) Next FileClose($file2) FileClose($file) The goal in written form is the following ::

      While in "OpenWindow"
          read from file 1 starting at line 1 until end of file.
         file 1 is a list of names to be searched.
         With $line selected, add this element to the element in file 2.
       
      The search of a variables in list 1 and list 2 differ on the amount of posts that day. (This is not a web based platform, it is a game) I need to search 2 names and take a screenshot of the out put. The sizes of the names list depend on the activity of names at the time of search.
      This loop continues until all the names from both lists have been searched. Mostly in the format of::
      File1= item
      File2= Vendor
       
      Item + Vendor  ( Capture screen, scroll) -- Not sure how to detect if I need to scroll)
       
      Thank you for your help and support!
    • Skeletor
      By Skeletor
      Hi Virtual People,
      My array works perfectly fine. However, what is the best practice if the line in the array doesn't have the correct amount of columns and if I can add a placeholder?

       
      For $count = 1 To _FileCountLines($FileRead1) Step 1 $string = FileReadLine($FileRead1, $count) $input = StringSplit($string, ",", 1) $value1 = $input[1] $value2 = $input[2] $value3 = $input[3] _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value2, "A1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value1, "B1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value3, "C1") Next  
    • MrCheese
      By MrCheese
      hi all,
      reviewing the forum, this thread is applicable: 
       
       
      I wanted to know if there is now a better way to do this?
      In essence, I load a tab delimited txt file into an array (works well). I used tab, as some fields in the original csv contains commas.
      However, I needed autoit to manipulate this array, and output it as a csv.
      IF my array contains items with a comma, without double quotes around the field, then how best do I get a csv out of this?
      My current workaround is to filewritefromarray tab delimited, then open it in excel and save as a csv. I will need to check this to see how the address fields behave that contain a comma.
       
      Any thoughts would be appreciated.
       
×