scummvm/engines/director/lingo/tests/if.lingo
Roland van Laar 762ebd59df DIRECTOR: LINGO: improve lingo c_not
It's a bit unexpected, but `not` works differently then the inverse of
`if`.

After testing in D4.0.4 the following two statements are true:

    defined variables are falsy when checked with not
        i.e. not varundefined => true and not vardefined => false
    only a var with value 0 is seen as false when checked with not
        i.e. not 0 => true
2023-11-24 22:49:06 +01:00

172 lines
4.4 KiB
Text
Raw Permalink Blame History

--
set x = 1
if x = 5 then exit
else put 10.0
if x = 6 then put 2
set y = 4
-- defined variables are falsy when checked with not
-- i.e. not varundefined => true
-- only a var with value 0 is seen as false when checked with not
-- i.e. not 0 => true
scummvmAssert(varundefined = 0)
scummvmAssert(not varundefined = 1)
set a to 0
scummvmAssert(not a = 1)
set a to 0.0
scummvmAssert(not a = 0)
set a to "string"
scummvmAssert(not a = 0)
set parray to [#pt: 1, #ar: 0]
scummvmAssert(not parray = 0)
--
repeat with x = 1 to 6
if x = 3 then put 30
else if x = 4 then put 40
else if x = 5 then put 50
else put 10.0
if x = 1 then
put 1
else if x = 2 then
put 1232.12345678901234
put 2.2
else if x = 3 then
put 3
else if x = 4 then
put 4
else if x = 5 then
put 5
else if x = 6 then
put 6
end if
if x = 4 then put 40
else put 50
end repeat
if the keyCode = 36 then -- return key goes to first menu
go to frame 1
else if the keyCode = 123 then -- left arrow goes to previous menu
dontPassEvent
go to marker(-1)
else if the keyCode = 124 then -- right arrow goes to next menu
dontPassEvent
go to marker(1)
else if the keyCode = 125 then -- down arrow goes to last (bottom) menu
dontPassEvent
go to frame "credits"
else if the keyCode = 126 then -- up arrow goes to first (top) menu
dontPassEvent
go to frame 1
end if
if abs(y) = x and abs(x) = y then
put TRUE
else
put FALSE
end if
if abs(y) = x and abs(x) = y then put 5
if abs(y) = x and abs(x) = y then put 5
else put 6
if the selection = the text of cast 1 then
go to frame "sEnd"
exit
else if whichTry = 1 then go to frame "sTell"
else if whichTry = 2 then go to frame "sShow"
else if whichTry = 3 then go to frame "sDo"
if the selection = the text of cast 1 then
go to frame "sEnd"
exit
else if whichTry = 1 then
go to frame "sTell"
else if whichTry = 2 then
put 5
go to frame "sShow"
else if whichTry = 3 then go to frame "sDo"
else put 6
if the selection = the text of cast 1 then go to frame "sEnd"
else put 7
if the selection = the text of cast 1 then go to frame "sEnd"
else if whichTry = 1 then
go to frame "sTell"
else if whichTry = 2 then
put 5
go to frame "sShow"
else if whichTry = 3 then go to frame "sDo"
else
put 6
put 7
end if
if the selection = the text of cast 1 then go to frame "sEnd"
else if whichTry = 1 then
go to frame "sTell"
else if whichTry = 2 then
put 5
go to frame "sShow"
else if whichTry = 3 then go to frame "sDo"
else put 7
if rollOver(2) then
put "The cursor is INSIDE the square." into field "Cursor Status"
else
put "The cursor is OUTSIDE the square." into field "Cursor Status"
end if
if the selection = the text of cast 1 then
if whichTry = 3 then
go to frame "sDo"
end if
else if whichTry = 1 then
if whichTry = 3 then go to frame "sDo"
else
put 5
end if
else if whichTry = 2 then
if whichTry = 3 then go to frame "sDo"
else
if the selection = the text of cast A21 then
if whichTry = 3 then
go to frame "Foo"
end if
else if abra = 5 then put 6
else
put 7
if abra = 7 then put 5
end if
end if
else if whichTry = 3 then go to frame "sDo"
else put 6
if the selection = the text of cast 1 then go to frame "sEnd"
when keyDown then if the key = RETURN then checkField
when keyDown then if the key = QUOTE then checkField
if the mouseH > ((the right of sprite 15) - 20) then beep
else if ((the mouseH > ((the left of sprite 15) + 30)) and <20>
(the mouseH < ((the left of sprite 15) + 73)) and <20>
(the mouseV > ((the top of sprite 15) + 20)) and <20>
(the mouseV < ((the top of sprite 15) + 40))) then StoreButtonHit
else if ((the mouseH > ((the left of sprite 15) + 81)) and <20>
(the mouseH < ((the left of sprite 15) +124)) and <20>
(the mouseV > ((the top of sprite 15) + 20)) and <20>
(the mouseV < ((the top of sprite 15) + 40))) then LoadButtonHit
else if ((the mouseH > ((the left of sprite 15) + 30)) and <20>
(the mouseH < ((the left of sprite 15) +124)) and <20>
(the mouseV > ((the top of sprite 15) + 55)) and <20>
(the mouseV < ((the top of sprite 15) + 83))) then AudioButtonHit
end if
macro WindowHorzP X
set X1 = constrainH( 14, X )
if X1 = X then return( TRUE )
else return( FALSE )