Home

TOTVS Technology

Child pages
  • Data Type
Skip to end of metadata
Go to start of metadata

With the purpose of using expressions, each AdvPL data is identified as one specific type. This way, each variable, constant, function or table field is associated with a type of data, and will depend on how each of these items was created. For example, a variable varies according to the value stored on it, a function varies according to the value assigned to it and a field varies according to the data table structure related.

Types of data available in AdvPL language are:

  • Character
  • Memo
  • Date 
  • Numeric 
  • Logic
  • NIL (absent) 
  • Array
  • Block of Code

 

Character

 

When values stored create strings of a specific size, made by numeric digits (0 - 9), alphabetic letters (a - z or A - Z) or special symbols (@, +, *, -, /, %, $, &, etc.), we call character.

This data is made by a string from zero to 65,535 (64 Kbytes) characters of ASCII table. A complete set of AdvPL character corresponds to ASCII 0 code (nil), 32 to126 (printable characters) and 128 to 255 (graphic characters).

Values or constants stored are limited by a pair of delimiters (open and close): quotes (" ") or apostrophes (' ').

The empty value for this type of data is ASCII 0 character (nil). To represent it, two adjacent delimiters are used, it means, "" or ''. Character is grouped according to the code value of ASCII Table.

Examples of character:

 

"AdvPL is a powerful programming language."

"The interest rate is 0.99 % monthly, conditioned to a minimum installment value of R$ 100.00."


Memo

Memo is equal to a character. The single difference is that memo has no specific size. This feature is possible as this type of data is saved in data files.

The code, which identifies memo, is saved in the information master data file: Customer, Supplier File, etc. This identifier code holds 10 positions and is responsible for identifying the information content saved in SYP data file.

In AdvPL, the standard function MSMM() is responsible for saving and recovering memo.

This type of data is important when some information cannot be limited to a specific size. For example, notes, reports, etc.

 

Date

This type of data represents the dates of a calendar and enables different operations such as, the difference between two dates in number of days and a new date after a sum or subtraction by a specific number of days.

This data stores values with 8 positions, made by 6 numeric digits from 0 to 9, bisected by bars "/", in 99/99/99 format.

In order to define a date, the use of CTOD() function is mandatory. It changes a character into a date. For example:

 

// Deals with dates in day/month/year format 
dNascim:= CTOD("14/05/12")

 

Excepting fields type date of data tables, the single way of defining a date is by function CTOD(). Both American and Brazilian formats are represented as follows:

The symbol dd represents the day. Depending the month, this must be between 1 and 31. The symbol mm represents the month. This must be between 01 and 12.

The symbol yy represents the year century. This must be between 00 and 29. The symbol yy represents the year. This must be between 00 and 99.

In Database, the storage of dates is made in a text format: ssaammdd. The interface software between Protheus and Database, called Top Connect, converts this text information into date according to Protheus configuration, when the application needs the information.

In Protheus, the displaying of a date is configured into an American format, represented by symbols mm/dd/yyyy or mm/dd/yy, or into a Brazilian format, represented by dd/mm/yyyy or dd/mm/yy.

As a standard, AdvPL works with dates of the twentieth century, not mentioning its indication, it means, the century indication, represented by yy, is not displayed.

In order AdvPL to accept it, a date must be a valid date and range between 01/01/0100 and 31/12/2999. An empty value for a date is a blank or empty date and represented by CTOD(""), CTOD(SPACE(8)) or CTOD("/  ") commands. CTOD function only accepts valid dates as an argument. If an invalid date is displayed as an argument, the command will convert it into a nil date.

Examples of invalid dates:

32/12/2012

23/13/2012

23/12/0099

29/02/2012

 

Numeric

When some data holds only numbers from 0 to 9, signs + (plus) or - (minus) and the decimal point, we call number. This type of data is used in math calculations.

Through this type of data, AdvPL is able to process numeric values between 10-308 and 10,308. Data file can store numeric data up to 32 positions (30 numbers, sign + or - and the decimal point), up to 16 decimal places of guaranteed accuracy. Therefore, we can have a number with 32 positions, without decimal places, up to the number of 15 positions, the decimal point and 16 decimal places.

Numeric data cannot be limited by any symbol. Otherwise, it will be considered as a character. The empty or nil value, for some numeric data, is a nil value (0).

A numeric value in AdvPL follows the American format: the decimal point is represented by a point (.) and the division of the integer values made by a comma (,). These are some examples based on the amount of money:

 

Examples:

43.53 (forty three reais and fifty three cents)

0.05 (five cents)

1,000,000.00 (a million)

1.815 (one real and eight hundred and fifteen thousandth)

 

 

However, when displaying the information to the user, on the screen or a report, you are able to convert the numeric value into a Brazilian format, where decimal point is represented by a comma (,) and the division of integer values is made by a point (.). Let's see the same examples above in a Brazilian format:

Brazilan format examples:

43,53 (forty three reais and fifty three cents)

0,05 (five cents)

1.000.000,00 (a million)

1,815 (one real and eight hundred and fifteen thousandth)

 

 

Logic

 

Logic represents only two possibilities, they are called Boolean values: false or true. Content can only be:

.Y. or .y. (Yes or Sim)

.N. or .n. (No or Não)

.T. or .t. (True or Verdadeiro)

.F. or .f. (False or Falso)

 

Logical data is mandatorily limited by points, and represents the data delimiters called character. For example:

lReturn:= .T.       // True
lReturn:= .F.      // False

 

NIL

NIL enables the manipulation of variables declared, but not started by a specific value. The representation of this type of data is the acronym NIL, without delimiters.

You can interpret NIL as lack of data. When a value is not assigned to a variable, array, array element or function parameter, AdvPL will assign a NIL value automatically.

The single class of variables, where nil value cannot be assigned, is data table fields.

 

Array

In AdvPL, matrices and vectors are considered as type of data, as one matrix can be assigned to a variable, supplied by a function or passed as an argument. A reference is the computer memory address where a matrix is found. Due to the number of details, we will deal with this type of data in the "Array" document.


Code Block

They are pieces of compiled codes that, as arrays, are considered as a type of data, as a reference to a block of code is assigned to a variable, supplied by a function or passed as an argument. A reference is an address of the computer memory where a block of code is found. Due to detailing, this type of data will be found in "Block of Code" document.

  • No labels