Language Core Definitions

Top  Previous  Next

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.

Variables

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 labtalkrun and watch the output tab:

labtalk6

Arrays

Arrays don't have to be declared as to type or number of elements. They all could be integer, float or string.

myarray[0] = 10

myarray[1] = 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[6]

The printed result is of course 20.

Expressions

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.

String operations

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

Comments

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

*/

Language.

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

Commands

Syntax example

Description

for to next

for x=1 to 10

...

next x

loop, can be nested

if then else endif

if (x==0) then

.....

else

......

endif

condition, can be nested

print

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

Defined functions

Functions

Syntax example

Description

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"

sin

a =sin(3.14)

Sine

cos

a =cos(3.14)

Cosine

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)

GETR

GETG

GETB

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 functions

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

Predefined Values

TRUE

FALSE


1

0

NULL


0