Δευτέρα, 31 Δεκεμβρίου 2018

Revision 14 Version 9.6

Fix the IF structure

This structure have four possible constructions

1) Using blocks
If condition then {

} else.if condition2 then {

} else.if condition3 then {

} else {

}

or in one line
If condition then {  } else.if condition2 then {  } else.if condition3 then { } else { }
last block maybe omit
If condition then {  } else.if condition2 then {  } else.if condition3 then { } else print "else"

after last block we can use : and place other statements. Those statements are not of the if structure
its structure return 123 because : ? "123"  (? for Print) aren't part of if (because a structure end with a block).

if false THEN {Print "no" } else.if true then {Print "else.if1"} else { ? "ok"} : ? "123"
if true THEN {Print "no" } else.if true then {Print "else.if1"} else { ? "ok"} : ? "123"
if false THEN {Print "no" } else.if true else {Print "else.if1"} else { ? "ok"} : ? "123"
if false THEN {Print "no" } else.if false else {Print "else.if1"} else { ? "ok"} : ? "123"


2) Without blocks
(we can use if condition else for reverse logic)
If condition then

else.if condition2 then

else.if condition3  else

else.if condition3 then

else

end if




3) In one line (we can use blocks or not)
If condition then print 1: print 2 else.if condition2 then print 4 else.if condition3 then print 5 : print 6 else print 7

if last clause has no block  then all statements until the end of line are part of if structure (of last clause)

If false then print 1: print 2 else.if false then print 4 else.if true then print 5 : print 6 else print 7

4) Split structure
(each in one line, no nested, can't be used inside type 2)
if false then Error "not a number"
Else Print "ok"






Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου