Command String

From Liberty BASIC Family
Jump to navigation Jump to search
Supported in Just BASIC Supported in Liberty BASIC Not supported in Liberty BASIC 5 Not supported in Run BASIC

Description

Command strings are used to issue commands to windows or controls.
To use:
Help ⇒ Sending Commands - two forms, with PRINT and without, link to Print - use with GUI
Help ⇒ Understanding Syntax - inserting variables in command string, preserving spaces

Syntax

There two ways to send commands (and text) to windows or controls. Windows or controls are identified by their Handle.
Old syntax, with PRINT (PRINT #handle, "command string")
The new syntax, allows us to drop the operator PRINT and the comma after handle (#handle "command string"):
  1. print #txtWin, "The fox jumped over the dog."
  2. #txtWin "The fox jumped over the dog."
Both ways work identically.

Hints

Some command strings contain numbers, e.g.
print #win, "box 30 221"
If we want to use variables instead of literal numbers, we should insert them so PRINT receives the same resulting string. That means preserving spaces:
x = 30
y = 221
print #main, "box ";x;" ";y
(If spaces are not included,
print "box";x;y
will result in Liberty BASIC seeing "box30221", which will not work.
print "box ";x;" ";y
will result in right thing: "box 30 221"
)
We can use the new form (without PRINT and comma). Internally it works the same way, so spaces should be preserved.
Some controls accept text. In that case, the command string should begin with an exclamation mark (!). For example, in this case
    #main.button1 "!disable"
    #main.button2 "disable"
button1 would understand the command and became disabled, while button2 would receive the text and change its caption (text on a button) to "disabled".

Example

' Place a simple, working example of the keyword here

Useful Procedures

' Place a useful function using this keyword here