Page 1 of 1

Problems with Listbox

PostPosted: Sun Dec 11, 2011 8:34 am
by kennyray23
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....

PostPosted: Sun Dec 11, 2011 8:43 am
by dec
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.

PostPosted: Mon Dec 12, 2011 3:14 am
by kennyray23
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.

PostPosted: Mon Dec 12, 2011 3:53 am
by kennyray23
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