Skip to content

LET FMT

Assigns String Value to Data Name

This directive assigns the value of a string to a data name

LET FMT(str-val[,elem-num[,occ-num]]) = data-val
[,ERR=line-ref|,ERC=error-code]
str-val
is any string, which contains a format name or data name.
elem-num
is a positive integer that specifies the data element to be referenced. The element number must be 0 if a data name is specified.
occ-num
is a positive integer that specifies the occurrence of a data element.
data-val
is any string, which represents the data to be stored or retrieved from the format's data area.
line-ref
is the program line number or label to branch to in the event of an error.
error-code
is a programmer-defined error code. Valid values are positive or negative whole numbers.

The value will be validated and then converted for storage according to the fixed attributes of the specified data element.

The format of the input value for data elements with date types 1, 2, 3, or 5 and length 4 (INFORMIX SQL) must be in the following system date formats:

Date format Input format
M “MMDDYY”
D “DDMMYY”
Y “YYMMDD”

If the input value is not in system date format, an ERR=167 results.

The format of the input value for data elements with date type 5 and length 6 (normal SQL) must be in system date format plus an optional time value as follows:

Date format Input format
M “MMDDYY”[+“HHMISS”]
D “DDMMYY”[+“HHMISS”]
Y “YYMMDD”[+“HHMISS”]

If the input value is not in system date format, an ERR=167 results.

An attempt to reference an invalid format/data name will result in an ERR=17.

An attempt to reference a format name without a data element number will result in an ERR=17.

An attempt to reference a data name with a data element number will result in an ERR=17.

An attempt to reference a format name that the data dictionary or current program does not recognize will result in an ERR=161.

An attempt to reference a data name that does not exist in the format’s data element table, either by name or by element number, will result in an ERR=163.

An attempt to reference an occurrence number of an element that is defined without multiple occurrences will result in an ERR=164.

An attempt to reference an invalid occurrence number of an element that is defined with multiple occurrences will result in an ERR=165.

The following examples assume that the FORMAT INCLUDE directive successfully loaded a format named DNFFMT into memory, and that DNFFMT consists of the following data elements:

ElemNumNameLengthNum typeDate type
1DN-STRING20--
2DN-BINNUM8.43-
3DN-STR-OCC10*4--
4DN-IEEE-OCC8.4*49-
5DN-SQLDATE6-5
FMT$="#DNFFMT"
STR$="DATA STRING"
LET FMT(FMT$,1)=STR$

stores the value of STR$ into #DNFFMT.DN-STRING.

NUM=-9999.9999;
LET FMT(FMT$,2)=STR(NUM)

stores the value of NUM into #DNFFMT.DN-BINNUM.

FOR OCC=1 TO NUM(ATR(FMT$,3,18));
LET FMT(FMT$,3,OCC)="OCCURS "+STR(OCC);
NEXT OCC

stores the values “OCCURS 1”, “OCCURS 2”, “OCCURS 3”, and “OCCURS 4” into the first, second, third, and fourth occurrences of #DNFFMT.DN-STR-OCC, respectively.

DNM$=FMT$+"."+ATR(FMT$,4,21);
FOR OCC=1 TO NUM(ATR(DNM$,0,18));
LET FMT(DNM$,0,OCC)=STR(1111.1111*OCC);
NEXT OCC

stores the values 1111.1111, 2222.2222, 3333.3333, and 4444.4444 into the first, second, third, and fourth occurrences of #DNFFMT.DN-IEEE-OCC, respectively.

DNM$=FMT$+"."+ATR(FMT$,5,21);
LET FMT(DNM$)=NTD(CDN,"MMDDYY")

stores the current date into #DNFFMT.DN-SQLDATE.

DNM$=FMT$+"."+ATR(FMT$,5,21);
LET FMT(DNM$)=NTD(CDN,"MMDDYYHHMISS")

stores the current date and time into #DNFFMT.DN-SQLDATE.

ATR, FMD, FMT, NTD, and NUM functions
CDN and DNE system variables
FORMAT INCLUDE, FORMAT INIT, FORMAT DEFAULT, and FORMAT DELETE directives

From the Thoroughbred Basic Language Reference, Volume II: F–Q, version 8.9.1. Open this page in the PDF