Source language: Translate to:

GetObjectInfo question

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

GetObjectInfo question

Postby dpayer » Mon Mar 26, 2012 2:01 pm

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.
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby Gaev » Mon Mar 26, 2012 3:21 pm

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 !!!
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby dpayer » Mon Mar 26, 2012 7:23 pm

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.
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest