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 / CROSSREF.ARK / CR-M04.INC < prev    next >
Text File  |  1987-04-18  |  5KB  |  169 lines

  1. {.pa}
  2. {****************************** function Compare ****************************}
  3.  
  4. function Compare (var Source,Table :NameType) :boolean;
  5.  
  6. { This function will compare the two file names to determine if they're the
  7.   same. }
  8.  
  9. var
  10.    I :integer;
  11.  
  12. begin
  13.    for I := 1 to length(Source) do
  14.       Source[I] := upcase(Source[I]);
  15.    for I := 1 to length(Table) do
  16.       Table[I] := upcase(Table[I]);
  17.    if Source = Table then
  18.       Compare := true
  19.    else
  20.       Compare := false;
  21. end;   { function Compare }
  22. {.pa}
  23. {**************************** procedure OpenFile ****************************}
  24.  
  25. procedure OpenFile(var InFile,TableFile :text;
  26.                    var Stop             :boolean;
  27.                    var SourceName,
  28.                        TableName        :NameType);
  29.  
  30. { This procedure allows the user to enter the source file name and it will
  31.   open the file.  Then it will allow the user to enter the Table and Listing
  32.   file names. }
  33.  
  34. var
  35.    Valid    :boolean;                    { program name valid }
  36.  
  37. begin
  38.    repeat
  39.       gotoxy(1,14); write('Enter source file name? (Return to exit) ');
  40.       buflen := 14;
  41.       readln(SourceName); ClrEol;
  42.       assign(InFile,SourceName);
  43.       {$I-} reset(InFile); {$I+}          { error checking }
  44.       Valid := (IOresult = 0);
  45.       if SourceName = '' then
  46.          Stop := true                     { don't cross-ref a program }
  47.       else
  48.          if not Valid then
  49.             begin
  50.                gotoxy(5,15); write(chr(7),'File ',SourceName,' not found.')
  51.             end
  52.    until Valid or Stop;
  53.    if not Stop then
  54.       begin
  55.          gotoxy(1,15); ClrEol;
  56.          repeat
  57.             gotoxy(1,16);
  58.             write('Enter table output file name? ');    { enter table name }
  59.             buflen := 14;
  60.             readln(TableName); ClrEol;
  61.             if Compare(SourceName,TableName) then
  62.                begin
  63.                   gotoxy(5,17); write(chr(7),'Cannot have same file names!');
  64.                   Valid := false;
  65.                end
  66.             else
  67.                Valid := true;
  68.          until Valid and (length(TableName) > 0);
  69.          assign(TableFile,TableName);
  70.          rewrite(TableFile);
  71.          gotoxy(1,14); ClrEol;
  72.          gotoxy(1,16); ClrEol;
  73.          gotoxy(1,17); ClrEol;
  74.       end;
  75. end;   { procedure EnterFileName }
  76. {.pa}
  77. {************************* function AnotherCross ****************************}
  78.  
  79. function AnotherCross: boolean;
  80.  
  81. { This function prompts the user with a question whether to cross-reference
  82.   another program.  A true boolean flag is returned if the response is 'Y',
  83.   otherwise false. }
  84.  
  85. var
  86.    Response:char;           { answer to question }
  87.  
  88. begin
  89.    if not Stop then
  90.       begin
  91.          writeln;
  92.          repeat
  93.             gotoxy(1,23);
  94.             write('Do you want to cross-reference another program? (Y/N) ');
  95.             buflen := 1;
  96.             readln(Response);
  97.          until Response in ['Y','y','N','n'];
  98.          AnotherCross := (Response in ['Y','y']);
  99.       end
  100.    else
  101.       AnotherCross := false;
  102. end;  { procedure AnotherCross }
  103. {.pa}
  104. {*************************** procedure InitializeTree ***********************}
  105.  
  106. procedure InitializeTree (var Tree :TreePointer);
  107.  
  108. begin
  109.    mark(Tree);
  110.    release(Tree);
  111.    Tree := nil;
  112. end;  { procedure InitializeTree }
  113.  
  114. {************************ procedure InitializeStatus ************************}
  115.  
  116. procedure InitializeStatus (var Status :Info);
  117.  
  118. { This procedure will initialize the variables of Status. }
  119.  
  120. var
  121.    I :Index;          { loop index }
  122.  
  123. begin
  124.    with Status do
  125.       begin
  126.          TotalLines := 0;
  127.          CommentLines := 0;
  128.          BlankLines := 0;
  129.          Comments := 0;
  130.          TotalIdents := 0;
  131.          DifferentIdents := 0;
  132.          TotalReserved := 0;
  133.          MostUsedNumber := 0;
  134.          LeastUsedNumber := MaxInt;
  135.          AvgIdentLength := 0.0;
  136.          for I := 1 to MaxIdentLength do
  137.             begin
  138.                MostUsedIdent[I] := ' ';
  139.                LeastUsedIdent[I] := ' '
  140.             end;
  141.          for I := 1 to MaxReservedWords do
  142.             UsedReserved[I] := 0;
  143.       end   { with Status }
  144. end;  { procedure InitializeStatus }
  145. {.pa}
  146. {***************************** procedure Titles ******************************}
  147.  
  148. procedure Titles;
  149.  
  150. { This procedure will display the title's of the program. }
  151.  
  152. begin
  153.    clrscr;
  154.    gotoxy(33,1); write('Cross Reference');
  155.    gotoxy(64,1); write('version 4');
  156.    gotoxy(30,2);
  157.    writeln ('Written by Milton Hom');
  158.    writeln;
  159.    writeln ('      This program will produce a cross reference table of');
  160.    writeln ('      identifiers and perform a simple analysis of a TURBO');
  161.    writeln ('      Pascal program.  The table and analyis will be written');
  162.    writeln ('      to a disk file specified by the user.');
  163.    writeln;
  164.    writeln ('      NOTE:');
  165.    writeln ('         Include file(s) are not recognized by this program.');
  166.    writeln ('         They must be cross referenced individually.');
  167.    writeln
  168. end;   { procedure Titles }
  169.