Page 1 of 1

Help me with this activity!

Posted: Sun Oct 29, 2017 11:56 pm
by MMH
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

Re: Help me with this activity!

Posted: Mon Oct 30, 2017 10:45 am
by Klaus
Déjà vue? viewtopic.php?f=7&t=30057&p=159687#p159687

It is good style to first answer other unanswered threads of yours! 8)
BTW, your code compiled without error on my machine.

Re: Help me with this activity!

Posted: Mon Oct 30, 2017 10:52 am
by [-hh]
This is probably homework. He/she learned nothing from the answers. Poor Klaus.

Re: Help me with this activity!

Posted: Mon Oct 30, 2017 12:09 pm
by Klaus
Then we have three of them currently.
O tempora, o mores! 8)

Re: Help me with this activity!

Posted: Fri Dec 01, 2017 1:24 pm
by MaxV
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#####

Re: Help me with this activity!

Posted: Fri Dec 01, 2017 1:31 pm
by Klaus
Buongiorno Max,

you are spoiling almost all of our well-thought pedagogical approaches! :D


Best

Klaus

Re: Help me with this activity!

Posted: Fri Dec 01, 2017 6:05 pm
by jacque
This handler begs for a switch statement.

Re: Help me with this activity!

Posted: Fri Dec 01, 2017 10:07 pm
by bogs
A switch statement, or just some clean up.

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
The repeat I used there could be done a lot better, and probably without repeat at all, but I'll leave that as homework :)