Constants

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 6.0


A constant is an expression that has a fixed value. There are two types of constants: predefined constants that you select by name, and literal constants for which you type the actual value.

Predefined Constants


Version 6 of 4th Dimension introduces predefined constants. These constants are listed in the Explorer Window:

The predefined constants are listed by theme. To use a predefined constant in a Method editor window:

Drag and drop the constant from the Explorer window to the Method Editor window.

Directly type its name in the Method Editor window.

Predefined constant names can contain up to 31 characters.

Tip: If you directly enter the name of a predefined constant, you can use the @ symbol (at sign) to avoid typing the entire constant name. For example, if you type "No such da@", 4D will fill the line with the constant "No such data in clipboard" when you press Return or Enter to validate the line of code.

Note: The predefined constants (about 500) are listed by theme in this manual. See the section About this manual for more information. When appropriate, predefined constants are also listed in the command descriptions.

Predefined constants appeared underlined by default within the Method Editor and Debugger windows:

In the window shown here, On Load, for example, is a predefined constant.

Literal Constants


Literal Constants can be of four data types:

String

Numeric

Date

Time

String Constants

A string constant is enclosed in double, straight quotation marks ("…"). Here are some examples of string constants:

"Add Records"

"No records found."

"Invoice"

An empty string is specified by two quotation marks with nothing between them ("").

Numeric Constants

A numeric constant is written as a real number. Here are some examples of numeric constants:

27

123.76

0.0076

Negative numbers are specified with the minus sign(–). For example:

–27

–123.76

–0.0076

Date Constants

A date constant is enclosed by exclamation marks (!…!). In the US English version of 4D, a date is ordered month/day/year, with a slash (/) setting off each part. Here are some examples of date constants:

!1/1/76!

!4/4/04!

!12/25/96!

A null date is specified by !00/00/00!

Tip: The Method Editor includes a shortcut for entering a null date. To type a null date, enter the exclamation (!) character and press Enter.

Note: A two-digit year is assumed to be in the 1900's. Unless this default setting has been changed using the command SET DEFAULT CENTURY.

Time Constants

A time constant is enclosed by question marks (?...?).

Note: This syntax can be used on both Windows and Macintosh. On Macintosh, you can also use the Dagger symbol (Option-T on a US keyboard).

In the US English version of 4D, a time constant is ordered hour:minute:second, with a colon (:) setting off each part. Times are specified in 24-hour format.

Here are some examples of time constants:

?00:00:00? ` midnight

?09:30:00? ` 9:30 am

?13:01:59? ` 1 pm, 1 minute, and 59 seconds

A null time is specified by ?00:00:00?

Tip: The Method Editor includes a shortcut for entering a null time. To type a null time, enter the question mark (?) character and press Enter.

See Also

Control Flow, Data Types, Identifiers, Methods, Operators, Pointers, Variables.


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next