Page 1 of 1

GetObjectInfo question

PostPosted: Mon Mar 26, 2012 2:01 pm
by dpayer
Is it possible to get information about a list box just from its name?

I know we define a variable of 'Selected Item(s)' in a listbox. I was hoping to create a NB function to move an item from one listbox to another by using only their names.

I thought the getobjectinfo would give me the selected text of the listbox. It returns a value called 'selected text' but that appears to work only for article objects.

Is it possible to derive the name of the variable used for selected text just from the listbox info (ie getobjectinfo "listbox1", etc.)

David P.

PostPosted: Mon Mar 26, 2012 3:21 pm
by Gaev
DavidP:

If you can make sure (at design time) that each ListBox's Object Name (e.g. Fruits) is the same as the Variable: (to store selected item) (e.g. [Fruits]), here is the desired function ...
Code: Select all
.. this Function will move the currently selected item in the ListBox with the same name as %1
.. to the ListBox with the name in %2
..passed parameters
SetVar "[sourceListBox]" "[%1]"
SetVar "[targetListBox]" "[%2]"
... selected item text
..AlertBox "siText" "[[SourceListBox]]"
... find the number of the selected item
ListBoxFindItem "[SourceListBox]" "[[SourceListBox]]" "[Found]"
If "[Found]" ">" "0"
    .. add to targetListBox
    ListBoxAddItem "[targetListBox]" "0" "[[SourceListBox]]"
    .. remove from sourceListBox
    ListBoxDeleteItem "[SourceListBox]" "[Found]"
EndIf
... and here is how you call it ...
Code: Select all
Call "davidPMoveListBoxItem" "Source" "Target"
Return


The key line of code is ...
Code: Select all
ListBoxFindItem "[SourceListBox]" "[[SourceListBox]]" "[Found]"
... note the double brackets !!!

PostPosted: Mon Mar 26, 2012 7:23 pm
by dpayer
Gaev wrote:DavidP:

If you can make sure (at design time) that each ListBox's Object Name (e.g. Fruits) is the same as the Variable: (to store selected item) (e.g. [Fruits]), here is the desired function !!!


Thanks Gaev.

I was hoping to create a NB function that could be used where someone already had defined the variables in their listbox.

If I can control the variable name, it does simplify the task.

I appreciate your input.

David P.