GURGLE Tutorial: Formatting and Extensions

Included below is an improved definition file to process our phone directory database. Copy it into a file in the same directory as the data source file and call it phones2.grg or download phones2.grg.

%%database "phonedir.txt"
%%define DELIM |
%%define NAMCOL
%%define TEXEXT .lst
%%header
PHONE DIRECTORY
%%record

  NAME:     %FIRSTNAME %LASTNAME
  JOB:      %JOB
  CONTACT:  %ROOM, x%EXTENSION
%%end

The changes made have been highlighted. The TEXEXT line changes the default output extension. We have also defined an explicit header (just some text in this case) and an explicit record. Both the record and header are written out exactly as is but any %FIELD reference is expanded to the current value of the given field. The %%end is optional but it's usually a good idea to include one to make explicit the end of the text body (the blocks of text associated with output sections).

Now we need to gurgle the file to produce the output.

gurgle phones2.grg

If everything worked this will created phones2.lst which is the output file and should look like below.

PHONE DIRECTORY
 
  NAME:     Joe Bloggs
  JOB:      Manager
  CONTACT:  C99, x4455
 
  NAME:     Jack Frost
  JOB:      Air Conditioning Technician
  CONTACT:  A23, x4321
 
  NAME:     John Doe
  JOB:      Coroner
  CONTACT:  B56, x3888
 
  NAME:     Mike Tyson
  JOB:      Security
  CONTACT:  A23, x7911
 
  NAME:     Rosanne Barr
  JOB:      Receptionist
  CONTACT:  A01, x1111
 
  NAME:     Bill Clinton
  JOB:      Legal Services
  CONTACT:  C55, x4723
 
  NAME:     Jerry Springer
  JOB:      Public Relations
  CONTACT:  B44, x8844
 
  NAME:     Frasier Crane
  JOB:      Counsellor
  CONTACT:  B78, x6542

Exercises

Try messing about with the content of the header and record bodies to see how the output is formatted according to the contents of these text bodies.

Now lets improve the output further.

NEXT