Jump to content

Recommended Posts

Posted

Func BUTTON2CLICK()
 GUICtrlSetData($ListView1_0, "")
 GUICtrlSetData($ListView1_0, "|" & "")
 GUICtrlSetData($ListView1_0, "|" & "|" & "")
 GUICtrlSetData($ListView1_1, "")
 GUICtrlSetData($ListView1_1, "|" & "")
 GUICtrlSetData($ListView1_1, "|" & "|" & "")
 GUICtrlSetData($ListView1_2, "")
 GUICtrlSetData($ListView1_2, "|" & "")
 GUICtrlSetData($ListView1_2, "|" & "|" & "")
 GUICtrlSetData($ListView1_3, "")
 GUICtrlSetData($ListView1_3, "|" & "")
 GUICtrlSetData($ListView1_3, "|" & "|" & "")
 GUICtrlSetData($ListView1_4, "")
 GUICtrlSetData($ListView1_4, "|" & "")
 GUICtrlSetData($ListView1_4, "|" & "|" & "")
 GUICtrlSetData($ListView1_5, "")
 GUICtrlSetData($ListView1_5, "|" & "")
 GUICtrlSetData($ListView1_5, "|" & "|" & "")
 GUICtrlSetData($ListView1_6, "")
 GUICtrlSetData($ListView1_6, "|" & "")
 GUICtrlSetData($ListView1_6, "|" & "|" & "")
 GUICtrlSetData($ListView1_7, "")
 GUICtrlSetData($ListView1_7, "|" & "")
 GUICtrlSetData($ListView1_7, "|" & "|" & "")
 GUICtrlSetData($ListView1_8, "")
 GUICtrlSetData($ListView1_8, "|" & "")
 GUICtrlSetData($ListView1_8, "|" & "|" & "")
 GUICtrlSetData($ListView1_9, "")
 GUICtrlSetData($ListView1_9, "|" & "")
 GUICtrlSetData($ListView1_9, "|" & "|" & "")
 Call("SET_GUI")
 GUICtrlSetData($Label1, "Done!!!")
EndFunc   ;==>BUTTON2CLICK

i want to know if there is a way to shorten the above piece of code, this seems like a waste of space to me.

any help will be apriciated ^^

Damian666

and proud of it!!!
Posted

Here you are.

Func BUTTON2CLICK()
    For $x = 0 To 9
        GUICtrlSetData($ListView1[$x], "")
        GUICtrlSetData($ListView1[$x], "|" & "")
        GUICtrlSetData($ListView1[$x], "|" & "|" & "")
    Next
    SetGUI()
    GUICtrlSetData($Label1, "Done!!!")
EndFunc

As you can see, when you do something repetitive like this, it is beneficial to put the controls into an array.

Posted

You didn't know arrays were allowed to have variables? That is an important concept. Putting like variables or controls into an array can allow you to perform the same function on all of them much easier. Just think if you have 25 or 50 controls that had to be edited.

Posted (edited)

hmm... then what would cause this?

==> Subscript used with non-Array variable.:
GUICtrlSetData($ListView1[$x], "")
GUICtrlSetData($ListView1^ ERROR
->17:26:37 AutoIT3.exe ended.rc:1

oh, i know arrays use variables, just didnt know that would work on controls too >.<

Edited by damian666
and proud of it!!!
Posted (edited)

Oh! sorry. Forgot to declare arrays. You need to declare the array at the beginning of the script. Use "Dim $ListView1[10]" because there are 10 elements in the array.

Edited by dantay9
Posted (edited)

oh yeah >.< sheesh...

that i myself didnt notice that Posted Image

but should that not be "Dim $ListView1_[10]" ??

notice the underscore?

yeah, that fixed it, thank you for your time :)

Edited by damian666
and proud of it!!!
Posted

ok, seems like i still dont get it, the above works, but this wont ???

For $x = 0 To 9
  $string1 = IniRead($lic, $number, "info1", "")
  $string2 = IniRead($lic, $number, "info2", "")
  $status = IniRead($lic, $number, "Status", "")

    If Not @error Then
        GUICtrlSetData($ListView1_[$x], $string1)
        GUICtrlSetData($ListView1_[$x], "|" & $string2)
        GUICtrlSetData($ListView1_[$x], "|" & "|" & $status)
  EndIf
  $number += 1
 Next

i mean, wtf... its the same principle right?

it does read the info correct, but wont insert it in the control...

Damian666

and proud of it!!!

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
×
×
  • Create New...