!       UTRING.BAS - puts 5 spaces at the beginning of each line to
!                       make room for the holes punched for a ring binder
!
!       Copyright @1985 by David W. Barrow III
!
! Date          Who     L What
!--------       ---     - ---------------------------------------------------
!05-23-85       DWB     A Original Coding
!

MAP1    VERSION,S,9,"VER052385"
PROGRAM PGMNAM,85.05A(23)

! MAPS
MAP1  IO'MAPS
 MAP2  COUNTER,F,6,0
 MAP2  INPUT'FILE'EXT,S,4,".   "
 MAP2  INPUT'FILE'NAME,S,6,""
 MAP2  INPUT'LINE,S,80,""
 MAP2  OUTPUT'FILESPEC,S,10,""
 MAP2  OUTPUT'LINE,S,80,""

! HOUSEKEEPING:
       ! Standard Error Routine
       ON ERROR GOTO ERR'ROUTINE

       PRINT TAB(-1,0)         ! Clear screen
       PRINT TAB(01,05); "UTRING is a Utility program to take a file ";  &
               "and add 5 spaces to the"
       PRINT TAB(02,01); "beginning of each line in order to make room ";  &
               "for holes for a 3 ring binder."
       PRINT TAB(04,05); "Written by David W. Barrow III of the Stonewall"; &
               " Computer Center"
       PRINT TAB(06,01)
       STOP

       PRINT TAB(09,01); "What is the name of the input program (NNNNNN) : ";
       INPUT INPUT'FILE'NAME

GET'EXT:
       PRINT TAB(11,01); "What is the extention of the input file (.NNN) : ";
       INPUT INPUT'FILE'EXT
       ! Check for period
               IF      ( INPUT'FILE'EXT[1,1] # "." )   &
               THEN    GOTO GET'EXT

       OUTPUT'FILESPEC = INPUT'FILE'NAME + ".NBK"

       OPEN #1, INPUT'FILE'NAME + INPUT'FILE'EXT, INPUT
       OPEN #2, OUTPUT'FILESPEC, OUTPUT

! MAINLINE:
       FOR COUNTER = 1 TO 10000
               INPUT LINE #1, INPUT'LINE
               ! Check for end of file
                       IF      ( EOF(1) # 0 )  &
                       THEN    COUNTER = 10000
               OUTPUT'LINE = SPACE$(5) + INPUT'LINE
               PRINT #2; OUTPUT'LINE
       NEXT COUNTER

! EXIT:
       CLOSE #1
       CLOSE #2
       XCALL SPOOL, OUTPUT'FILESPEC
       END

               !!!!!!!!!!!!!!!!!!!!!!!
               ! PROGRAM SUBROUTINES !
               !!!!!!!!!!!!!!!!!!!!!!!



               !!!!!!!!!!!!!!!!!!!!!!!!
               ! STANDARD SUBROUTINES !
               !!!!!!!!!!!!!!!!!!!!!!!!

ERR'ROUTINE:
       ! Check for AlphaBASIC error
               IF      ( ERR(0) = 0 )  &
               THEN    GOTO ISAM'ERROR
       ! Display Basic error
       PRINT TAB(-1,0)                         ! Clear Screen
       PRINT TAB(12,15); "?? Fatal AlphaBASIC Error "; STR$(ERR(0))
       ON ERR(0) CALL C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, &
                       C11, C12, C13, C14, C15, C16, C17, C18, C19, C20,  &
                       C21, C22, C23, C24, C25, C26, C27, C28, C29, C30,  &
                       C31, C32, C33, C34, C35, C36, C37, C38, C39, C40,  &
                       C41, C42, C43, C44, C45, C46
               IF      ( ERR(1) )      &
               THEN    PRINT TAB(13,15); " on the line after "; STR$(ERR(1))
               IF      ( ERR(2) )      &
               THEN    PRINT TAB(14,15); " on Channel "; STR$(ERR(2))
       GOTO ERROR'ABORT

ISAM'ERROR:
!               IF      (

ERROR'ABORT:
       PRINT TAB(20,15); "!! Contact System Operator Immediately !!"
       PRINT TAB(21,01);
       END

C1:
       PRINT "Control-C interrupt";
       RETURN

C2:
       PRINT "System Error";
       RETURN

C3:
       PRINT "Out of Memory";
       RETURN

C4:
       PRINT "Out of Data";
       RETURN

C5:
       PRINT "NEXT without FOR";
       RETURN

C6:
       PRINT "RETURN without GOSUB";
       RETURN

C7:
       PRINT "RESUME without ERROR";
       RETURN

C8:
       PRINT "Subscript out of range";
       RETURN

C9:
       PRINT "Floating Point overflow";
       RETURN

C10:
       PRINT "Divide by zero";
       RETURN

C11:
       PRINT "Illegal function value";
       RETURN

C12:
       PRINT "XCALL subroutine not found";
       RETURN

C13:
       PRINT "File already open";
       RETURN

C14:
       PRINT "IO to unopened file";
       RETURN

C15:
       PRINT "Record size overflow";
       RETURN

C16:
       PRINT "File specification error";
       RETURN

C17:
       PRINT "File not found";
       RETURN

C18:
       PRINT "Device not ready";
       RETURN

C19:
       PRINT "Device full";
       RETURN

C20:
       PRINT "Device error";
       RETURN

C21:
       PRINT "Device in use";
       RETURN

C22:
       PRINT "Illegal user code";
       RETURN

C23:
       PRINT "Protection Violation";
       RETURN

C24:
       PRINT "Write protected";
       RETURN

C25:
       PRINT "File type mismatch";
       RETURN

C26:
       PRINT "Device does not exist";
       RETURN

C27:
       PRINT "Bitmap kaput";
       RETURN

C28:
       PRINT "Disk not mounted";
       RETURN

C29:
       PRINT "File already exists";
       RETURN

C30:
       PRINT "Redimentioned array";
       RETURN

C31:
       PRINT "Illegal record number";
       RETURN

C32:
       PRINT "Invalid filename";
       RETURN

C33:
       PRINT "Stack overflow";
       RETURN

C34:
       PRINT "Invalid syntax code";
       RETURN

C35:
       PRINT "Unsupported function";
       RETURN

C36:
       PRINT "Invalid subroutine version";
       RETURN

C37:
       PRINT "File in use";
       RETURN

C38:
       PRINT "Record in use";
       RETURN

C39:
       PRINT "Deadly embrace";
       RETURN

C40:
       PRINT "File cannot be deleted";
       RETURN

C41:
       PRINT "File cannot be renamed";
       RETURN

C42:
       PRINT "Record not locked";
       RETURN

C43:
       PRINT "Multiple link translation";
       RETURN

C44:
       PRINT "LOKSER queue is full";
       RETURN

C45:
       PRINT "Device not file structured";
       RETURN

C46:
       PRINT "Illegal ISAM sequence";
       RETURN


!                       ******* END OF PGMNAM.BAS *******