PreviousNextIndex

INPUT-OUTPUT THROUGH statement

Names a program (process) for the AVM to start. This process is the input source as well as the output destination for the procedure.

Syntax

INPUT-OUTPUT [ STREAM stream | STREAM-HANDLE handle ] 
  THROUGH { program-name | VALUE ( expression ) } 
  [ argument | VALUE ( expression ) ] ... 
  [ ECHO | NO-ECHO ] 
  [ MAP protermcap-entry | NO-MAP ] 
  [ UNBUFFERED ] 
  [     NO-CONVERT 
     |  { CONVERT 
            [ TARGET target-codepage ] 
            [ SOURCE source-codepage ] 
        } 
  ] 

STREAM stream
STREAM-HANDLE handle
program-name
VALUE ( expression )
argument
ECHO
NO-ECHO
MAP protermcap-entry | NO-MAP
UNBUFFERED
CONVERT
TARGET target-codepage
SOURCE target-codepage
NO-CONVERT
Examples

This procedure uses a C program to recalculate the price of each item in inventory. Specifically, the C program increases the price of each item by 3% or by 50 cents, whichever is greater. The INPUT-OUTPUT THROUGH statement tells the procedure to get its input from, and send its output to, the r-iothru.p procedure. The INPUT-OUTPUT CLOSE statement resets the input source to the terminal and the output destination to the terminal.

r-iothru.p
FOR EACH Item WHERE Item.ItemNum < 10: 
  DISPLAY Item.ItemNum Item.Price LABEL "Price before recalculation". 
END. 
INPUT-OUTPUT THROUGH r-iothru UNBUFFERED. 
FOR EACH Item WHERE Item.ItemNum < 10: 
  EXPORT Item.Price. 
  SET Item.Price. 
END. 
INPUT-OUTPUT CLOSE. 
FOR EACH Item WHERE Item.ItemNum < 10 WITH COLUMN 40: 
  DISPLAY Item.ItemNum Item.Price LABEL "Price after recalculation". 
END. 

You can perform this calculation within a single ABL procedure. The C program is used for illustration purposes only. Use a UNIX program outside ABL to execute specialized calculations or processing.

You must unpack the C program from the proguide subdirectory and compile it before you can use it with the r-iothru.p procedure. If you do not have a C compiler, do not try this example.

Following is the C program used by the r-iothru.p procedure:

r-iothru.c
#include <stdio.h> 
#define MAX(a,b)    ( (a < b) ? b : a ) 
main( ) 
{ 
  float cost; 
  /* This is important so that buffering does not   */ 
  /* defeat attempts to actually write on the pipe. */ 
  setbuf(stdout, (char *) NULL); 
  while (scanf("%f", &cost) == 1) { 
    /* Here the item cost is manipulated. We are */ 
    /* increasing the cost by a fixed percentage */ 
    /* (with a minimum increase), to provide     */ 
    /* an example.                               */ 
    cost = cost + MAX( 0.03 * cost, .50); 
    printf("%10.2f\n", cost); 
  } 
} 

Notes
See also

DEFINE STREAM statement, INPUT CLOSE statement, INPUT-OUTPUT CLOSE statement, Stream object handle


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex