Jump to content

variable variable


Recommended Posts

hi guys!

i've made a for-next loop and have to save a Control id in every run. and the loop must run 255 times.

so i can't save it in a array, can i?

so i thought that there must be a way to set a variables name with another variable.

for example:

the variable of the for-next loop is called $i. no i want to create variables in every run, which names would be $var1, $var2, $var3...

someone's got an idea?

greetz, RìggníXBiTrAtE.tk

Link to comment
Share on other sites

This won't work. The best way to accomplish this is to create an array & store data within it. It should look something like this:

#include <Array.au3> ;This is for _ArrayDisplay function
Local $array[254] ;Create array
For $i = 1 To UBound($array)-1 ;For-Next loop
    $array[$i-1] = "This is $array[" & $i-1 & "]" ;For each array, store text
Next
_ArrayDisplay($array, "") ;Display the whole Array (Mainly for testing purposes)

[untested]

:whistle: Good luck,

Kurt

EDIT: Small correction

Edited by _Kurt

Awaiting Diablo III..

Link to comment
Share on other sites

there are controlIDs of listviewitems saved in this array.

How can i use them by clicking on it?

I'm having trouble trying to understand what you are trying to do. What exactly are you trying to say? Mind elaborating on that? :whistle:

Kurt

Awaiting Diablo III..

Link to comment
Share on other sites

Not too sure what you want to do, but I think this will help:

;THIS SCRIPT WAS CREATE BY GAFROST
; Events - ListView
#include <GuiConstants.au3>;Inclusion file for the GUI interface controls
#include <GuiListView.au3>

#region  Global variables
Global $ListView
Global Const $WM_NOTIFY = 0x004E
Global Const $DebugIt = 1

;ListView Events
Global Const $NM_FIRST = 0
Global Const $NM_CLICK = ($NM_FIRST - 2)
Global Const $NM_DBLCLK = ($NM_FIRST - 3)
#endregion End Global variables

Opt("WinTitleMatchMode", 2)

$main_GUI = GUICreate("GuiRegisterMsg Test", 225, 400, 300, 10, BitOR($WS_THICKFRAME, $WS_SIZEBOX))

$ListView = GUICtrlCreateListView("Entry Name|Category", 5, 75, 195, 280, BitOR($LVS_SORTASCENDING, $LVS_SINGLESEL))
_GUICtrlListViewSetColumnWidth ($ListView, 0, 100)
_GUICtrlListViewSetColumnWidth ($ListView, 1, 100)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("Name 1|Category 1", $ListView)
GUICtrlCreateListViewItem("Name 2|Category 2", $ListView)
GUISetState()

;Register WM_NOTIFY  events
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

While 1
   
   $msg = GUIGetMsg()
   
   Switch $msg
      
    ;-----------------------------------------------------------------------------------------
    ;This case statement exits and updates code if needed
      Case $GUI_EVENT_CLOSE
         Exit
         
         
       ;-----------------------------------------------------------------------------------------
       ;put all the misc. stuff here
        Case Else
            ;;;
   EndSwitch
WEnd

Func ListView_Click()
    ;Use this if you want to detect SINGLE clicks
EndFunc   ;==>ListView_Click

Func ListView_DoubleClick()
    MsgBox(0,"Double Clicked", _GUICtrlListViewGetItemText ($ListView, _GUICtrlListViewGetSelectedIndices($ListView)))
EndFunc   ;==>ListView_DoubleClick

;
; WM_NOTIFY event handler
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam) ;NMHDR (hwndFrom, idFrom, code)
    If @error Then Return
    $event = DllStructGetData($tagNMHDR, 3)
    Select
    Case $wParam = $ListView
        Select
            Case $event = $NM_CLICK
                ListView_Click ()
            Case $event = $NM_DBLCLK
                ListView_DoubleClick ()
            EndSelect
    EndSelect
    $tagNMHDR = 0
    $event = 0
    $lParam = 0
EndFunc   ;==>WM_Notify_Events

Script taken from a post from GaFrost

Kurt

Awaiting Diablo III..

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