version 1.5
OP Set format (bindID; tableID; fieldID; conversionFormat) Longint
Parameter | Type | Description | |
bindID | Longint | Bind list ID | |
tableID | Longint | Number of the table in the database | |
fieldID | Longint | Number of the field in the table | |
conversionFormat | String | Format string for conversions | |
Function result | Longint | Error code result for the function |
Description
OP Set format allows you to set the format used when you convert non-alphanumeric values to alphanumeric and text values, and vice versa.
To clear a format, pass an empty string in the conversionFormat parameter.
This command accepts two syntactical forms:
Pass a valid bind list number in bindID
Pass a negative number that denotes a data type
If you pass a valid bind list number in bindID, you also pass the numbers of the table and field whose formats you want to set. The format applies only to the field in this bind.
If you pass a negative number, tableID and fieldID are ignored; you can pass 0 for those parameters. The format applies to all conversions that do not have a format already set.
The following table lists the data type codes and some examples of the formats you can use:
Data Type | Data Type Code | Example Format |
Numeric | -1 | $###,###.00 |
Date | -4 | Char(3) (where 3 is the number of the date format) |
Boolean | -6 | Male;Female |
Time | -11 | Char(4) (where 4 is the number of the time format) |
For a complete description of valid data types and conversion format, refer to the 4D command SET FORMAT.
Error Codes
If OP Set format executes successfully, it returns 0. Otherwise, this function returns one of the following errors:
Error Code | Description |
-108 | Not enough memory to perform this command. |
10128 | The 4D Open for 4th Dimension package has not been initialized. |
10137 | The bind list does not exist. |
10148 | Unknown option requested to 4D Open for 4th Dimension. |
10154 | This command cannot be executed right now. |
10163 | Bind entry not found. |
Example
This example binds a string array to a date field on the server. We use the format comment to specify how the conversion should occur.
C_LONGINT ($BindID;$ErrCode;$ConnectID) ARRAY STRING (35;aInvDate;0) C_LONGINT (vTableInvoices) C_LONGINT (vFieldDate) ` Get [Invoices] tableID and [Invoices]Invoice date fieldID $errCode:=OP Get one field number (vConnectID;"[Invoices]Invoice date";vTableInvoices;vFieldDate) $ErrCode := OP Create bind ($BindID) $ErrCode := $ErrCode + OP Define bind by pointer ($BindID;vTableInvoices;vFieldDate;->aInvDate) ` On a known stable structure one could also write ` $ErrCode := $ErrCode + OP Define bind by pointer ($BindID;2;3;0;0;->aCompany) ` Specify (non default) conversion format for use when transfering data with THIS bind ` We want invoices date read through this bind to be converted to string ` using the Abbreviated ,6, or Abbr Month Date $errCode:= OP Set format (vConnectID;$BindID;vTableInvoices;vFieldDate; Char (Abbr Month Date)) If ($ErrCode=0) $ErrCode:=OP Selection to array (vConnectID;$BindID) End if $ErrCode:=OP Delete bind ($BindID)
See Also
OP Array to selection, OP Define bind by numbers, OP Define bind by pointer, OP Selection to array, OP Set format.