OP Set format

4D - Documentation   Français   English   German   4D Open for 4D, Command Theme List   4D Open for 4D, Command Alphabetical List   Back   Previous   Next

version 1.5


OP Set format (bindID; tableID; fieldID; conversionFormat) Longint

ParameterTypeDescription
bindIDLongintBind list ID
tableIDLongintNumber of the table in the database
fieldIDLongintNumber of the field in the table
conversionFormatStringFormat string for conversions
Function resultLongintError 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 TypeData Type CodeExample Format
Numeric-1$###,###.00
Date-4Char(3) (where 3 is the number of the date format)
Boolean-6Male;Female
Time-11Char(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 CodeDescription
-108Not enough memory to perform this command.
10128The 4D Open for 4th Dimension package has not been initialized.
10137The bind list does not exist.
10148Unknown option requested to 4D Open for 4th Dimension.
10154This command cannot be executed right now.
10163Bind 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.


4D - Documentation   Français   English   German   4D Open for 4D, Command Theme List   4D Open for 4D, Command Alphabetical List   Back   Previous   Next