create script variable "i"
repeat [[
change "i" by 1
if ((([i] mod 5) = 0) and (([i] mod 3) = 0))[[
display "FizzBuzz"
wait for 0.5 seconds
]] else [[
if (([i] mod 3) = 0)[[
display "Fizz"
wait for 0.5 seconds
]] else [[
if (([i] mod 5) = 0)[[
display "Buzz"
wait for 0.5 seconds
]] else [[
display i
]]]] for 100 times
Do not forget to put Indents(preferablly 4 spaces)
create script variable "i"
repeat [[
change "i"
if ((([i] mod 5) = 0) and (([i] mod 3) = 0))[[
display "FizzBuzz"
wait for 0.5 seconds
]] else [[
if (([i] mod 3) = 0)[[
display "Fizz"
wait for 0.5 seconds
]] else [[
if (([i] mod 5) = 0)[[
display "Buzz"
wait for 0.5 seconds
]] else [[
display i
]]]] for 100 times
make a variable called "x" for script -- the "x" variable is null currently
change "x" to 0
repeat this 100 times {
change [x] to [x]+1 -- change by 1
if [x] mod 5 = 0 and I mod 3 = 0 then{
display "FizzBuzz"
if not then{
if [x] mod 3 then{
display "Fizz"
if not that then{
if [x] mod 5 then{
display "Buzz"
if not then{
display(x)
Aargh, don't make the big Python mistake of making the spacing part of the syntax. Someone else edits the code using a different editor and the spacing gets messed up.
I think what started the formal theory of syntax is that in the first version of Algol they had if A then if B then C else D as legal syntax until they discovered that that's ambiguous.
Well, if A then if B then C else D is ambiguous -- is it if A then (if B then C) else D or is it if A then (if B then C else D)? In the first case, if A is false then you always do D; in the second case both A and B have to be false in order to get D.
Sensible languages solve this problem with some kind of bracketing. It doesn't matter whether you use parentheses or brackets or braces, but something. Some languages even use endif to close an if. Python reinvented the terrible idea, which comes along every 20 years or so, of using indentation as the bracketing mechanism. That works until you need to change the structure of a deeply-nested chunk of code, or not even deeply nested but just too long to fit on your screen at once.