Progress
External Program
Interfaces


Coding the 4GL Program

The 4GL program:

The following 4GL program demonstrates reading and writing a Windows NT named pipe "custpipe:"

e-4glpip.p
/* e-4glpip.p */ 
/* 4GL program that reads and writes a Windows NT named pipes */

/* 1. Define buttons */
DEF BUTTON bWrite LABEL "Write to Pipe".
DEF BUTTON bRead  LABEL "Read from Pipe".
DEF BUTTON bQuit  LABEL "Quit".

/* 2. Define form */
FORM SKIP(5)
  SPACE(5) bWrite SPACE(5) bRead SPACE(5)
  SKIP(1)
  SPACE(18) bQuit
  SKIP(5)
WITH FRAME f TITLE "Pipe Test".

/* 3. Define write trigger */
ON CHOOSE OF bWrite IN FRAME f
DO:
  OUTPUT TO \\.\pipe\custpipe APPEND.
  FOR EACH customer:
    DISPLAY name.
  END.
  OUTPUT CLOSE.
END. 

/* 4. Define read trigger */
ON CHOOSE OF bRead IN FRAME f
DO:
  DEF VARIABLE i AS INTEGER.
  INPUT FROM \\.\pipe\custpipe.
  SET i.
  INPUT CLOSE.
  FIND customer WHERE cust-num = i.
  DISPLAY customer WITH 2 COLUMNS FRAME y OVERLAY TITLE "Customer Info".
END.

/* 5. Define quit trigger */
ON CHOOSE OF bQuit IN FRAME f
DO:
  APPLY "window-close" TO CURRENT-WINDOW.
END.

/* 6. Enable all objects, then wait on a close event */
ENABLE ALL WITH FRAME f.
WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW. 

  1. The program defines three buttons, labeled “Write to Pipe,” “Read from Pipe,” and “Quit.”
  2. The program defines a form to contain the buttons.
  3. The program defines a trigger for the Write to Pipe button. The trigger redirects output to named pipe custpipe, displays (to named pipe custpipe) the name of each customer in the Sports database, and closes the named pipe.
  4. In an OUTPUT TO statement, \\. means the current machine. To communicate with remote machine “pcdev68,” for example, use \\pcdev68. This follows Uniform Naming Conventions (UNC).

    The OUTPUT TO statement uses the APPEND option, which causes Progress to open the named pipe without first creating it. This is necessary because Progress 4GL cannot create named pipes.

  5. The program defines a trigger for the Read to Pipe button. The trigger defines an integer data item, reads named pipe custpipe, assigns the value read (a customer number) to the integer data item, closes the named pipe, retrieves the row of the customer table with the specified customer number, and displays the columns of the row.
  6. The INPUT FROM statement assumes that the pipe exists and that another process writes to it. The INPUT FROM statement blocks until the other process writes to the named pipe.

  7. The program defines a trigger for the Quit button.
  8. The program enables all objects in the frame and waits on a close event.

Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095