You are here: Development Standards > OSAS Standards > Using String Templates > Definition

# Definition

Use string templates as another way to store data. Simply define a template that will define the data elements stored in a string. Here are some samples of string templates:

`“CUST:C(10),NAME:C(30),BALANCE:N(14)”`

This syntax means that the variables CUST, NAME, and BALANCE are stored in the string as follows:

Variable | Description
CUST | alphanumeric field, with a length of 10
NAME | alphanumeric field, with a length of 30
BALANCE | numeric field with a length of 14

`“CUST:C(10*),NAME:C(30*),BALANCE:N(14*)”`

This syntax means that the variables CUST, NAME, and BALANCE are stored in the string as follows:

Variable | Description
CUST | alphanumeric field, with a length of 10, followed by a field terminator
NAME | alphanumeric field, with a length of 30, followed by a field terminator
BALANCE | numeric field with a length of 14 followed by a field terminator

This syntax does not mean that the CUST variable is forced to a length of 10; if a field is field-terminated, it can be any length.

To assign this template to a string, use one of these standards:

`0010 DIM ARCU$:“CUST:C(10*),NAME:C(30*),BALANCE:N(14*)”`

or

`0010 LET B$=“CUST:C(10*),NAME:C(30*),BALANCE:N(14*)”`
`0020 DIM ARCU$:B$`

This assigns the template to ARCU$. You can then reference the fields inside ARCU$ as follows:

`0030 LET CUSTOMER_ID$=ARCU.CUST$; PRINT ARCU.NAME$;`
`0040 LET CUSTOMER_BALANCE=ARCU.BALANCE`

A rule of thumb for string templates is that if the contents of a variable is to be handled more than twice, assign the variable to a local variable, manipulate the local variable as needed, and reassign the string template.