
Literals
There are five kinds of literals in ACF:
String literals: These consist of any text enclosed in single or double quotes. If the same kind of quotes are included within the literal, they must be escaped. String literals can span multiple lines.
Number literals - Integer: These are represented by any series of digits, optionally prefixed with a "-" for negative values. Large numbers are automatically treated as long integers.
Float literals: Float literals are represented by any series of digits that include a decimal point ".". They can also use scientific notation, such as "E06". Float literals use a decimal point, not a comma, as the decimal separator.
Array literals: An array can be initialized with a comma-separated list of string or number literals, enclosed in curly brackets. The list can also contain variables or expressions, and other array variables to merge the arrays. The type of the elements must be the same as the array type, as we cannot have mixed types in an array.
Example:
ARRAY STRING abc = {"row1", "row2", "row3", any_string_var};
JSON and XML literals JSON and XML literals are string literals starting with
{
or<
- the JSON and XML engine will try to parse the string to create a JSON or XML variable. The notation is only used in an assignment operation to assign a JSON or an XML variable as that specific type. Otherwise, the start character will have no such meaning and will be treated as ordinary text.Example:
JSON jsonvar = '{"a":"abc"}';
Example:
XML xmlvar = '<root>myRootElement</root>';
Literals with Special Meaning:
Some literals have special meanings and trigger the FileMaker evaluation engine to retrieve their content. These literals are in addition to the "eval" function, which takes a string expression as an argument. The literals with special meaning are:
FileMaker evaluate literal: Any text enclosed by "@" symbols on each side will be evaluated as a FileMaker expression. They must be on the same line. For multiline evaluations, use "@@" on each side instead.
FileMaker evaluates variable name literal: Any identifier prefixed with one or two "$" symbols will be evaluated as a FileMaker expression to retrieve its value.
FileMaker evaluates field name: Any table::field notation will be evaluated as a FileMaker expression to retrieve its value.
Data Types
In ACF, various data types are used to represent different kinds of values. Here is a list of ACF data types along with their corresponding C++ types and descriptions:
Type Name | C++ Type | Description |
---|---|---|
int | int | Integers, hardware-dependent 32-bit or 64-bit integer values. The actual size can be obtained with the size(a int variable) function in bytes. |
long | long | Long integers. The actual size can be obtained with the size(a long variable) function in bytes. |
float | double | Floats (these are actually represented as doubles). |
double | double | Double-precision floating-point numbers. |
string | std::string | String datatype, with maximum length depending on the implementation (can be very large). |
date | time_t | Timestamp with only the date part. |
time | time_t | Timestamp with only the time part. |
timestamp | time_t | Full timestamp including date and time. |
bool | int | Boolean values represented as 0 (false) or 1 (true). |
JSON | nlohman::json | Structured data on JSON format (v 1.7.0.x) |
XML | internal structural data | Structured data on XML format (v 1.7.0.x) |
Operands
Operands are values or variables operated on by operators to produce a result. Here are the operators available in ACF, along with their left and right operand types and the resulting data type:
Operator | Left Type | Right Type | Result Type | Description |
---|---|---|---|---|
+, -, * | Numeric Types | Numeric Types | Float, Long, Int | Basic arithmetic operations. |
/ | Int, Long, Float | Int, Long, Float | Float | Division always results in a float. |
++ | Numeric Types | - | Same | Increment left operand by one. |
-- | Numeric Types | - | Same | Decrement left operand by one. |
+ | String | All | String | Concatenate strings or convert non-string values to strings and concatenate. |
+ | Date | Numeric | Date | Add days to a date. |
+ | Time | Numeric | Time | Add seconds to a time. |
* | String | Int, Long | String | Repeat the left string right times. |
^ | Int, Long, Float | Int, Long, Float | Float | Exponentiation (power). |
&& | Bool | Bool | Bool | Logical AND. |
|| | Bool | Bool | Bool | Logical OR. |
== | All | All | Bool | Equal comparison. |
< | All | All | Bool | Less than comparison or string alphabetical order. |
> | All | All | Bool | Greater than comparison or string alphabetical order. |
<= | All | All | Bool | Less than or equal comparison. |
>= | All | All | Bool | Greater than or equal comparison. |
!= | All | All | Bool | Not equal comparison. |
≠ | All | All | Bool | Not equal comparison (alternative syntax). |
Priority of Operands
The priority of operands defines the order of evaluation in expressions. Higher-priority operands are evaluated first. To change the priority, you can use parentheses in expressions. A factor can be negated with a "-" symbol in front of it, or "!" for boolean types, affecting only the next factor in the evaluation. For negating an entire expression, you must use parentheses.
Example:
a = !a || b;
This negates "a" but not the entire expression. To negate the whole expression:
a = !(a || b);
Here's the priority list of operands, from highest to lowest:
- Power (^)
- Multiplication (*) and Division (/)
- Addition (+) and Subtraction (-)
- Comparison operators (<, >, <=, >=, ==, !=, ≠)
- Logical AND (&&)
- Logical OR (||)
Conversion between data types
Most declaration type names can also be used as type converter functions. Some conversions allow additional parameters to specify the format to be applied. Here are some examples.
- Convert a date to a string:
string(date_variable, "%Y/%m/%d");
- Convert a string to date:
date(string variable, "%Y-%m-%d");
The format specifier describes the existing format of the date. - Convert a float to int (floor):
int(float variable)
- Convert a float to a string:
- With format:
format("%.2f", float_variable);
- Standard format:
string(float_variable)
- With format:
- Convert int to bool:
bool(int_variable)
- Convert bool to int:
int(bool_variable)
- Convert string to float:
float(string_variable)
- Structural type converters: The simple assignment will do the conversation automatically, as the type name as function is used for key/value pair converters,
- Convert JSON to XML:
xml_variable = json_variable
- Convert XML to JSON:
json_variable = xml_variable
- Convert JSON to XML: