home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / spoc88 / proasm / dump.pro < prev    next >
Text File  |  1988-06-09  |  2KB  |  87 lines

  1. /*
  2.  
  3.         NOTE:  This program links in two external object
  4.         files: open.obj and read.obj.  Assemble these
  5.         files using Turbo Assembler. Be sure to compile
  6.         this program as
  7.         a project.
  8.  
  9.         If compiling as a project, create a project file
  10.         called "dump.prj" with the following text:
  11.  
  12.         simple
  13.         open
  14.         read
  15.  
  16.         To compile, choose "Project" from the "Compile"
  17.         pulldown Menu, and selct the appropriate project file.
  18. */
  19.  
  20. PROJECT "SIMPLE"
  21.  
  22. global DOMAINS
  23.   file = infile
  24.   STRINGLIST = STRING*
  25.   INTEGERLIST  = INTEGER*
  26.  
  27. GLOBAL PREDICATES
  28.  
  29.    open(STRING,INTEGER) - (i,o) language asm
  30.    read(INTEGER,INTEGER,INTEGER) - (i,o,o) language asm
  31.  
  32. PREDICATES
  33.  
  34.    run
  35.    readfile(STRING)
  36.       repeat
  37.       processBYTE(INTEGER,INTEGER)
  38.  
  39. GOAL
  40.  
  41.    run.
  42.  
  43. CLAUSES
  44.  
  45. /****************************** run *******************************/
  46.  
  47.    run if
  48.  
  49.      makewindow(1,7,7,"Test of OPEN and READ routines ",0,0,25,80),
  50.      cursor (5,10),
  51.      write("Enter filename: "), 
  52.      readln(Filename),
  53.      clearwindow,nl,nl,
  54.      readFILE(FileNAME).
  55.  
  56. /***************************** readfile ***************************/
  57.  
  58.    readFILE(FileNAME) if
  59.       open(FileNAME,FileHANDLE),
  60.       FileHANDLE <> 255,     /* Check for error in opening file */
  61.       repeat,                /* we backtrack to here if not EOF */
  62.       read(FileHANDLE,NumberBYTESread,ReadBUF),
  63.       processBYTE(NumberBYTESread,ReadBUF),
  64.       NumberBYTESread = 0,!. /* Check for end of file. */
  65.    readFILE(FileNAME) if !,
  66.       removewindow,
  67.       write("Sorry, unable to open ",FileNAME,"."),nl,
  68.       exit.
  69.  
  70. /****************************** repeat ****************************/
  71.  
  72.    repeat.
  73.    repeat if
  74.       repeat.     
  75.  
  76. /**************************** processBYTE *************************/
  77.  
  78.    processBYTE(NumberBYTESread,ReadBUF) if
  79.       NumberBYTESread <> 0,
  80.       write(ReadBUF," "), !.
  81.    processBYTE(0,_) if !,
  82.       nl,
  83.       write("End of file."),
  84.       nl.
  85.  
  86. /*********************** END OF DUMP.PRO **************************/
  87.