Aristar, Inc.Dialect Language ReferencePage 1
Dialect Language Reference
Aristar, Inc.
302 N. Cleveland-Massillon Road
Akron, OH 44333
330-668-2267
Dialect Language Reference Index
Introduction to Dialect
Different Versions of Dialect
Dialect Standard
Dialect Professional
Technical Support for Dialect
Miscellaneous Details
Chapter 1—Data Types
Chunks
Functions
Classes
Class Instance
Properties
Chapter 2—Expressions
Chapter 3—Statements
Assignment
Array Style Assignment
Break
Continue
Debug
For..EndFor
ForEach..EndForEach
If…<ElseIf...Else>...EndIf
Import
Interpret
Local
Return
Run
Throw
Try..<Catch..Finally>..EndTry
While..EndWhile
With..EndWith
Chapter 4—Core Functions
Chapter 5—File Handling
File class members
File class static members
Chapter 6—Scripts and Modules
Run
Import
Outputs Module
Exceptions Module
Throw
Try..<Catch..Finally>..EndTry
Crypto Module
MD5 Class
SHA1 Class
Blowfish Class
DiffieHellman Class
Socket Module
Socket module functions
Socket class members
Math Module
System Module
System Module Functions
Sleep(milliseconds)
ParseTime(dateTimeString)
Createdate$(year, month, day, hour24, min, sec)
CompareTime(dateTime1, dateTime2)
Exec(filename, <bWait>)
Status(processID)
Ticks()
Seconds()
PlaySound(filename, <bSync>)
OpenRegKey(keyString, bCreateOK)
Regkey(keyString)
The Regkey class methods
ComPort Class (serial port access)
DLL Class
ADO Database Module
The Connection Class
The Recordset Class
The Fields Class
The Field Class
Predefined ADO Constants
ObjectStateEnum (Not under WinCE)
CursorTypeEnum
LockTypeEnum
CommandTypeEnum
AffectEnum (not under WinCE)
PositionEnum
SearchDirectionEnum (not under WinCE)
StringFormatEnum (not under WinCE)
Bookmarks (not under WinCE)
RecordStatusEnum (not under WinCE)
DataTypeEnum
GUI Module
GUI Module Functions
Enter()
Exit()
ScreenRect()
MsgBox(window, message, title, mbType)
MousePos(<window>)
PopupMenu(window, x, y, menuArray)
FileOpenDlg(parent, filename, ext, types)
FileSaveAsDlg(parent, filename, ext, types)
GUI Module Classes
Window(text, rect, <optionsFrame>)
Button(parent, text, rect, <optionsFrame>)
Calendar(parent, initDate, rect)
CheckBox(parent, text, rect)
ComboBox(parent, rect, <optionsFrame>)
Edit(parent, text, rect, <optionsFrame>)
Grid(parent, rect, numRows, colWidthsArray, <optionsFrame>)
Layout(parent, rect, layoutFrame, dataFrame, <optionsFrame>)
Listbox(parent, rect, <optionsFrame>)
Menubar(parent, rect, menuArray, <optionsFrame>)
Note(parent, text, rect, <optionsFrame>)
Pane(parent, rect, <optionsFrame>)
Radio(parent, text, rect, <optionsFrame>)
Scrollbar(parent, bHorz, rect, rangeMin, rangeMax, pageSize)
Chapter 7—Regular Expressions
Regex class members
Using regex.replace()
Using regex.match
Chapter 8—Trouble Shooting and Your IDE
Things to Avoid
Recursive data structures
Invoking a “non-static” class member function by calling directly into the class (i.e. not calling from a class instance)
Invoking class member functions after a class (or class instance) has been garbage collected
Integrated Development Environment Overview
Debugging
Making executables
Sample Scripts
GUI Calendar Sample
GUI POP3 Email Reader
Sending Email via SMTP
Double Echo Socket Server
Simple Text File Editor
Date/Time Parser Using Regular Expressions
QuickForm - Displaying Layouts
ADO Rolodex Sample
Introduction to Dialect
The Dialect language originated as a version of the Basic language. The Basic roots give Dialect a simple to learn syntax and a good set of basic functions. For example, to print some text you might code something like:
print "Hello world"
To print the numbers from one to ten, you could write:
for x = 1 to 10
print x, cr
endfor
In the above example cr stand for carriage return, telling the print statement to start a new line of text.
To the Basic core we added special features to make it capable of handling database and data processing tasks. For example, to record information about John Doe you could do the following:
johnDoe = {age:27, eyeColor:"Brown"}
Later, if you need to print John Doe‘s age:
print "John Doe is ", johnDoe.age, " years old"
Or, you could store the information in a text file:
file.save("JohnDoe.txt", johnDoe, 'ascii)
You could then read back the information at a later time:
johnDoe = file.load("JohnDoe.txt")
Because of its simplicity, Dialect is extremely useful for writing small utility programs. Of course, sometimes you need more than just a simple utility program. For that reason, Dialect also supports advanced programming techniques such as functions, external modules, object-oriented classes, and regular expressions.
Dialect currently runs under Windows 9x/NT and Windows CE 2. A modified version of Dialect, sans a few features, has been compiled under Linux and might be made available at a later date.
Different Versions of Dialect
This reference document describes the complete Dialect language in its current state. There are, however, several versions of Dialect. Some of these versions lack certain features as described below.
Dialect Standard
Dialect Standard does not contain the ADO database module. Dialect Standard is free for personal, academic, and other not-for-profit uses.
Dialect Professional
Dialect Professional contains all the functionality described in this reference. Demo versions of Dialect Professional may not contain the ability to generate stand-alone executables. Also, appropriate licenses must be purchased to use Dialect Professional in a commercial environment and to create commercial applications (including shareware).
Technical Support for Dialect
Dialect is written and maintained by Aristar, Inc. Technical support is currently handled via email using the following address:
As time passes and as necessity dictates, we plan to support FAQ sheets accessible from our web site:
Miscellaneous Details
- Dialect is case insensitive with regard to keywords and identifiers; thus:
MyFrame = myframe = MYFRAME
- The end of line (i.e. carriage return) is significant and expected at the end of every statement. The backslash character, \, may be used to continue the current line on the next line. The backslash character must be immediately followed by an end of line (by hitting ENTER or RETURN). Thus not even comments may follow a backslash character.
OK: x = 5 + 6 + 7 + \
8 + 9 + 10 # Adding some numbers
ERROR: x = 5 + 6 + 7 + \ # Adding some numbers
8 + 9 + 10
- Programmers familiar with C/C++ should note that memory management is accomplished with automatic garbage collection, relieving the programmer of the chore. When data is no longer referenced by any variable, Dialect frees the memory of that data. If the data is a class instance, then Dialect first calls the destructor for that class (i.e. the __del__ function) if it exists.
- A frame called global is shared by all modules and can be used to store common data. For example, Dialect places some environment data in global.__environ__. So to display a dialog box giving the version of Dialect, you could use the following code:
message(global.__environ__.version)
- To execute a script from the command line, use the -run flag followed by the name of the script. For example:
Dialect.exe -run D:\scripts\myScript.d
In the event the script path or filename contains spaces, then be sure to surround the name in double-quotes.
- Comments are notes a programmer leaves for himself in the code for future reference. When the time comes to modify a piece of code, and it will, without comments the programmer must reread every single line to find the line which needing modification. Dialect allows three types of comments:
- Block comments may span multiple lines of code. Like block comments in the C language, a block comment begins with /* and ends with */.
- Line comments tell Dialect to ignore everything to the right of the // comment marker, up to the end of line. This works the same as the C++ line comment. The # symbol may also be used to mark the beginning of a line comment.
- Persistent comments are designed to survive compilation and serialization, unlike block and line comments that are removed during normal compilation. Persistent comments must be the only item on a line of code and are signified by two leading backward slashes, \\, not to be confused with the line comment which uses two forward slashes.
Chapter 1—Data Types
In Dialect, all information can be classified as belonging to one of two data types divided according to how they are held in memory. “Pass by Value” data types enjoy a simple one-to-one relationship between variables and their contents. “Pass by Reference” data types identify a reference point which in turn identifies other sources of information.
Pass by Value / Integer / 5Floating Point / 3.14159
Boolean / true, false
String / "Hello World"
Pass by Reference / Array / ["hello", "world", 5]
Frame / {key:"Value", x:42}
Symbol / 'Fruit
Chunk / [:{encoding:"hex"}, "2DF4587E":]
Function / F = func(<ArgsDecl>)
<StatementBlock>
endfunc
Class / Class Ident <(BaseClass)>
<MemberDecls>
EndClass
Class Instance / X = myClass(<ConstructorArgs>)
Special / Void / nil
Property / P = prop(init, readFunc, writeFunc)
Note that Elements within are optional.
Data is stored in named symbol tables. Only three forms of symbol table are possible for the resolution of a variable: module/script,class object, and function. Generally speaking, Dialect can not look outside a specific environment to resolve a variable. Thus a function could only see variables local to itself, local to the module in which it was declared, and local to its parent class if it belongs to a class object. Moreover, if a function is declared within another function, it will not see the encapsulating function’s local symbol table.
Integers
Integers are 32-bit signed numbers, the ones we learned to count with stones or cows. When evaluated as a Boolean value, zero returns false and all other values return as true.
Floating Points
Dialect uses IEEE 32-bit floating-point numbers, that is a string of numbers containing a single decimal point. All floating-point numbers must have at least one digit to the left of the decimal point. That digit may be zero (0). When evaluated as a Boolean value, 0.0 returns false and all other values represent true.
Boolean
The keywords true and false are used to represent the two Boolean states. In Boolean logic, a thing either “is” or “is not,” the binary condition essential to digital existence.
Strings
A string may hold zero or more characters and is defined using quotation marks as in:
x = "This is a string"
Two strings can be added using the + operator. The length of a string equals the number of characters in the string and can be determined using the len() function (see Core Functions). Individual characters of a string are accessible using the bracket operator. To get the fifth character of a string and place it into the variable x, you could write x = myString[5]. To extract a range of characters from a string, use the range operator inside the brackets. Where a negative number in the range is interpreted as indexing from the end of the string to the front. To extract the substring containing the third through the fifth characters: x = myString[3 -> 5]. When evaluated as a Boolean value, the empty string returns false, while all other strings return true. When inside a double-quoted string expression, accent marks, `, are converted into quotation marks.
message("Say `Goodnight, Gracey`")
message("Goodnight, Gracey")
Arrays
Arrays hold zero or more elements and are designated by square brackets, [ ]. Elements are separated by commas. Each element can be of a different data type, including another array. The length of an array is equal to the number of elements it contains, which can be determined using the len() function. When evaluated as a Boolean value, arrays always return true. There are two methods of creating arrays.
Method one: x = ["a", "b", "c"]
Method two: x = array(3)
Elements of an array are accessed using the bracket operator. The first element in an array is at index 1, not zero. So to get the fifth element of an array you could write x = myArray[5], or to set it write myArray[5] = 23. Since a multi-dimensional array is simply an array of arrays, elements are accessed using multiple bracket expressions. If myArray is a two-dimensional array, you would get the value of row 6, column 2 in the following manner: x = myArray[6][2].
If you need to get a series of elements from an array, you can specify a range between the brackets using the range operator -> . For example, to get an array that contains the fifth, sixth, and seventh elements of an array, you could write x = myArray[5 -> 7]. If a negative integer is used in describing a range, it is interpreted as indexing from the end of the array to the front. So, myArray[4 -> -1] would return all the elements starting at the fourth and ending at the last.
Two arrays can be joined together to create a single larger array using the concatenation operator, ~
[1, 2, 3] ~ [4, 5, 6] results in the array [1, 2, 3, 4, 5, 6].
Frames
Frames store data by equating a string, which becomes the frame’s localized key, to a value. Thus a frame is essentially a storage system of key-value pairs, often called “hash tables” or “dictionaries”. A frame key must be a string (ex. x or myVariable), while the value can be of any data type. Frames are created using curly braces, {}. To set the variable x to an empty frame: x = {}. To create a frame with two initial key-value pairs, also known as slots, separate the values by commas (ex. myFrame = {age:27, eyeColor:"Brown"}, or, myFrame = {"age":27, "eyeColor":"Brown"}). Values are retrieved from a frame using either the dot or bracket operator. Thus both
x = myFrame.ageandx = myFrame["age"] yield the value 27.
If a key is referenced that doesn't contain a value, the result will be nil. Once a frame has been created, new slots can be added using the same operators: myFrame.hairColor = "Blonde", or, myFrame["hairColor"] = "Blonde". To completely remove a slot from a frame, use the remove function. For example: remove(myFrame, "hairColor")
Two frames can be combined using the concatenation operator. If a key exists in both frames, then the value contained in the right operand is used in the result. For example: {a:1, b:2} ~ {b:3, c:4} results in the frame {a:1, b:3, c:4}.
When evaluated as a Boolean value, all frames return true.
Symbols
A symbol is any valid identifier preceded by a single quote. For example, 'imaSymbol_123. Symbols are case insensitive.
Chunks
A chunk is a contiguous block of memory. It is similar to an array in concept, but is more efficient than an array when dealing with binary-type data. Chunks are declared using the [: and :] bracket symbols. Contained within the brackets must be a frame and a data item. The frame contains options for the chunk. The data item represents the data to be stored in the chunk. The frame may contain the following slots:
- encoding: If the data item is a string, then the encoding type tells Dialect how to convert the string into binary data. Whenever the chunk is represented as a string, using the str$() function for example, Dialect will convert the data into a string using the specified encoding type. The three currently supported types are "hex", "base64", and "ascii". If not specified, "base64" is used as the default since it is more efficient than hexadecimal.
- itype: Specifies the index type of the chunk. This is explained more thoroughly below. If not specified, the itype defaults to ui1 (an unsigned, one-byte integer).
- dim: Specifies the length of each dimension of the chunk. Currently only one-dimensional chunking is supported. Therefore, if specified, dim must be a positive integer. Dim is only required if the data item is nil, since Dialect will need to know how much memory to allocate. If not specified and the data item is not nil, then Dialect will allocate enough memory to store the decoded data item. The actual number of bytes allocated is the number of bytes required for the itype multiplied by the value provided for dim.
The data item used to construct a chunk can be one of the following types:
- string: If the data item is a string, then the encoding type given above is used to convert the string into binary data.
- chunk: If a chunk is the data item, then the returned item will be the same chunk except the options may be different. This is how to change a chunk from "hex" to "base64" encoding, for example.
- nil: If nil is given, then the chunk will be created with the size specified in the dim slot of the options frame and all its elements will be initialized to zero.
Elements of a chunk are accessed using the bracket operators. So to get the fifth element of a chunk and assign its value to x, you would write: x = myChunk[5]. An element of a chunk is a number. The type of number, and how many bytes of the chunk are used to determine the number, is dependent upon the chunks itype property. The following is the list of currently supported itypes: