English

How To: Write an AML to create and run an INFO program with odd and even program sections

Summary

INFO programs are very efficient and fast when processing large INFO files. The AML in this article writes an INFO program containing both even and odd program sections.

Procedure

INFO programs use alternating odd and even program sections to change the level at which they operate. Odd programming sections perform a command on all the selected records before moving to the next command. Even programming sections perform all the commands on one record then move to the next selected record.

This code sample shows how even and odd program sections work. By default, all the INFO code prior to the first even program section command line constitutes PROGRAM SECTION ONE. PROGRAM SECTION ONE illustrates odd programming sections and PROGRAM SECTION TWO illustrates even programming sections.

Code:
/********************************************************************
/* EVENPRGSECT.AML
/*
/* 1) Deletes any existing INFO files named INC or TEST.DAT.
/*
/* 2) Starts an INFO session to create and populate a 6 record
/* INFO file TEST.DAT.
/*
/* 3) Lists the file displaying its 2 items: ALPHA and NUMITEM
/*
/* ALPHA NUMITEM
/* ----- -------
/* aa 11
/* bb 22
/* cc 33
/* dd 44
/* ee 55
/* ff 66
/*
/* 4) Writes an INFO Program named INC. The PROGRAM SECTION ONE
/* selects test.dat records 2,3,4, and 5. And initializes the INFO system
/* variable $NUM1 to 500.
/*
/* The PROGRAM SECTION TWO loops on each of the 4 selected record. Each
/* pass through the loop calculates NUMITEM to $NUM1 and then calculates
/* $NUM1 equal to $NUM1 plus 100.
/*
/* 5) Runs the INFO program INC.
/*
/* 6) Selects and lists the TEST.DAT INFO file.
/*
/* ALPHA NUMITEM
/* ----- -------
/* aa 11
/* bb 500
/* cc 600
/* dd 700
/* ee 800
/* ff 66
/*
/* 7) Exits INFO returning to the Arc: prompt
/**********************************************************************

/* &ECHO &ON

&IF [EXISTS INC -INFO] &THEN &TYPE [DELETE INC -INFO]
&IF [EXISTS TEST.DAT -INFO] &THEN &TYPE [DELETE TEST.DAT -INFO]

/* Make a data file TEST.DAT
&DO
&data arc info
ARC
DEFINE TEST.DAT
ALPHA,2,2,C
NUMITEM,5,5,I
~
ADD
aa,11
bb,22
cc,33
dd,44
ee,55
ff,66
~
LIST
PROGRAM INC
FORMAT $NUM1,7,7,I
CACL $NUM1 = 500
SELECT TEST.DAT
RESELECT $RECNO GT 1 AND $RECNO LT 6
PROGRAM SECTION TWO
CALC NUMITEM = $NUM1
CALC $NUM1 = $NUM1 + 100
PROGRAM END
~
RUN INC
ASELECT
LIST
QUIT
STOP
&END

&ECHO &OFF