OBJECT Get format
OBJECT Get format ( {* ;} object ) : Text
Parameter | Type | Description | |
---|---|---|---|
* | Operator | → | If specified, object is an object name (string) If omitted, object is a field or a variable |
object | any | → | Object name (if * is specified) or Field or variable (if * is omitted) |
Function result | Text | ← | Object display format |
This command is not thread-safe, it cannot be used in preemptive code.
Description
The OBJECT Get format command returns the current display format applied to the object specified in the object parameter.
If you pass the optional * parameter, you indicate that the object parameter is an object name (in this case, pass a string in object). If you do not pass this parameter, you indicate that the object parameter is a field or variable. In this case, you do not pass a string, but a field or variable reference.
This command returns the current display format of the object; in other words, the format as defined in the Design environment or using the OBJECT SET FORMAT command. OBJECT Get format works with all types of form objects (fields or variables) that accept a display format: Boolean, date, time, picture, string, number, as well as button grids, dials, thermometers, rulers, picture pop-up menus, picture buttons, 3D buttons, and list box headers. For more information on the display formats of these objects, refer to the documentation for the OBJECT SET FORMAT command.
Note: If you apply the command to a set of objects, the form of the last object selected is returned.
When the OBJECT Get format command is applied to objects whose format has been set using a longint constant (date, time or picture objects), the string returned corresponds to the character code of the constant. To obtain the value of the constant, simply apply the Character code function to the result (see below).
Example 1
This example allows you to obtain the value of the format constant applied to the picture variable named “myphoto”:
var $format : Text
OBJECT SET FORMAT(*;"myphoto";Char(On background))
//Apply background format (value = 3)
$format:=OBJECT Get format(*;"myphoto")
ALERT("Format number:"+String(Character code($format)))
//Display value "3"
Example 2
This example allows you to obtain the format applied to the Boolean field [Members]Marital_status:
var $format : Text
$format:=OBJECT Get format([Members]Marital_status)
ALERT($format) //Display format, for example "Married;Single"
Example 3
Customized formats are returned untouched:
var $format : Text
OBJECT SET FORMAT(*;"timeinput";":m") //":" is required for single-char patterns
$format:=OBJECT Get format(*;"timeinput") // ":m"