Menu

Commands

Will Pittenger Bharath Gaddam

Definition

Commands are any procedure that looks like a simple statement when called. These can be built-in like the PRINT statement in every existing variant of BASIC or declared by code. They can be global or members of a class, struct, or interface. You declare them with the command keyword. They can’t return a value. Below is a list of what various parts of the declaration mean. Commands don’t have a return type. (The closest equivalent in C would be a function returning void.)

What you see What it means
[text] Optional syntax that isn’t needed to call the command
(possibility 1 or possibility 2) Either possibility can appear, but one must; both can’t appear
parameter1, parameter2 two parameters delimited by commas
\identifier\ Name of keyword that must appear without the backslashes
var string identifier Declaration of parameter “Identifier”
var s$ Declaration of parameter s$
(sequence)...identifier The sequence happens as many times as needed; identifier becomes an array with the contents being the sequence; access with identifer[index].
{\keyword1\ sequence, \keyword2\ sequence, ...} Defines a set of sequences, each preceded by a unique keyword (to the set), which can occur in any order, but only once. Place a sequence inside [] to make it optional. Without the [], that sequence is required somewhere.
Combined samples What they mean
[\Keyword\ var myString] Parameter myString is passed only if the \Keyword\ keyword appears
(\left\ or \right\) One of the keywords shown must appear
({[\keyword1\ var string strParam], [\keyword2\ var int%]})...paraemters A list of parameters that can appear in any order asand as often or rarely as needed

A simple command

command CallMe [\left\ var left#] [\right\ var right#]
  if \left\ then
    print "left: " + left#.toString(".5")

  if \right\ then
    print "right: " + right#.toString(".5")

Note the code shown doesn't have anything like END IF that other BASIC derivatives have. The indentation is all you need. If a parser of ASIL sees the indentation decrease, whatever control statement was current is required to end. So each if shown is a single statement. The command ends at the end of the sample.

You will also note that “\left\” and “\right\” are referenced inside the if statements. Those references evaluate to true if the caller used them and false if the caller skipped them.

Classic BASIC’s PRINT command implemented in ASIL

ASIL doesn’t really need a PRINT command as it would probably end up with a console object, but I’m showing it here so show how repeating options work. This is much more complex than CallMe in the previous example.

command PRINT [\newLine\] var Variant firstParam [(\;\ (\newLine\ | var Variant param))...parameters]
  if \newLine\ then
    console.print "\n"

  console.print firstParam

  parameters.foreach var ParameterPass curParameter 
    switch
      case curParameter.\newLine\ ’Because this keyword was part of a repeating parameter list, treat it as a member of curParameter
        console.print "\n"

        break;

      case curParameter.param <> null ’ Will be null if the pass was the \newLine\ keyword
        console.print curParameter.param

Some notes:

  • It assumes the foreach complex statement described in [Members and methods]
  • I'm also using that console object just mentioned to actually output the string
  • The presence of a toString function and the Variant type are assumed
  • What wasn’t mentioned in the table above was that the array (in this case, parameters), is an array of type ParameterPass
  • For the syntax of the switch statement, see [Switch statements].

Related

Wiki: Appendices-Terms-Declaration sequence
Wiki: Home
Wiki: Members and methods
Wiki: Origins
Wiki: Switch statements
Wiki: When is it a procedure, command, function, property, property accessor, method, complex statement, or type cast?
Wiki: keywords-class
Wiki: keywords-command
Wiki: keywords-interface
Wiki: keywords-switch
Wiki: keywords-throws