Page 1 of 1

More scripting help needed... IF statements.

Posted: Tue Jul 11, 2006 11:11 pm
by AndrewWickliffe
I'm trying to get store something in the temp memory and use it to control where a jump goes.

On a button, I've got
on mouseUp
put "Entry1" into entrySelection
end mouseUp

then on another button, the jump button, I've got this:

on mouseUp
if entrySelection contains "Entry1" then go to card 1
else
if entrySelection is "Entry2" then go to card 2
else
if entrySelection is "Entry3" then go to card 3
else go to card 4
end if
end if
end mouseUp

I can get it to jump to card 4 (from all three selections), but I can't get it to actually work.

Any help would be greatly appreciated....

TIA

Posted: Wed Jul 12, 2006 4:16 pm
by BvG
You somehow need to store the data so the other button can access it.

For example as custom property:
set the entrySelection of this stack to "Entry1"

Then you can do this to access the custom property:
put the entrySelection of this stack into yourVar

another way is with globals:
button 1:
global entrySelection
on mouseUp
put "Entry1" into entrySelection
end mouseUp
button 2:
on mouseUp
if entrySelection contains "Entry1" then go to card 1
else
....
end if
end mouseUp


also one if statement can only have one "else", but several "else if"'s, your code should look like this:
on mouseUp
if entrySelection contains "Entry1" then
go to card 1
else if entrySelection is "Entry2" then
go to card 2
else if entrySelection is "Entry3" then
go to card 3
else
go to card 4
end if
end mouseUp

Posted: Wed Jul 12, 2006 6:02 pm
by malte
A short addition to BvGs post:

If you want to work with globals, you need to declare them in each button.

button 1:
global entrySelection
on mouseUp
put "Entry1" into entrySelection
end mouseUp

button 2:
global entrySelection
on mouseUp
if entrySelection contains "Entry1" then go to card 1
else
....
end if
end mouseUp

All the best,

Malte

Posted: Wed Jul 12, 2006 7:32 pm
by BvG
argh posted too fast again :)

Why doesn't this work.... :(

Posted: Sun Jul 16, 2006 3:30 am
by AndrewWickliffe
I've succcessfully gotten the entrySelection filled... but I can't get it to work with this:

on openCard
if entrySelection contains "Submit1" then
set the layer of image "Entry1" to top
else
play videoClip "Task 1 Ask 1"
end if
end openCard

always plays the video.

TIA

Posted: Sun Jul 16, 2006 8:23 am
by malte
try declaring the global.

global entrySelection

--rest of script here.

This is important. If the var is not declared for the script you are using it in it will be treated as a local variable which in this case is always empty.

Hope that helps,

Malte

Posted: Sun Jul 16, 2006 12:50 pm
by AndrewWickliffe
thanks