LabTALK is an interpreter language based on the BASIC language. The task of this document is not to teach BASIC, but rather to point out the similarities and differences between it and LabTALK. Therefore the documents below assume that you have some general programming knowledge.
LabTALK can work with integer, float and string variables. There is no forward declaration of variables like in advanced languages (C, or Pascal..) The variable becomes the type as soon as you assign a value to it for first time.
a = 10
will create integer variable 'a'
b = 10.5
will create float variable 'b'
name = "Hello!"
will create string variable 'name'. If you need to enter '\' you need to do it like in the C language with double '\\'
file = "c:\\myfile.txt"
You can create your very first program quite easily:
string = "Hello!" print string
Then hit the Run button and watch the output tab:
Arrays don't have to be declared as to type or number of elements. They all could be integer, float or string.
myarray = 10 myarray = 20
Arrays in LabTALK can go even to negative:
myarray[-1] = 10
is still valid. In fact you can mix various types within one array - but of course this is not advised and is of little benefit.
The array index may be a constant, another variable or an expression. See the code below:
a = 5 myarray[a] = 10 myarray[a+1] = 20 print myarray
The printed result is of course 20.
LabTALK has fully developed integer and float expressions.
b = 3 a = 3 + 2 * 5 + 4*(10+b*(23+b)) print a
The result is 365. You can use expressions directly in any function.
LabTALK can use various string operations as well. See the code below:
c = "Os"+"car" str = "Hello"+ CHR(32) + c + "!" print str
Result is: Hello Oscar
Everything in a line after // is deemed to be a comment
menu = MenuGetCurSel() // VTS menu 1..255, VMG menu 10001..10255
Whole line can be just a comment
// ****** The loop starts here ********
You can comment block of the text with /* and */
/* This text is just a comment It will never run
The whole language can be divided into two parts. One are commands of the basic language - the definition of the language. The other part are functions that are specific to DVD-lab.
CORE of language
|for to next||for x=1 to 10
|loop, can be nested|
|if then else endif||if (x==0) then
|condition, can be nested|
|print "Variable ", a, "Other Variable ", b||print to Output window or if run directly show a message|
|print msg||print msg "Variable ", a||always show a message|
|trace||trace "Variable ", a||print only to output window, if run directly nothing is shown (good for debugging)|
|input||input "Enter value", a||Input box for multiple parameters|
|end||End of the script|
|goto||goto 100||got label 100|
|gosub||gosub 100||goto subroutine label 100|
|return||return from subroutine|
|RND||a = RND(5)||random value 0...5|
|INT||a = INT(b)||integer value from float|
|FLOAT||a = FLOAT(b)||create float from integer|
|CHR||c = CHR(32)||generates character from ascii number (32 is space for example)|
|ABS||a = ABS(b-5)||absolute value|
|STR||c = STR(5)||Convert integer number to string. In our example the C will become c= "5"|
|MIN||a = MIN(b,c)||minimum value from two parameters|
|MAX||a = MAX(b,c)||maximum value from two parameters|
|RGB||color = RGB(255,0,0)||color value from red, green, blue components (in our example result is red color)|
|red = GETR(color)||Get red, green or blue component from color value|
|VMG||firstVMGmenu = VMG(1)||adds 10000 to the parameter. For menu coding, see more <a href="lt_commands.htm">functions</a>|
|LEFT||string = LEFT(input, x)||gets first x character from left of the input string|
|RIGHT||string = RIGHT(input, x)||gets first x character from right of the input string|
|LOW||string = LOW(string1)||convert the string to lowercase|