Bookshelf Home | Contents | Index | Search | PDF |
Siebel eScript Language Reference > Siebel eScript Language Overview > Data Types >
Primitive Data Types
Variables that have primitive data types pass their data by value. If an argument is passed by value, the variable used for that argument retains its value when the subroutine or function returns to the routine that called it (the caller). The following fragment illustrates:
var a = "abc";
var b = ReturnValue(a);
function ReturnValue(c)
{
return c;
}After
"abc"
is assigned to variablea
, two copies of the string"abc"
exist, the original literal and the copy in the variablea
. While the functionReturnValue
is active, the parameter or variable c has a copy, and three copies of the string"abc"
exist. Ifc
were to be changed in such a function, variablea
, which was passed as an argument to the function, would remain unchanged.After the function
ReturnValue
is finished, a copy of"abc"
is in the variableb
, but the copy in the variablec
in the function is gone because the function is finished. During the execution of the fragment, as many as three copies of"abc"
exist in memory at one time.The primitive data types are number, Boolean, and string.
Number
The number data type includes integers and floating-point numbers, which can be represented in one of several ways.
NOTE: Numbers that contain characters other than a decimal point are treated as string values. For example, eScript treats the number 100,000 (notice the comma) as a string.
Integer
Integers are whole numbers. Integer constants and literals can be expressed in decimal, hexadecimal, or octal notation. Decimal constants and literals are expressed by using the decimal representation. See the following two sections to learn how to express hexadecimal and octal integers.
Hexadecimal
Hexadecimal notation uses base 16 digits from the sets of 0-9 and A-F or a-f. These digits are preceded by 0x. Case sensitivity does not apply to hexadecimal notation in Siebel eScript. Examples are:
0x1, 0x01, 0x100, 0x1F, 0x1f, 0xABCD
var a = 0x1b2E;The decimal equivalents are:
1, 1, 256, 31, 31, 43981
var a = 6958Octal
Octal notation uses base 8 digits from the set of 0-7. These digits are preceded by a zero. Examples are:
00, 05, 077
var a = 0143;The decimal equivalents are:
0, 5, 63
var a = 99Floating Point
Floating-point numbers are numbers with fractional parts that are indicated by decimal notation, such as 10.33. Floating-point numbers are often referred to as floats.
Decimal
Decimal floats use the same digits as decimal integers but use a period to indicate a fractional part. Examples are:
0.32, 1.44, 99.44
var a = 100.55 + .45;Scientific
Scientists often use scientific notation to express very large or small numbers. It uses the decimal digits in conjunction with exponential notation, represented by
e
orE
. Scientific notation is also referred to as exponential notation. Examples are:4.087e2, 4.087E2, 4.087e+2, 4.087E-2
var a = 5.321e33 + 9.333e-2;The decimal equivalents are:
408.7, 408.7, 408.7, 0.04087
var a = 53210000000000000000000000000000 + 0.09333Boolean
Boolean variables evaluate to either false or true. Because Siebel eScript automatically converts values when appropriate, when a Boolean variable is used in a numeric context, its value is converted to 0 if it is false, or 1 if it is true. A script is more precise when it uses the actual Siebel eScript values, false and true, but it works using the concepts of zero and nonzero.
String
A string is a series of characters linked together. A string is written using a pair of either double or single quotation marks, for example:
"I am a string"
'so am I'
'me too'
"344"The string
"344"
is different from the number344
. The first is an array of characters, and the second is a value that may be used in numerical calculations.Siebel eScript automatically converts strings to numbers and numbers to strings, depending on the context. If a number is used in a string context, it is converted to a string. If a string is used in a number context, it is converted to a numeric value. Automatic type conversion is discussed more fully in Automatic Type Conversion.
Although strings are classified as a primitive data type, they are actually a hybrid type that shares characteristics of primitive and composite data types. A string may be thought of as an array (a composite data type) of characters, each element of which contains one character. For an explanation of arrays, read Array.
Bookshelf Home | Contents | Index | Search | PDF |
Siebel eScript Language Reference Published: 18 April 2003 |