Partilhar via


Conditon in Small Basic

Introduction

Today, I'd like to write about condition in Small Basic.  I hope this information make you understand Small Basic deeply.

What is Conditon?

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

If condition Then

  statements

EndIf

While condition

  statements

EndWhile

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 follwing 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. If you compare two texts with operators including less or greater, the texts are converted to number zeroes before comparison. So you can't compare such like "ant" > "apple". To compare order for texts, you should create a subroutine.

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]

  Program.Delay(200)

EndWhile

Logical Value

There are following two logical values in Small Basic.

  • "True"
  • "False"

 These texts are not case-sensitive.  So you can write "TRUE" or "false" for the same purpose.  Actually, Small Basic checks whether the logical value is "True" or not.

Comments

  • Anonymous
    June 02, 2014
    I like the Not Array variable to reverse logical true and false.  I usually end up doing If (keydown = "False"), but I prefer your approach.

  • Anonymous
    June 02, 2014
    This is a great description! Thanks, Nonki!

  • Anonymous
    June 02, 2014
    I wrote TechNet Wiki article about control also. social.technet.microsoft.com/.../24709.small-basic-condition.aspx

  • Anonymous
    June 02, 2014
    Oops, not control but condition.

  • Anonymous
    December 22, 2015
    great

  • Anonymous
    March 31, 2017
    very help