if

Help Contents First Steps In Logo Built-in instructions Controlling program flow if
Controlling program flow repeat

if


One of them, if, is used to tell Logo to execute a list of instructions only if a given condition is fulfilled.

	if :a>0 [print "positive]
Here you say Logo to print the word positive only if the value of a is greater than zero.

Apparently if enables you to define not only what to do when something is true, but also what to do otherwise:
	if :a>0
		[print "positive]
		[print "negative "or "zero]
To make shorter line Logo agrees to look for lists of instructions not only in the line where if is used, but also on the next line too.

Anyway, the condition must always be on the same line - right after if.

Speaking of conditions, Logo decides whether one is fulfilled only by its value.

It its value is the word true, then the condition is fulfilled. Otherwise it is not.

Examples:
References:

Controlling program flow repeat