Define GS

PURPOSE:  Global Storage (GS) is a set of user-defined fields that define an area in memory where information can be stored and passed on from CM and PM to other CM’s, PM’s and even direct commands.  It is also possible to share data with programs running simultaneously even those being executed by other users.  GS fields are similar in function and syntax to the fields in Schema Definitions (SD) except:

GS areas are very useful for storing values that are to be used from command to command and exceed the capacity provided by the system fields @STRING, @NUMBER, @INTEGER, @VDATE, AND @COMMAND

Any number of GS areas may be defined, but only 10 may be in use at a time.  The values stored in Global Storage are lost when the USE GS for that GS is executed again or USE NO GS command is issued or the current ACCENT R session is terminated.  The field definitions for GS, however, endure until specifically removed or modified.

Once a GS area has been declared with USE GS command, the fields in that GS can be accessed for either input or update from any DBL in the user’s directory.  Closing a Data Base Library (DBL) does not close the GS area.

Up to ten GS’s can be declared and accessed.  If more than one declared GS has a field by the same name, the first declared GS’s definition would apply.  Individual GS’s can be closed with the command USE NO GS GS.name.

A GS definition is created with the DEFINE command.  The DEFINE command transfers control to the edit level, where the field definition statements and any of the following options may be entered.

SYNTAX

DEFINE GS name [IN DBL dbl_name]

name

is the name assigned to the GS being created.

[IN DBL dbl_name]

is used to create the GS entry in a DBL other than the current one.  If an IN DBL clause is included, the GS will be stored in the DBL named in that clause.  Otherwise, it will be stored in the current DBL.

EXAMPLE

*DEFINE GS AUTHOR
--10  %NAME,CHAR,25
--20  %ADDRESS,CHAR,35
--30  %CONTRACT,INT,1,VALID IF VALUE = 0,1,2
--SAVE

NOTES:  The names of GS definitions should not begin with ACC because this prefix is used by the ACCENT R utilities that use GS’s.

The field definition statement has the same clauses as are used in the field definition statement of Schema Definition (SD).  See Chapter 4 for a detailed description of each clause.  The DATA clause is only used for global storage definitions and is described in detail here.

SYNTAX

[$start_position] %field_name, data_type,

[,{field_width; MAX} [, decimal_places]] [DATA value]

[,OCCURS m [[{BY; *} [n {BY; *} o]] [{RECORD; COLUMN} /MAJOR/]]

[,IE = "input_edit_string"]

[,OE = "output edit string"]

[,PP = "print_picture_string"]

[,TITLE = "title_string"]

[,\\ALIAS names\\]

[,OVERPUNCH]

[,/USAGE IS/ {ASCII; BINARY}]

[,USE VALUES \\field_value = "string"\\]

[,VALID conditional clause]

DATA

allows an initial value to be specified for the field.

The DATA clause eliminates the need to set values to GS fields each time they are declared for use.

value

is the initial value of the right data type.  For alpha and character fields, the value must be enclosed in quotation marks; for date fields, the value must be entered as an integer in the form YYMMDD (see example below).

EXAMPLE

*LIST GS CUSTOMER
00010  %NAME,CHAR25
00020  %ADDRESS,CHAR,35
00030  %REGION,INT,1,VALID IF VALUE = 3,4,5,6
*USE GS CUSTOMER
*SET “RHONDA GARRETT” TO %NAME
*SET “123 OAK ST., FERNVILLE, CA” TO %ADDRESS
*SET 3 TO %REGION
*TYPE %NAME, %ADDRESS, %REGION,
RHONDA GARRETT 123 OAK ST., FERNVILLE CA 3

The next example shows a Global Storage (GS) definition containing a DATA clause for each of its fields.  Note the DATA clauses eliminate the need to set initial values to the fields.

*LIST GS DEMO
00100  %TEXT,CHAR,3, DATA “abc”
00110  %INT,INT,2, DATA 10
00120  %NUMBR,FLOAT,6,2, DATA 100.50
00130  %DUE_DATE, DATE, DATA 851230
*USE GS DEMO
*TYPE  %TEXT,2B,%INT,2B,%NUMBR,2B,%DUE_DATE
abc 10 100.50 12/30/85

For items with OCCURS clause, the data is specified with “DATA” on a line following the item definition and each data line follows beginning with “ / ”.  Data values must be separate by comma with the last data item followed on the next line with “DATA END”.

NOTES:  The field names in a GS definition should not begin with %ACC because this prefix is used by ACCENT R utilities that use GS’s.

The following examples should help:

LIST GS RATES
00001  %RATE,1,2 OCCURS 3
00002  DATA
00003  /1.4,17,92
00004  DATA END
00005  %CODES,C,2, OCCURS 2 BY 3
00006  DATA
00007  /‘en’, ‘at’, ‘bt’, ‘xa’, ‘yb’, ‘hj’
00008  DATA END
00009  %DISC,I,2,OCCURS 3 BY 3
00010  DATA
00011  /5,9,11
00012  /12,14,17
00013  /25,50,75
00014  DATA END

Values for groups can be specified as follows:

LIST GS GROUP.EXP
GROUP EXP OCCURS 3 TIMES
%CODE,1,2
%TEXT,C,3
END GROUP
DATA
/10,’aaa’/
/20,’bbb’/
/30,’ccc’/
DATA END