Reference > Functions reference > Text functions > Code
 

Code

Returns the Unicode code points for the characters in the text.

Format 

Code(text)

Parameters 

text - one or more characters

Data type returned 

number

Originated in 

FileMaker Pro 10.0

Description 

Returns the Unicode code points for the characters in text. If zero characters are in text, returns an empty string.

If one character is in the text, the function returns the code point for that character. If the text contains multiple characters, the Unicode code point for each character is returned as a group of five digits where the code point for the first character is represented by the low five digits, the code point for the second character in the next higher (to the left) five digits, and so forth.

When converting a composite character such as ä, the function returns the Unicode code point for the composite character.

The following table shows how navigational characters are reported to a script activated by this trigger:

 

Key Pressed

Is reported as

Notes

backspace

  8

Corresponds to Unicode/ASCII code for BS (backspace)

tab

  9

Corresponds to Unicode/ASCII code for HT (horizontal tab)

shift-tab

  9

The shift can be detected using the value returned from the Get(TriggerModifierKeys) function

enter

 10

Corresponds to Unicode/ASCII code for LF (line feed)

return

 13

Corresponds to Unicode/ASCII code for CR (carriage return)

escape

 27

Corresponds to Unicode/ASCII code for ESC (escape)

left arrow

 28

Corresponds to Unicode/ASCII code for FS (file separator)

up arrow

 29

Corresponds to Unicode/ASCII code for GS (group separator)

right arrow

 30

Corresponds to Unicode/ASCII code for RS (record separator)

down arrow

 31

Corresponds to Unicode/ASCII code for US (unit separator)

space

 32

Corresponds to Unicode/ASCII code for Space

forward delete

127

Corresponds to Unicode/ASCII code for Delete

Notes 

If there are too many characters to be represented in the FileMaker number field type, the function returns a NaN (Not a Number) value.

Example 1 

Code ( "" ) returns an empty string.

Code ( "a" ) returns 97.

Code ( "b" ) returns 98.

Code ( "ab" ) returns 9800097.

Code ( "ä" ) returns 228.

Code ( "ä" ) (an a followed by a dieresis character entered in a separate keystroke) returns 77600097.

Related topics 

Functions reference (category list)

Functions reference (alphabetical list)

About formulas

About functions

Defining calculation fields

Using operators in formulas

Char function