Help me with this activity!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Help me with this activity!
Hi everyone! I´ve been trying to make this activity where you should put three fields and a button in the fields you should specify the angles of a traingle, and when you hit the button, an image of the triagle should appear, it was working properly, and I closed the file. I do not know why now it is not working, it shows me this error.
***button "What is?": execution error at line 7 (Operators +: error in left operand), char 1***
this is the code
on mouseUp
put field "first" into x
put field "second" into y
put field "third" into z
if x+y+z=180
then set the visible of img "error" to FALSE
if x+y+z=180 and x=60 and y=60 and z=60
then set the visible of img "equilateral(1).png" to TRUE
else
set the visible of img "equilateral(1).png" to FALSE
if x+y+z=180 and x=y or y=z or x=z
then set the visible of img "isosceles" to TRUE
else
set the visible of img "isosceles" to FALSE
if x+y+z=180 and x=90 or y=90 or z=90
then set the visible of img "recto" to TRUE
else
set the visible of img "recto" to FALSE
if x+y+z=180 and x<>y and x<>z and y<>z
then set the visible of img "escaleno" to TRUE
else
set the visible of img "escaleno" to FALSE
if x + y + z <> 180
then set the visible of img "error" to TRUE
end if
end if
end if
end if
end mouseUp
***button "What is?": execution error at line 7 (Operators +: error in left operand), char 1***
this is the code
on mouseUp
put field "first" into x
put field "second" into y
put field "third" into z
if x+y+z=180
then set the visible of img "error" to FALSE
if x+y+z=180 and x=60 and y=60 and z=60
then set the visible of img "equilateral(1).png" to TRUE
else
set the visible of img "equilateral(1).png" to FALSE
if x+y+z=180 and x=y or y=z or x=z
then set the visible of img "isosceles" to TRUE
else
set the visible of img "isosceles" to FALSE
if x+y+z=180 and x=90 or y=90 or z=90
then set the visible of img "recto" to TRUE
else
set the visible of img "recto" to FALSE
if x+y+z=180 and x<>y and x<>z and y<>z
then set the visible of img "escaleno" to TRUE
else
set the visible of img "escaleno" to FALSE
if x + y + z <> 180
then set the visible of img "error" to TRUE
end if
end if
end if
end if
end mouseUp
Re: Help me with this activity!
Déjà vue? viewtopic.php?f=7&t=30057&p=159687#p159687
It is good style to first answer other unanswered threads of yours!
BTW, your code compiled without error on my machine.
It is good style to first answer other unanswered threads of yours!
BTW, your code compiled without error on my machine.
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Help me with this activity!
This is probably homework. He/she learned nothing from the answers. Poor Klaus.
shiftLock happens
Re: Help me with this activity!
Then we have three of them currently.
O tempora, o mores!
O tempora, o mores!
Re: Help me with this activity!
Your code works, but an end if is missing:
########CODE to copy and paste#######
on mouseUp
put field "first" into x
put field "second" into y
put field "third" into z
if x+y+z=180 then set the visible of img "error" to FALSE
if x+y+z=180 and x=60 and y=60 and z=60 then
set the visible of img "equilateral(1).png" to TRUE
else
set the visible of img "equilateral(1).png" to FALSE
if x+y+z=180 and x=y or y=z or x=z then
set the visible of img "isosceles" to TRUE
else
set the visible of img "isosceles" to FALSE
if x+y+z=180 and x=90 or y=90 or z=90 then
set the visible of img "recto" to TRUE
else
set the visible of img "recto" to FALSE
if x+y+z=180 and x<>y and x<>z and y<>z then
set the visible of img "escaleno" to TRUE
else
set the visible of img "escaleno" to FALSE
if x + y + z <> 180 then
set the visible of img "error" to TRUE
end if
end if
end if
end if
end if
end mouseUp
#####END OF CODE generated by http://tinyurl.com/j8xf3xq with livecode 9.0.0-dp-10#####
########CODE to copy and paste#######
on mouseUp
put field "first" into x
put field "second" into y
put field "third" into z
if x+y+z=180 then set the visible of img "error" to FALSE
if x+y+z=180 and x=60 and y=60 and z=60 then
set the visible of img "equilateral(1).png" to TRUE
else
set the visible of img "equilateral(1).png" to FALSE
if x+y+z=180 and x=y or y=z or x=z then
set the visible of img "isosceles" to TRUE
else
set the visible of img "isosceles" to FALSE
if x+y+z=180 and x=90 or y=90 or z=90 then
set the visible of img "recto" to TRUE
else
set the visible of img "recto" to FALSE
if x+y+z=180 and x<>y and x<>z and y<>z then
set the visible of img "escaleno" to TRUE
else
set the visible of img "escaleno" to FALSE
if x + y + z <> 180 then
set the visible of img "error" to TRUE
end if
end if
end if
end if
end if
end mouseUp
#####END OF CODE generated by http://tinyurl.com/j8xf3xq with livecode 9.0.0-dp-10#####
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Help me with this activity!
Buongiorno Max,
you are spoiling almost all of our well-thought pedagogical approaches!
Best
Klaus
you are spoiling almost all of our well-thought pedagogical approaches!
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 7229
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Help me with this activity!
This handler begs for a switch statement.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Help me with this activity!
A switch statement, or just some clean up.
The repeat I used there could be done a lot better, and probably without repeat at all, but I'll leave that as homework
Code: Select all
on mouseUp
lock screen
set the visible of img "error" to TRUE
put field "first" into x
put field "second" into y
put field "third" into z
// the following assumes all triangle images have something in common,
// if so, just set the visible of all images you want from the start...
repeat with x=1 to the number of images on card "yourCard"
if image x contains "commonIdentifier" then
set the visible of image x to false
end if
end repeat
// then use switch/case or else if to determine visibility...
if x+y+z=180
then set the visible of img "error" to FALSE
if x+y+z=180 and x=60 and y=60 and z=60
then set the visible of img "equilateral(1).png" to TRUE
else if x+y+z=180 and x=y or y=z or x=z
then set the visible of img "isosceles" to TRUE
else if x+y+z=180 and x=90 or y=90 or z=90
then set the visible of img "recto" to TRUE
else if x+y+z=180 and x<>y and x<>z and y<>z
then set the visible of img "escaleno" to TRUE
/* this test is not needed because to get into this loop
we already know x + y + z = 180...
else if x + y + z <> 180
then set the visible of img "error" to TRUE */
end if
end if
unlock screen
end mouseUp