Sign in to follow this  
Followers 0
RìggníX

variable variable

7 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

k, that works.

there are controlIDs of listviewitems saved in this array.

How can i use them by clicking on it?

btw: i use the MessegaLoop mode


greetz, RìggníXBiTrAtE.tk

Share this post


Link to post
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..

Share this post


Link to post
Share on other sites

k:

i've made a CtrlListView. in that for-next loop there are CtrlListViewItem's created, and their ControlID's are saved in this array.

Now, i want the program to react, if the user double clicks an item.


greetz, RìggníXBiTrAtE.tk

Share this post


Link to post
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..

Share this post


Link to post
Share on other sites

thx, it works!!

/signed


greetz, RìggníXBiTrAtE.tk

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