This article introduces about condition in Small Basic and expecting to understand Small Basic deeply.

What is Condition?

In Small Basic, there are two pattern to use condition as follows.

If condition Then
While condition

Types of Condition

There are following three types of condition in Small Basic.

  • comparison expression (ex. a < b)
  • logical expression (ex. clicked And moved)
  • logical value (ex. "True")

Comparison Expression

There are following six comparison operators in Small Basic.

  • = equal to
  • < less than
  • <= less than or equal to
  • > greater than
  • >= greater than or equal to
  • <> not equal to

Equal to and not equal to are used for text also.  But other operators are for numbers.  While comparing two texts with operators including less or greater, the texts are converted to number zeroes before comparison.  So comparison such like "ant" > "apple" always returns "False".  To compare order for texts, you should create a subroutine like one in a sample JLS539-1.

Logical Expression

There are following two logical operators in Small Basic.

  • And
  • Or

Small Basic doesn't have Not operator.  Following code is my alternate solution.

Not = "True=False;False=True;"
While Not[keydown]

Logical Value

There are following two logical values in Small Basic.

  • "True"
  • "False"
These texts are not case-sensitive.  So for example both "TRUE" or "false" are available as logical values.  Actually, Small Basic checks whether the logical value is "True" or not.  And following properties and operations return logical values.
  • Array.ContainsIndex(arry, index)
  • Array.ContainsValue(arry, value)
  • Array.IsArray(arry)
  • GraphicsWindow.CanResize
  • GraphicsWindow.FontBold
  • GraphicsWindow.FontItalic
  • Mouse.IsLeftButtonDown
  • Mouse.IsRightButtonDown
  • Text.IsSubText(txt, subTxt)
  • Text.EndsWith(txt, subTxt)
  • Text.StartsWith(txt, subTxt)

See Also

Additional Resources

Other Languages