## edi/ordernun - ORDERNET COMMUNICATIONS TEMPLATE - UNIX
##                Stuart Richler 12/10/97
##
## ************************************************************************* *
##             This is an unpublished work created in 1984 through 1998      *
## G.T.R. DATA INC. owns all rights to this work and intends to keep         *
## the work confidential so as to maintain its value as a trade secret.      *
## G.T.R. DATA INC. may also seek to protect this work as an unpublished     *
## copyright work. In the event of either inadvertent or deliberate          *
## publication,  G.T.R. DATA INC.  intends to enforce its rights for this    *
## work under the copyright laws as a published work; and to that end,       *
## G.T.R. DATA INC.   hereby affixes the following statutory notice:         *
##              (C) Copyright, G.T.R. DATA INC.  1984 through 1998.          *
## ************************************************************************* *
##
## This job file requires the following other files:
##
##
##
#################################################

## Monitor command in var1

|var1|

## Config file

CONFIG |var2|
LET PROTOCOL=ASCII
|var3|
LET DEVICE=|device|
LET MODEMINIT=|var4|
LET informat=|inform|

## Dial up

10 AUTODIAL |tel-no| T60 R|no-attempts|

BRANCH ON BUSY TO 10
BRANCH ON DIAL_ABORT TO 150
BRANCH NOT OK TO 150

##LOGON

KEY
FIND ":"
KEY +
FIND ":"
KEY ONET,SSGATE
FIND "Connected to ONET"
KEY |var7|
FIND "SUPERTRACS READY FOR INPUT"

LOG Logged onto Ordernet.

## Send

## Check if the lock file exists in the output directory
EXISTS |outdir|/lock
BRANCH ON NOFILE TO 50
LOG Output Directory is currently locked...try again later.
BRANCH ON TRUE TO 80

## Check if there is anything to send
50 EXISTS |outdir|/|outfile|
BRANCH ON NOFILE TO 80

## There is, so append the job card record to the top of the file
OPEN |outdir|/ident -O
WRITE \036\036ADD ID=|userid| BATCHID='|password|'\013
CLOSE
SYSTEM cat |outdir|/ident |outdir|/|outfile| > |outdir|/sendfile

## Send file to Ordernet
SEND |outdir|/sendfile
KEY \04
BRANCH NOT NRMEOF TO 500

LOG Output file |outdir|/|outfile| sent.

## Erase send file
SYSTEM rm |outdir|/|outfile|


## Receive
FIND "SUPERTRACS READY FOR INPUT"
80 KEY \036\036REQUEST ID=|userid| BATCHID='|password|'\013\004 -R
RECEIVE |indir|/temp

LOG File |indir|/temp received.


VOICE
LOG Signed off from Ordernet.

## Check for directory lock on receive directory.
EXISTS |indir|/lock
BRANCH ON NOFILE TO 100
LOG Input file received but not transferred to |indir|/|infile|
LOG because direcory is locked.
BRANCH ON TRUE TO 800

## Make list of input files
100 SYSTEM |var6| |indir|/temp*.* > |indir|/filelist
OPEN |indir|/filelist

110 READ filename
BRANCH ON NODATA TO 120

## Check to see if file is wrapped, if it is then unwrap it.
IF $informat=no
  SYSTEM |var5| $filename
ENDIF

## Concatenate file to Input file.
SYSTEM cat |indir|/|infile| $filename > |indir|/tempfile
SYSTEM mv |indir|/tempfile |indir|/|infile|
BRANCH ON TRUE TO 110


## Finished; erase input files
120 SYSTEM rm |indir|/temp*.*




QUIT

150 VOICE
LOG Errored out on call
QUIT 10

500 VOICE
LOG Ordernet transmission of file |outdir|/|outfile| failed.
QUIT 50

800 VOICE
LOG Ordernet receipt of file |indir|/temp failed.
QUIT 80