home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / TURBOPAS / TLIST.LBR / INCLUDE.PQS / include.pas
Pascal/Delphi Source File  |  2000-06-30  |  2KB  |  74 lines

  1. PROCEDURE Includes(VAR Line : Line_Type;
  2.                    VAR Include_file_present : BOOLEAN;
  3.                    VAR Include_file_name : Filename_Type);
  4. {
  5. Include_file_present is TRUE if an Include compiler directive is in
  6. the line.  It also must be flush with the comment bracket to be recognized;
  7. thus, if an include takes the following form, { $I filename.ext..., it will be
  8. neither included during a compilation nor during a listing with this program.
  9. It was lifted and modified from program: LISTER.PAS, supplied by Borland.  It
  10. must be called before the line is "processed" so that the string flag
  11. represents a continuing string before the line.  I. e., the include directive
  12. is not recognized if it is within a string definition.
  13. }
  14.  
  15. VAR
  16.  Name_start, Name_end : INTEGER;
  17.  
  18. BEGIN
  19.  Ch := '-';
  20.  Dummy := POS('{$I', Line);
  21.  IF Dummy <> 0 THEN
  22.   BEGIN
  23.    Name_start := Dummy + 3;
  24.    Ch := Line[Name_start];
  25.   END
  26.  ELSE
  27.   BEGIN
  28.    Dummy := POS('(*$I', Line);
  29.    IF Dummy <> 0 THEN
  30.     BEGIN
  31.      Name_start := Dummy + 4;
  32.      Ch := Line[Name_start];
  33.     END
  34.    ELSE
  35.     BEGIN
  36.      Dummy := POS('{$i', Line);
  37.      IF Dummy <> 0 THEN
  38.       BEGIN
  39.        Name_start := Dummy + 3;
  40.        Ch := Line[Name_start];
  41.       END
  42.      ELSE
  43.       BEGIN
  44.        Dummy := POS('(*$i', Line);
  45.        IF Dummy <> 0 THEN
  46.         BEGIN
  47.          Name_start := Dummy + 4;
  48.          Ch := Line[Name_start];
  49.         END;
  50.       END;
  51.     END;
  52.   END;
  53.  Include_file_present := NOT (Ch IN ['+', '-']);
  54.  FOR I := 1 TO Dummy - 1 DO
  55.   IF Line[I] = '''' THEN Include_file_present := NOT Include_file_present;
  56.  IF Strng THEN Include_file_present := NOT Include_file_present;
  57.  
  58.  IF Include_file_present THEN
  59.   BEGIN
  60.   {
  61.   This section parses for a filename within the line, following the include
  62.   directive.  It was lifted from program: LISTER.PAS, supplied by Borland.
  63.   }
  64.    WHILE Line[Name_start] = ' ' DO
  65.     Name_start := SUCC(Name_start);
  66.    Name_end := Name_start;
  67.    WHILE (NOT (Line[Name_end] IN [' ', '}', '*']))
  68.     AND ((Name_end - Name_start) <= Filename_Length) DO
  69.      Name_end := SUCC(Name_end);
  70.    Name_end := PRED(Name_end);
  71.    Include_file_name := COPY(Line, Name_start, (Name_end - Name_start + 1));
  72.   END;
  73. END;
  74.