home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / kiskometer / makelibnames.rexx < prev    next >
OS/2 REXX Batch file  |  1977-12-31  |  2KB  |  75 lines

  1. /*\
  2.  *  This function converts any FD file into a Library offset file
  3.  *  for Kiskometer.
  4. \*/
  5.  
  6. parse arg source " " dest " " libname
  7.     ec=0;
  8.  
  9.     if open(infile,source,'r') then do
  10.         if open(outfile,dest,'w') then do
  11.             call writeln(outfile,"LIBRARYOFFSETFILE")
  12.             call writeln(outfile,libname)
  13.             privatefunc=1;
  14.             liboffs=0;
  15.             do while ~eof(infile)
  16.                 line=readln(infile)
  17.                 if left(line,1)~=='*' then do                            /* No comment line */
  18.                     if left(line,2)=='##' then do
  19.                         if left(line,8)=='##public' then
  20.                             privatefunc=0
  21.                         else if left(line,9)=='##private' then
  22.                             privatefunc=1
  23.                         else if left(line,5)=='##end' then
  24.                             leave
  25.                         else if left(line,7)=='##bias ' then do
  26.                             newoffs=strip(substr(line,8))
  27.                             do while liboffs<newoffs
  28.                                 if liboffs=6 then
  29.                                     call writeln(outfile,"Lib_Open")
  30.                                 else if liboffs=12 then
  31.                                     call writeln(outfile,"Lib_Close")
  32.                                 else if liboffs=18 then
  33.                                     call writeln(outfile,"Lib_Expunge")
  34.                                 else if liboffs=24 then
  35.                                     call writeln(outfile,"Lib_Null")
  36.                                 else if liboffs~=0 then do
  37.                                     printed=0;
  38.                                     if right(libname,7)==".device" then do
  39.                                         printed=1
  40.                                         if liboffs=30 then
  41.                                             call writeln(outfile,"Lib_BeginIO")
  42.                                         else if liboffs=36 then
  43.                                             call writeln(outfile,"Lib_AbortIO")
  44.                                         else
  45.                                             printed=0
  46.                                     end
  47.                                     if printed=0 then
  48.                                         call writeln(outfile,"Lib_Offs_"||liboffs)
  49.                                 end
  50.                                 liboffs=liboffs+6
  51.                             end
  52.                         end
  53.                     end
  54.                     else do                                                    /* Function description */
  55.                         parse var line funcname "("
  56.                         call writeln(outfile,funcname)
  57.                         liboffs=liboffs+6
  58.                     end
  59.                 end
  60.             end
  61.             call close(outfile)
  62.         end
  63.         else do
  64.             say "Could not open »"||dest||"« to write."
  65.             ec=10
  66.         end
  67.         call close(infile)
  68.     end
  69.     else do
  70.         say "Could not open »"||source||"« to read."
  71.         ec=10
  72.     end
  73.  
  74. exit ec
  75.