More scripting help needed... IF statements.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 12
- Joined: Tue Jun 20, 2006 8:11 pm
More scripting help needed... IF statements.
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
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
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
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
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
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
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
-
- Posts: 12
- Joined: Tue Jun 20, 2006 8:11 pm
Why doesn't this work.... :(
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
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