SAS-00  Spike & Sparky Sample App                                        Page: 1
JPN 12/01/97 15:06                            Technical Documentation (ILF Only)
Process Type:       SUBROUTINE  Process Name:     IMPORT TEXT FILE
                                Description:      Import Text File
STMT PROC KEY IMPORT TEXT FILE


Frm Class:  RECORD      Frm Seq:            Alt Img No:        Chld Seq
                                                               or   Opt
Start Of Process
================================================================================
      *        See Note 1
      CNV BIN  --- CDF HEX00                  =      0
      CNV BIN  --- CDF HEX0A                  =      10
      SET      --- CDF PATH & FILE NAME       =      /tmp/custin.txt
      APPEND   --- CDF PATH & FILE NAME       0  --- CDF HEX00
      SET      --- CDF TYPE                   =      r
      APPEND   --- CDF TYPE                   0  --- CDF HEX00
      PASS     --- CDF PATH & FILE NAME       FIELD            SHARE? Y
      PASS     --- CDF TYPE                   FIELD            SHARE? Y
      PASS     --- CDF FILE POINTER           FIELD            SHARE? Y
      CALL         ,RT_OPEN_STREAM            RESIDENT? Y  END? N  FAIL 0
      IF       --- RETURN CODE                NE     +1
T     CANCEL   Unable to Open Input File
      *        See Note 2
      LABEL    :READ A LINE
      SET      --- TEMP 256                   =
      PASS     --- TEMP 256                   FIELD            SHARE? Y
      SET      --- LI                         =      256
      PASS     --- LI                         FIELD            SHARE? Y
      PASS     --- CDF FILE POINTER           FIELD            SHARE? Y
      CALL         ,RT_READ_STREAM            RESIDENT? Y  END? N  FAIL 0
      IF       --- RETURN CODE                EQ     +1
T     GOSUB        :PARSE LINE
T     GOSUB        :MOVE TO OUTPUT
T     GOTO     :READ A LINE
      *        Standard close routine
      PASS     --- CDF FILE POINTER           FIELD            SHARE? Y
      CALL         ,RT_CLOSE_STREAM           RESIDENT? Y  END? N  FAIL 0
      RETURN
      *
      *        Subroutines
      *
      LABEL    :PARSE LINE
      *        parses tab delimited input field, returns results in WORK ARRAY
      *        See Note 3
      SET      --- TEMP 1                     =
      BEG LOOP II = 001 TO 030  STEP 001
      SET      SAS WORK ARRAY             II  =
      END LOOP II
      *        first strip trailing binary data
      IF       --- TEMP 256                   IN --- CDF HEX00
T     SET      --- XI                         =  --- TEXT AT POSITION
T     COMPUTE  --- XI                         -      1
T     SET      --- TEMP 512                   =
T     SET TEMP 512   AT 001 FOR XI  FROM 001 OF  --- TEMP 256
T     SET      --- TEMP 256                   =  --- TEMP 512
      IF       --- TEMP 256                   IN --- CDF HEX0A
T     SET      --- XI                         =  --- TEXT AT POSITION
T     COMPUTE  --- XI                         -      1
T     SET      --- TEMP 512                   =
T     SET TEMP 512   AT 001 FOR XI  FROM 001 OF  --- TEMP 256
T     SET      --- TEMP 256                   =  --- TEMP 512
      CNV BIN  --- CDF HEX0A                  =      13
      IF       --- TEMP 256                   IN --- CDF HEX0A
T     SET      --- XI                         =  --- TEXT AT POSITION
T     COMPUTE  --- XI                         -      1
T     SET      --- TEMP 512                   =
T     SET TEMP 512   AT 001 FOR XI  FROM 001 OF  --- TEMP 256
T     SET      --- TEMP 256                   =  --- TEMP 512
      *        begin parsing
      CNV BIN  --- TEMP 1                     =      9
      SET      --- II                         =      1
      LABEL    :PARSE AGAIN
      SET      --- TEMP 512                   =
      IF       --- TEMP 256                   IN --- TEMP 1
T     SET      --- XI                         =  --- TEXT AT POSITION
T     COMPUTE  --- XI                         -      1
T     SET TEMP 512   AT 001 FOR XI  FROM 001 OF  --- TEMP 256
T     SET      SAS WORK ARRAY             II  =  --- TEMP 512
T     COMPUTE  --- XI                         +      2
T     SET      --- TEMP 512                   =
T     SET TEMP 512   AT 001 FOR 512 FROM XI  OF  --- TEMP 256
T     SET      --- TEMP 256                   =  --- TEMP 512
T     COMPUTE  --- II                         +      1
T     GOTO     :PARSE AGAIN
      SET      SAS WORK ARRAY             II  =  --- TEMP 256
      RETURN
      *
      LABEL    :MOVE TO OUTPUT
      SET      1EX VENDOR NO                  =  SAS WORK ARRAY             001
      SET      1EX VENDOR NAME                =  SAS WORK ARRAY             002
      WRITE    1EX VENDOR              FAIL 0
      RETURN