Jump to content

Recommended Posts

Posted

I hope I am using the execute function properly with the following line of code:

Execute("$openlistitem" & $counter & "=GUICtrlCreateListViewItem($openlistarray[" & $counter &"],$Opencaselist)")

I am trying to dynamically evaluate the statement:

$openlistitem24=GUICtrlCreateListViewItem($openlistarray[24],$Opencaselist)

and it is not working. Please help. I know its got to be something simple.

Posted

P.S. the second line of code in the above post will work fine if entered manually. The problem is when I try to construct

it dynamically and use the execute statement.

Posted (edited)

Sorry, bub.

From the helpfile:

Remarks

Environment, Files, Dir, Disk, GUI, InputBox, MsgBox, Misc, Network, Obj/COM, Process, Registry, Tray, WinKill functions implying deletion or modification will not be executed. They will set @error to 9999 and return "".

That could mean 1 of two things:

1, that GUI functions won't be handled. In this case you're lost.

2, that GUI functions implying deletion or modification won't be handled. In this case... I have no clue. Sorry.

Edited by JoshDB
Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite
Posted

I don't even think it has to do with any of those exceptions. I've been playing with this a bit and even with the simplified

code shown below I can't get the execute statement to even dynamically create a variable such as $tempadd3.

Dim $tempadd3

$counter=3

$tempstr="$tempadd" & $counter & "=5" ;;;creates the string "$tempadd3=5"

Execute($tempstr)

MsgBox(0,"",$tempadd3)

I'm sure Autoit can handle situations such as these since they come up quite often in programming. I just can't figure out what is going wrong. I also checked the @error returned from the execute statement and it wasn't the 9999 that would be generated for one of the exceptions you pointed out in the function definition.

Posted

I agree - With some further testing I see your point.

However, this would be a quick to a solution - There is a quite simple workaround.

Global $openlistitem[101]

While 1
    $openlistitem[0] = $openlistitem[0] + 1; Equivelent of $counter
    
    $openlistitem[$openlistitem[0]] = GUICtrlCreateListViewItem($openlistarray[$openlistitem[0]],$Opencaselist)
WEnd
Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite
Posted

I had thought of using arrays but I wasn't sure if the individual elements of an array could be assigned to event functions etc (I need to do something different depending on which item in the listview is clicked). Unless I get a better explanation of the execute

function, I will have to start doing some testing to see if the array method will work for me.

Thanks for the suggestion.

Posted

Here's this bit of code that exemplifies what I said above. And no, I'm not sure if that's a word or if it's spelled right.

Global $_name[101]
Global $_damage[101]
Global $_dps[101]
Global $_average[101]
Global $_time[101]
Global $_count[101]

Global $_guiname[101]
Global $_guidps[101]
Global $_guiaverage[101]

; PROGRAM CODE NOT INCLUDED HERE - TOO LONG AND TOO SECRETIVE : )

        $NamePos = _ArraySearch ($_name, $playername)
        
        If $NamePos <= 0 Then
            $_name[0] = $_name[0] + 1
            $_name[$_name[0]] = $playername
            $NamePos = $_name[0]
        EndIf
        
        If $_time[$NamePos] = 0 Then $_time[$NamePos] = 1
        
        $_count[$NamePos] = $_count[$NamePos] + 1
        $_damage[$NamePos] = $_damage[$NamePos] + Damage($str)
        $_time[$NamePos] = $_time[$NamePos] + $second - $secondreference
        $_average[$NamePos] = Round($_damage[$NamePos] / $_count[$NamePos])
        $_dps[$NamePos] = Round($_damage[$NamePos] / $_time[$NamePos])
        
        If Number($_average[$NamePos]) Then
            GUICtrlSetData($_guiname[$NamePos],$playername )
            GUICtrlSetData($_guidps[$NamePos],$_dps[$NamePos])
            GUICtrlSetData($_guiaverage[$NamePos],$_average[$NamePos])

            GUISetState()
        EndIf

So basically this code searces all player names (the $_name array) logged for the current player name ($playername). If it doesn't exist, then it's logged. If it does, then... It's not. Whatever happens, the program continues on to set a little data about the player, indexed to the position of the player's name in the $_name array.

This is probably a bad solution (veterans pop in here!), but it works like a dream for me.

P.S. The GUICtrlSetData calls are made in lieu of GUICtrlCreateLabel because the labals are all pre-made, they're just blank, waiting to be filled.

Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite
  • 2 weeks later...
Posted

I agree - With some further testing I see your point.

However, this would be a quick to a solution - There is a quite simple workaround.

Global $openlistitem[101]

While 1
    $openlistitem[0] = $openlistitem[0] + 1; Equivelent of $counter
    
    $openlistitem[$openlistitem[0]] = GUICtrlCreateListViewItem($openlistarray[$openlistitem[0]],$Opencaselist)
WEnd
Josh,

I need to re-visit this one again since I have come across a situation where I need the event of each handle in the array to

be recognized in the Autoit event handler loop. In other words I want to be able to do something unique if any of the items are clicked. The user of my code can create 10 or 100 of these so that is why I originally wanted to use the execute function.

Basically, if you could show my how to create unique events for each of the items in the $openlistitem array, that would solve

my problem.......for now.....;>

Posted

Find out how to detect the index of the item that is being clicked. Yo ucan do this by detecting which is clicked and then by using an _ArraySearch. The develop your function around those two pieces of information.

Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite
Posted

Thanks Josh.

Here is what I came up with (its the ass end of my event handler loop). Works great. Thanks for the idea.

...........
...........

        Case Else
            $casetypeindex=_ArraySearch($Casetypearray,$nMsg[0])
            If $casetypeindex>0 Then
                $temparray=StringSplit($MJTDATA[1],"|")
                If _GUICtrlListFindString($CaseTypeList,$temparray[$casetypeindex],1)=$LB_ERR Then
                    _GUICtrlListAddItem($CaseTypeList,$temparray[$casetypeindex])
                Else
                    MsgBox(0,"Error","This case type is already in list")
                EndIf
            EndIf
    EndSwitch
WEnd

Find out how to detect the index of the item that is being clicked. Yo ucan do this by detecting which is clicked and then by using an _ArraySearch. The develop your function around those two pieces of information.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...