home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / intel86 / itemize.p86 < prev    next >
Text File  |  2020-01-01  |  3KB  |  84 lines

  1. $large
  2.  
  3. itemize: do;
  4.     /*
  5.      *  This program copies each pathname given by the input filespec
  6.      *  to the corresponding output file.  It is intended to be used
  7.      *  with a single output file and a wild-card input pathname, in
  8.      *  which case it places in that output file all pathnames matching
  9.      *  the input filespec.
  10.      *
  11.      *  by Albert J. Goodman; Edit date:  6-June-1985
  12.      */
  13.  
  14. /* Get all iRMX 86 system call external declarations */
  15. $include(:I:RMX.EXT)
  16.  
  17. declare
  18.     CR      literally   '0Dh',      /* ASCII Carriage-return character */
  19.     LF      literally   '0Ah',      /* ASCII Line-feed character */
  20.     ( input$pathname, output$pathname ) structure(
  21.                                             len     byte,
  22.                                             ch(80)  byte),
  23.     output$preposition                  byte,
  24.     output$connection                   token,
  25.     ( bytes$written, status )           word,
  26.     exception$handler$info              structure(
  27.                                             offset  word,
  28.                                             base    word,
  29.                                             mode    byte);
  30.  
  31. check$excep: procedure;     /* Check for an exception code */
  32.     if ( status <> E$OK ) then  /* we got an exceptional condition */
  33.         call rq$exit$io$job( status, 0, @status );  /* abort the program */
  34. end check$excep;
  35.  
  36. /* begin ITEMIZE */
  37. /* Disable our exception handler, so control never passes to it. */
  38. exception$handler$info.offset = 0;
  39. exception$handler$info.base = 0;
  40. exception$handler$info.mode = 0;
  41. call rq$set$exception$handler( @exception$handler$info, @status );
  42. call check$excep;
  43.  
  44. /* get the first input pathname */
  45. call rq$c$get$input$pathname( @input$pathname, size( input$pathname ),
  46.                                     @status );
  47. call check$excep;
  48. /* while we have any more pathnames */
  49. do while ( input$pathname.len > 0 );
  50.     /* Get the matching output pathname (default to command output) */
  51.     output$preposition = rq$c$get$output$pathname( @output$pathname,
  52.                                     size( output$pathname ),
  53.                                     @( 7,'TO :CO:' ), @status );
  54.     call check$excep;
  55.     /* Get a connection to the output file */
  56.     output$connection = rq$c$get$output$connection( @output$pathname,
  57.                                     output$preposition, @status );
  58.     call check$excep;
  59.     /* Copy the input pathname to the output file */
  60.     bytes$written = rq$s$write$move( output$connection, @input$pathname.ch,
  61.                                     input$pathname.len, @status );
  62.     call check$excep;
  63.     /* Append a carriage-return/line-feed line terminator */
  64.     bytes$written = rq$s$write$move( output$connection, @( CR,LF ),
  65.                                     2, @status );
  66.     call check$excep;
  67.     /* Close the output file */
  68.     call rq$s$close( output$connection, @status );
  69.     call check$excep;
  70.     /* And delete the output connection */
  71.     call rq$s$delete$connection( output$connection, @status );
  72.     call check$excep;
  73.     /* Get the next input pathname, if any */
  74.     call rq$c$get$input$pathname( @input$pathname, size( input$pathname ),
  75.                                     @status );
  76.     call check$excep;
  77. end;    /* do while ( input$pathname.len > 0 ) */
  78.  
  79. /* Terminate the program, signalling O.K. */
  80. call rq$exit$io$job( E$OK, 0, @status );
  81.  
  82. end itemize;
  83.  
  84.