This chapter lists the global statements and procedures that form the core of the twinBASIC language.
Warning
Work in Progress Below
Categorical List
Compiler Control
- Option - configure a compiler option
- #If … Then … Else - enable or disable compilation of enclosed code
Declarations and Definitions
- Class, Module - define a class or module
- Sub - define a procedure
- Function - define a function
- Property - define a property
- Enum - define an enumeration type with associated constants
- Type - declare a user-defined data type (UDT)/a structure
- Declare - declare an external/library procedure or function
- Event - declare an event
- Implements - specifies that a class implements a given interface
- End - terminate execution, finish a Function, Sub, Property, or Enum definition, finish a Type declaration; finish a Class or Module, finish an If, Select, or With block
Flow Control
Statements:
- Call - invokes a procedure or function
- Do … Loop, For … Next, While … Wend - loops
- If … Then … Else - execute code conditionally
- Continue - skip to the next iteration of the loop
- Exit - exit a loop, procedure, function or property
- Select Case - execute a code block selected by an expression
- With - bring a variable or expression into scope
- Goto, GoSub … Return - transfer execution to another location
- Resume - resumes execution after an error has been caught
- On Error - specifies what to do when an error occurs
- On … GoTo, On … GoSub - transfer execution to a location selected by an expression
- Stop - interrupt execution
See also:
- End - terminate execution.
Variable Declaration
Statements:
- Dim - declare a typed scalar or array variable
- Const - declare a constant
- Public - declare a public variable in a class or module
- Private - declare a private variable in a class or module
- Static - declare a a variable of static duration
See also:
Variable Assignment and Modification
Statements:
- Let - sets the value of a variable
- Set - changes the object referred by the variable
- Erase - fills a fixed-size array with default values, or invalidates a dynamic array
- LSet - assigns a user-defined type, or left-aligns a string
- RSet - right-aligns a string
- ReDim - change the size of a dynamically-sized array,
File I/O
Statements:
- Open, Close - open/close a file for I/O operations
- Get, Put - read/write data from an open random access file
- Line Input, Print - read/write a line from/to an open text file
- Input, Write - read/write data from an open sequential access file
- Seek - change the current access position in an open file
- Lock, Unlock - lock/unlock a range of records in an open file
Procedures:
- Reset - close all open disk files
- Width - set the limit for line lengths when printing
- ChDir, ChDrive - change the current working directory and disk drive
- MkDir, RmDir - create/remove a directory on disk
- Name - rename a file or directory on disk
- SetAttr - set attributes of a file on disk
- FileCopy - copy a file on disk
- Kill - delete a file from disk
- SavePicture - write a
PictureorImageto a disk file
State Management
Procedures:
- Load, Unload - load/unload a form or control into memory
- GetSetting, SaveSetting - retrieve/store a string value from/to the system registry
- DeleteSetting - remove value from the system registry
Events and Interaction
Statements:
- RaiseEvent - raise an event that may be handled by event handlers
See also
- Event - declare an event
Procedures:
- AppActivate - change the focus to, or activate, a named window
- Beep - sound a system beep
- SendKeys - send keystrokes to the active window
Mathematics
Procedures:
- Atn, Cos, Sin, Tan - trigonometric functions
- Sqr - take a square root
- Exp - calculate an exponential with base $e$
- Log - calculate the natural (base $e$) logarithm of a number
- Sgn - return the sign of a number
- Abs - returns the absolute value of a number
- Round - round the number to a given number of decimal places
- Rnd - generate a random number in the range [0.0, 1.0)
- Randomize - seed the random number generator
String Handling
Statements that modify strings:
Procedures that check properties of strings:
- Len$, Len, LenB$, LenB - the length of a string
- Asc, AscB, AscW - returns the character code of the first letter in a string
- StrComp - compares two strings
- InStr$, InStrB, InStr - finds the position of a given substring in a string
Procedures that create strings:
- Chr$, Chr, ChrB$, ChrB, ChrW$, ChrW - returns the character having a given code
- Space$, Space - return a string of spaces
- String$, String - return a string of specified characters
Procedures that return modified strings:
- Left$, Left, LeftB$, LeftB - extract a left substring of a string
- Mid$, Mid, MidB$, MidB- extract a substring of a string
- Right$, Right, RightB$, RightB - extract a right substring of a string
- LTrim$, LTrim, RTrim$, RTrim - removes leading/trailing spaces from a string
- Trim$, Trim - removes leading and trailing spaces from a string
- StrReverse - reverses the order of characters of a string
- LCase$, LCase, RCase$, RCase - capitalizes or lowercases a string
- StrConv - converts the string to a specified format
- Join - concatenates a string array using a given delimiter
- Split - splits a string into a string array
- Replace - replaces substrings in a string
- Filter - filters a string array into a subset according to criteria
- InStrRev - filters a string array into a subset according to criteria
- Format$, Format - format a numeric expression in a specific way
- FormatNumber - formats an expression as a numeric string
- FormatPercent - formats an expression as a percent string
See also:
- FormatCurrency - format an expression as a currency string
- FormatDateTime - formats an expression as a date/time string
Date and Time
Procedures:
- Date, Time - set the current date and time
- FormatDateTime - formats an expression as a date/time string
- MonthName - returns the name of the specified month
- WeekdayName - returns the name of the specified day of the week
Financial
Procedures:
- DDB - depreciation of an asset via the Double-Declining Balance method
- FV - future value of an investment with constant deposits and interest
- Pmt - payment for a loan with constant payments and interest
- IPmt - interest payment for a loan with constant payments and interest
- PPmt - principal payment for a loan with constant payments and interest
- SYD - sum-of-years’ digits depreciation of an asset
- SLN - straight-line depreciation of an asset in one period
- PV - present value of investment
- IRR - internal rate of return for a series of cash flows
- MIRR - modified internal rate of return for a series of cash flow
- Rate - interest rate per period of an annuity
- NPV - net present value of an investment
- NPer - number of periods for an investment with constant deposits and interest
- FormatCurrency - format an expression as a currency string
Deprecated
Statements:
- DefBool, DefByte, DefInt, DefLng, DefCur, DefSng, DefDbl, DefDec, DefDate, DefStr, DefObj, DefVar - used to give implicit types to single-letter variables
- Error - raise an error