Source language: Translate to:

Problems with Listbox

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Problems with Listbox

Postby kennyray23 » Sun Dec 11, 2011 8:34 am

Hello, I am having a strange problems getting a line of script to execute once an item is pulled from a listbox. I was previously able to make this work without problems but for some reason NB won't cooperate with me. What I want to do is simple add a score if a certain letter resides in the listbox. Here is an example of what I am trying to do....

If "Listbox1" "=" "E"
Setvar "[Score]" "[Score]+400"
Else
Endif

In the script de-bugger, it appears as if it is pulling the "E" from the listbox, but the next line of script, (SetVar "[Score]" "[Score]+400"), doesn't execute.

I have also tried to "GetListboxItem" and put that into a variable and say " If Listbox1" "=" "[Variable]", but nothing works....little help please....
kennyray23
 
Posts: 11
Joined: Sat Nov 19, 2011 12:09 pm

Postby dec » Sun Dec 11, 2011 8:43 am

Hi,

The listbox object have an associated variable wich contain the selected listbox item. If you put a listbox object onto your publication, the default name to this is "ListBox1", and their associated variable is named "[ListBox1]". So, your condition need to look something like this:

Code: Select all
If "[Listbox1]" "=" "E"
  Setvar "[Score]" "[Score]+400"   
EndIf


Note we compare here the selected listbox item (stored on [ListBox1] variable) with the letter "E", in other words, we ask if the selected listbox item is "E", and, in this case, execute the next "SetVar" action.

Take a look at the listbox object properties (click with the right mouse button onto the listbox to see) for more information, for example, the [ListBox1] variable can store the text of the item (wich can be "E" or something else) or the number of the item on the listbox.
.
Enhance your NeoBook applications!
.
58 plugins, 1131 actions and 233 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Postby kennyray23 » Mon Dec 12, 2011 3:14 am

Thank you very much for your help, but I have another question. When the item "E" is added to the listbox, the only way for the next line of code to execute is if I highlight the letter in the listbox and click the button that holds the code:

If "[Listbox1]" "=" "E"
HideObject "Rectangle2" "Page Turn" "10"
else
Endif

Is there a way for the code to execute without me having to select the letter in the listbox? I thought I had accomplished this before, but I can't seem to figure it out.
kennyray23
 
Posts: 11
Joined: Sat Nov 19, 2011 12:09 pm

Postby kennyray23 » Mon Dec 12, 2011 3:53 am

Think I figured it out... this is what I did...

ListBoxSize "ListBox1" "[Size]"
ListBoxGetItem "ListBox1" "[Size]" "[Outcome]"
If "[Outcome]" "=" "E"

HideObject "Rectangle2" "None" "0"

Else
Endif
kennyray23
 
Posts: 11
Joined: Sat Nov 19, 2011 12:09 pm


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 4 guests

cron