|
أمري الشرط IF و IFELSE :
الصيغة
العامة
if [true/false condition][action if true]
ifelse [true/false condition][action if true][action if false]
make "variable1 23
make "variable2 23
ifelse :variable1 = :variable2 [print [It's TRUE]][print
[It's FALSE]]
produces ... It's TRUE
ملحوظة :
يمكن أن يحوي جواب الشرط بالقوس المربع
العديد من الأوامر ومنها الإجراءات .
iftrue and iffalse
الأمرين
iftrue and iffalse
هما
تطبيقات خاصة لأمر الشرط "if"
حيث
يقوم الأمر "test"
باختبار
العبارة أولاً ومن ثم يعتمد سلوك الأمر
الأمرين iftrue
و
if false علي تلك
النتيجة
مثال:
make "variable1 27
make "variable2 33
test :variable1 = :variable2
iftrue [print [The values are the same.]]
ifffalse [print [The values are different.]]
produces ... The values are different.
وكما سبق
يمكن يعالج جواب الشرط عدد من الأوامر أو
الإجراءات .
|