Xbasic

RECORD_ADD Function

Syntax

Result_Flag as L = record_add(C tablename ,C data [,N style ])

Arguments

tablenameCharacter

The name of a table

dataCharacter

A CR-LF delimited list of the field values to add as a new record. The data can be presented in two different formats as Defined by the Style argument.

styleNumeric

Default = 1. An optional style selector that defines the format of the data parameter. Value can be 1 or 2.

When entering data in an auto-increment field, use Style 1 and leave the value of the field blank. E.g. "Fieldname1 = ".

See explanation below for more information.

Returns

Result_FlagLogical

.T. = the record was added. .F. = the record was not added.

Description

Adds a new record to a table. Data is CRLF delimited list. Style 1 - data is fieldname=fieldvalue pairs, Style 2 data is just fieldvalues in same order as fieldnames

Discussion

RECORD_ADD() adds a new record to Table_Name using the field values specified by Data_List.Note : The RECORD_ADD() function opens and closes the table. You should not use TABLE.OPEN() or TABLE.CLOSE().

Example

dim cs as C
cs = "00000010" + crlf() + "Layout" +  crlf() + "Report"
? cs = 00000010
Layout
Report
record_add("category", cs, 2)

Setting the Style 

The Style selector defines the format of the data. There are two options available:

  • Style = 1 

    The default style used, data is listed using a CR-LF delimited list of <field_name> = <value> pairs. For example:

    Fieldname1 = Value1
    Fieldname2 = Value2
    FieldnameN = ValueN
  • If data must be included for auto-increment fields, you must use Style 1. You can specify the auto-increment field with a blank value as follows:

    Fieldname1 =
  • Style = 2 

    Data only includes the values. For example:

    Value1
    Value2
    ValueN

See Also