Copyright: Copyright ® 1995, Greg Truesdell


Alphabetical Reference
Pseudo-Basic Alphabetical Language Reference

Close

Dim

FreeFile

For/Next

Goto

If/Then/Else/EndIf

Input

InputBox

InStr

Len

MessageBox

Open

Print

Result

String Functions

SubStr

Trim/LTrim/RTrim

UCase/LCase

While/WEnd


Close

Closes an opened text file.

Usage:

Close [#]<file-number>

Example:

See Open


Open

Opens a Text file

Usage:

Open <string-expression> For READ|WRITE as [#]<File-number>

Example:

Dim Name As String,
    File As Integer,
    OutFile As Integer

File = FreeFile
OutFile = FreeFile

Open "Work.Dat" for Write as OutFile
if Result <> 0 Then

  Log('Error creating Work.Dat!')
  SaveLog('Ooops.Log')
  Close OutFile

  End

EndIf

Open "Employee.Dat" for Read as File
if Result = 0 Then

  While Result = 0

    Input File, Name
    Print OutFile, Name

  WEnd

  Close File
  Close OutFile

Else

  Log('Error opening Employee.Dat')
  SaveLog('Ooops.Log')
  Close OutFile

EndIf


Dim

This keyword is used to dimension (declare) a variable.

Note:
This demo requires that variables be declared before used.  The Dim statement can be used at any time, but must logically preceed any statements that use the variable.

Usage:

Dim <variable-name> As <data-type>[, ....]

Data Types:

DATA TYPE	DESCRIPTION
Decimal	Decimal number in the range of 0 to (+/-) 1*10^38
Integer	An integer in the range of (+/-) 2.1 Billion
String	A character string containing 0 to 255 characters.
Example:

Dim
    Name As String,
    Age As Integer,
    Balance As Decimal


FreeFile

FreeFile is used to locate a free file handle for text files.  The Open/Close/Input and Print commands require a valid file handle.  There are only 14 file handles available.

Usage:

<integer-variable> = FreeFile

Example:

Dim File as Integer

File = FreeFile
Open "MyFile.Log" for Write as File
Print "What a sorry sight was he."
Close File


Default


Goto

This keyword is used to jump to a new location in the script.

Usage:

Goto <line-label>

If <relational-expression> Then Goto <label>

Synopsis:

Line labels are identifers that are alone on a line followed by a colon.  Obviously, the line label must exist or an error is generated.

Example:

#
# Goto Example
#

Open 'MyFile.Dat' for Read as #1
if Result <> 0 then Goto Error
Close #1
End

Error:
MessageBox('oops')
End


IfEndIf
If .. Then .. Else .. EndIf

Program control.

Important Note:
Relational expressions can not be surrounded by "(" and ")" in this version of TBasicInterpreter.  Expressions are parsed from left to right in simple form. For example:

If Name = "SMITH" and not Age > 40 Then ....

This expression is evaluated left to right.  It is TRUE if Name = "SMITH" and Age is not greater than 40.

Usage:

If <relational-expression> Then
  ...
[Else
  ...]
EndIf

Example:

If Amount < 100 Then
  MessageBox('Not enough.')
Else
  MessageBox('Approved.')
EndIf


Input
Input (Text File)

This command is used to input a line of text from a text file.  String variables are normally used, but if the file was saved as a list of numbers, a numeric variable will be accepted.

Usage:

Input [#]<file-handle>, <variable>

Example:

Dim Line as String

Open 'MyData.Dat' for Read as #1
If Result = 0 Then
  Input #1, Line
  Close #1
  MessageBox( Line )
Else
  MessageBox('File Open Error!')
EndIf


InputBox

This function is used to prompt the user for data.

Usage:

<variable> = InputBox(<prompt>[,<title>[,<default>]])

Example:

Dim Name as String

Name = InputBox('What is your name?')


InStr

Returns the position of a sub-string in a string.

Usage:

InStr(<start>,<source-string>,<search-string>)

Example:

# displays "5"
Messagebox( InStr(1,'The Moon is Green','Moon'))


Len

Returns the length of a string expression.

Usage:

Len(<string-expression>)

Example:

# returns 25
length = Len('All the world is a stage.')


MessageBox

Displays a message in a dialog and returns the number of the key pressed.

Usage:

[<numeric-variable> =] MessageBox(<string-expression>)

Example:

Dim Key as Integer

Key = MessageBox('Continue?')
If Key = 1 Then
  MessageBox('Ok Button Pressed')
Else
  MessageBox('Cancel Button Pressed')
EndIf


Print

Used to print a line of text to a text file.

Usage:

Print [#]<file-number>

Example:

See Open


Result

This variable is updated after any Open, Close, InputBox, Input, Print or MessageBox statement.  It contains the result code resulting from the execution of the statement.


String Functions

Set of functions that provide string manipulation functions.

SubStr

InStr

Len

Trim, LTrim and RTrim

UCase/LCase


SubStr

Returns a section of a string.

Usage:

SubStr(<string-expression>, <start>, <length>)

Example:

# displays "Moon" in the message box
MessageBox(SubStr('The Moon is Green',5,4))


Trim
Trim, LTrim and RTrim

Trims spaces surrounding, from the left or the right of a string.

Usage:

Trim(<string-expression>)

Trim spaces from left and right side of the string.

LTrim(<string-expression>)

Trim spaces from the left side of the string.

RTrim(<string-expression>)

Trim spaces from the right side of the string.

Example:

# all examples return 'Hello'
Trim('       Hello      ')
LTrim('      Hello')
RTrim('Hello       ')


UCaseLCase
UCase and LCase

Returns the Uppercase or Lowercase form of a string.

Usage:

<string_var> = UCase(<string_expr>)
<string_var> = LCase(<string_expr>)

Example:

Dim Name As String

Name = InputBox('Name?','Input Required')
If Result = True Then
  MessageBox('Name:'+UCase(Name))
EndIf


WhileWEnd
While .. WEnd

Looping control construct.  This construct executes the lines between the While and WEnd statements until the relational expression is false.

Usage:

While <relational-expression>
  ...
  ...
WEnd

Example:

See Open


Contents
TBasicInterpreter Demo Component

Sample application of TScriptParser.

Copyright © 1995,  Greg Truesdell

Language Reference


ForNext
For..Next

Program control.  Note that the Next statement does not accept a control variable.  The TBasicInterpreter Component know which loop is next.

Usage:

For <control_variable> = <numeric_expr> to <numeric_expr>
...
...
Next

Example:

Dim Counter As Integer

For Counter = 1 To 4
  MessageBox('Counter is now '+Counter)
Next


Index

A

Alphabetical Reference

C

Close

Contents

D

Dim

F

ForNext

FreeFile

G

Goto

I

IfEndIf

Index

Input

InputBox

InStr

L

Len

M

MessageBox

O

Open

P

Print

R

Result

S

StringFunctions

SubStr

T

Trim

U

UCaseLCase

W

WhileWEnd