Jump to content

working with dynamic variables?


 Share

Recommended Posts

I have descovered how to create a tray menu item dynamically by using:

EX>

For $i = 1 To $Groups[0][0]

Assign($Groups[$i][0], TrayCreateItem($Groups[$i][1]), 2)

Next

but having trouble trying to remove the menu items using :

EX>

For $i = 1 To $Groups[0][0]

TrayItemDelete($Groups[$i][0])

Next

can someone please help!

Link to comment
Share on other sites

I have descovered how to create a tray menu item dynamically by using:

EX>

    For $i = 1 To $Groups[0][0]

  Assign($Groups[$i][0], TrayCreateItem($Groups[$i][1]), 2)

    Next

but having trouble trying to remove the menu items using :

EX>

    For $i = 1 To $Groups[0][0]

  TrayItemDelete($Groups[$i][0])

    Next

can someone please help!

<{POST_SNAPBACK}>

Not sure why your using the Assign.

The following should work for storing the control Id's

For $i = 1 To $Groups[0][0]
    $Groups[$i][0] = TrayCreateItem($Groups[$i][1],2)
Next

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Not sure why your using the Assign.

The following should work for storing the control Id's

For $i = 1 To $Groups[0][0]
    $Groups[$i][0] = TrayCreateItem($Groups[$i][1],2)
Next

<{POST_SNAPBACK}>

Storing the items in the array is not the problem. It seems to be deleting the dynamically created menu items...
Link to comment
Share on other sites

Both your code and Gary's code will successfully create the tray menu items, but only using Gary's code will you be able to delete them again with your deletion code because Gary's code does store the references to the items in the array while yours doesn't.

Here's an example of how Assign() works:

$apple = "banana"
$banana = "456"
assign($apple, "789")
; this sets $banana to 789 and not $apple

Hope that clears the confusion. Assign() is used to assign a value to a variable whose name is stored in another.

assign($apple, "789")
; not identical to
$apple = "789"
Edited by LxP
Link to comment
Share on other sites

Both your code and Gary's code will successfully create the tray menu items, but only using Gary's code will you be able to delete them again with your deletion code because Gary's code does store the references to the items in the array while yours doesn't.

Here's an example of how Assign() works:

$apple = "banana"
$banana = "456"
assign($apple, "789")
; this sets $banana to 789 and not $apple

Hope that clears the confusion. Assign() is used to assign a value to a variable whose name is stored in another.

assign($apple, "789")
; not identical to
$apple = "789"

<{POST_SNAPBACK}>

Thankx guys, really appreciate it. Works like a charm
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...