MaxScript supported Data Types

Table fields

MaxScript supports natively DBF data tables.

DBF tables reside on disk and are structured in fields of fixed lenght. Lenght depends by the data type:

Field type

Code

Max Lenght

Use for

CHAR

C

Up to 254 chars (ASCII)

Strings

NUM

N

9 digits

Numbers

LOGIC

L

1 digit

Boolean values Y or N

MEMO

M

Limited by host memory or 1 Gigabyte (it contains only a 10 digit pointer to an external DBT file that actually contains the data)

Strings

DATE

D

8 or 10 chars representing a date in format DD/MM/YY

Calendar dates

Fields Naming Rules

Example of a table structure:

Table: SITE_USERS Position on disk: c:\dbfree\db\samples

Name

Type

Size

Decimals

Sample of content

USR_NAME

C

35

0

JOHN123

IP_ADDR

C

15

0

192.168.12.158

LAST_LOG

D

8

0

12/06/10

LAST_TIME

C

8

0

11:05:27

PAYD

N

6

2

1.50

ACTIVE

L

1

0

Y

INTRO_MSG

M

10

0

Welcome back John, we are happy to see you again here. <br> There are no new messages in you mail box <br> Please select an option from the menu below <hr>

Tables can be created using DBFree utilities, programmatically or using third party tools.

DBFree offers it own implementation of indexes (MTX) for DBF tables. For further informations see the appropriate publication.

Data Types for variables

MaxScript supports 5 data types for variables:

Character ( C)

Numeric (N)

Date (D)

Logic (L)

Arrays (A)

MaxScript is also supporting Arrays (mono and multidimensional) but they are not native data types and must be mapped into one of them during calculations. Arrays can not be stored on disk and can exist only in memory during program execution.

Data type conversion

Each data type can be converted into another by using the appropriate conversion functions.

String to numbers

Converting string to numbers is easy, using the function val(cString)

Example 1:

cString := "21”
nnn := val(cString)  //-- results is the number 21

Example 2:

cString := "Mark Twain”
nnn := val(cString) //-- result is number zero 

Example 3:

cString := "Cadillac 1956 pink”
nnn := val(cString) //-- result is number 1956

Numbers to string

Converting numbers to string is even simpler, and can be done with greater flexibility using the function str(nNumber, nLenght, nDecimals, cFiller).

Example 1:

nnn := 112,62
cString := str(nnn) //-- result is "112”

Example 2:

nnn := 112,62
cString := str(nnn,2) //-- result is "11”

Example 3:

nnn := 112,62
cString := str(nnn,5) //-- result is "  112”

Example 4:

nnn := 112,62
cString := str(nnn,5,0,”0”) //-- result is "00112”

Example 5:

nnn := 112,62
cString := str(nnn,3,1) //-- result is "112,6”

Example 6:

nnn := 112,62
cString := str(nnn,3,2) //-- result is "112,62”

Example 7:

nnn := 112,62
cString := str(nnn,6,2,”A”) //-- result is "AAA112,62”