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 / ZINDENT5.LBR / SYSTEM.PQS / SYSTEM.PAS
Pascal/Delphi Source File  |  2000-06-30  |  11KB  |  363 lines

  1.  
  2. (*************************************************************)
  3.         PROGRAM     SYSTEM  ;
  4. (*************************************************************)
  5.  
  6. CONST
  7.  
  8.   (* used by SysScr.INC *) (* appears in object code *)
  9.   SysTitle    = 'zINDENT.pas,  Indent for dBASE / Turbo Pascal Source Files';
  10.   SysVersion1 = 'Command via : Line / File / User';
  11.   SysVersion2 = 'version 1000am, sat, 20.Sep.86, Glen Ellis';
  12.   SysCredit   = '                                          ';
  13.  
  14.   SysPgmName  = 'SYSLIST.DAT';  (* file containing filename list *)
  15.  
  16.   (* purpose of program 'System.Pas' : *)
  17.   (* provide core program for applications development *)
  18.  
  19.   (* parameters FOR Compiler *)
  20.      {$C+}
  21.      {$U+}
  22.      {$F4}
  23.  
  24.   (* parameters FOR LISTT.PAS, Borland's advanced Lister program *)
  25.      {.U+}
  26.      {.N-}
  27.      {.P-}
  28.      {.PO0}
  29.  
  30.  
  31. (*####################################################################*)
  32.  
  33.      (*$I B:SYSVAR.INC*) (* for core program *)
  34.      (*$I A:STRING.INC*) (* required string utilties *)
  35.      (*$I A:SYSSCR.INC*) (* screen display procedures *)
  36.      (*$I A:SYSUTL.INC*) (* miscelaneous procedures *)
  37.      (*$I A:SYSDSK.INC*) (* disk file procedures *)
  38.      (*$I A:KEYDB.INC*)  (* keyword dBASE *)
  39.      (*$I A:KEYTP.INC*)  (* keyword Pascal *)
  40.  
  41.  
  42. (********************************************************************)
  43. (*==================================================================*)
  44. (********************************************************************)
  45.  
  46.  
  47. BEGIN (*  MAIN  *)
  48.    
  49.    (*=======> INIT <=======*)
  50.    
  51.    (* programmer's options *)
  52.    
  53.    SysDisplay    := true  ;    (* always true   *)
  54.    SysUserTrace  := true  ;    (* display program path *)
  55.    SysPgmTrace   := true  ;    (* audit developmental path *)
  56.    SysSpcTrace   := false ;    (* special, temporary *)
  57.    
  58.    pSayHeader; (* Display header *) (* SysScr.INC *)
  59.    IF not SysPgmTrace then delay(3000);
  60.    
  61.    (*=======> FETCH <=======*)
  62.    
  63.    (* fetch command line from either paramstring or paramfile
  64.    (* set defaults for operational vars :
  65.    (*   Filename, Indent, Comment, LineCount, Vertiate
  66.    *)
  67.    
  68.    (* set mode flags true *)
  69.    SysCmdLine := true ;
  70.    SysCmdFile := true ;
  71.    SysCmdUser := true ;
  72.    
  73.    (* parameter flags : if satisfied, then lower flag *)
  74.    SysCmdUserFile := true  ;  (* enable fetch *)
  75.    SysCmdUserParm := true  ;
  76.    
  77.    (*=======> FETCH LINE ENTRY *)
  78.    
  79.    IF SysCmdLine then
  80.    begin
  81.       IF SysPgmTrace
  82.          then writeln('--> SysCmdLINE');
  83.       (*$I B:SYSLINE.INC*) (*:::*)
  84.    end;
  85.    
  86.    
  87.    (*=======> FETCH FILE ENTRY *)
  88.    
  89.    IF SysCmdFile then
  90.    begin
  91.       IF SysPgmTrace
  92.          then writeln('---> SysCmdFILE');
  93.       SysInFileName := SysPgmName;  (* read data file name *)
  94.       (*$I B:SYSFILE.INC*) (*:::*)
  95.    end;
  96.    
  97.    
  98.    (*=======> FETCH USER ENTRY *)
  99.    
  100.    IF SysCmdUser then
  101.    begin
  102.       IF SysPgmTrace then writeln('---> SysCmdUSER');
  103.       (*$I B:SYSUSER.INC*) (*:::*)
  104.    end;
  105.    
  106.    (*=======> CORE CONTROLLER <=======*)
  107.    
  108.    (* if filename and parameters installed *)
  109.    IF SysCmdLine or SysCmdFile or SysCmdUser
  110.       then SysEnableCORE := true
  111.    ELSE SysEnableCORE := false;
  112.    
  113.    IF SysUserTrace  (* display list of file names *)
  114.       then pSayFileList; (*::: SysUtl.INC *)
  115.    
  116.    IF SysPgmTrace
  117.       then pSaySysVar;  (* big VAR display prior to CORE *)
  118.    
  119.    (*=======> CORE <=======*)
  120.    
  121.    IF SysEnableCore then
  122.    begin
  123.       
  124.       IF SysPgmTrace then
  125.       begin
  126.          writeln('--- Enable Core ---');
  127.          delay(1000);
  128.       end;
  129.       
  130.       (* init : cmdline/cmdfile/cmduser *)
  131.       IF (SysInSourceMax = 0)
  132.          then SysInSourceMax := 1;
  133.       
  134.       
  135.       (*=========================================*)
  136.       FOR SysInSourceCnt := 1 to SysInSourceMax do
  137.       begin  (* Count Through InSource Array of FileNames *)
  138.          
  139.          (* fetch new filename *)
  140.          
  141.          (* parse for .typ *)
  142.          
  143.          (* start file *)
  144.          
  145.          (* read loop *)
  146.          
  147.          (* load the work var *)
  148.          SysInFileName := SysInSource[SysInSourceCnt];
  149.          
  150.          (*=======> Parse file.typ for mode : OL, DB, TP *)
  151.          
  152.          IF SysPgmTrace then
  153.          begin
  154.             writeln('--- Parse FileName --- ', SysInFileName);
  155.             delay(1000);
  156.          end;
  157.          
  158.          (*:::*)
  159.          pSysParse( SysInFileName, SysPgmMod, SPMSL, SPMSR );
  160.          (*::: SysUtl.INC *)
  161.          
  162.          (*=======> Start Files *)
  163.          
  164.          (* create  three file.type vars for  .BAK, .(source), .$$$
  165.          (*         Open, Reset, Rewrite files *)
  166.          IF SysPgmTrace then
  167.          begin
  168.             writeln('--- Start Files ---');
  169.             delay(1000);
  170.          end;
  171.          
  172.          IF SysPgmTrace then
  173.          begin
  174.             writeln('---> Before Start Files IOcheck = ',SysIOcheck);
  175.             (* delay(1000); (**)
  176.          end;
  177.          
  178.          SysIOcheck := true ; (* any one dead file will skip ! *)
  179.          
  180.          pSysStartFiles(SysIOcheck);  (*::: SysUtl.INC *)
  181.          
  182.          (* IOcheck returned *)
  183.          IF SysPgmTrace then
  184.          begin
  185.             writeln('<--- After Start Files IOcheck = ',SysIOcheck);
  186.             (* delay(1000); (**)
  187.          end;
  188.          
  189.          (*---------------*)
  190.          IF SysIOcheck then
  191.          begin
  192.             
  193.             IF SysUserTrace then
  194.             begin
  195.                writeln('--- Start Read Loop ---');
  196.                delay(1000);
  197.             end;
  198.             
  199.             (* prep for linecnt during WHILE loop *)
  200.             SysLineNum := 0;
  201.             
  202.             (* operational var set to zero *)
  203.             pSysLvlInit;  (*::: SysUtl.INC *)
  204.             
  205.             (*=======> Scan Through File *)
  206.             
  207.             WHILE not (eof(SysInFile))
  208.             do
  209.             begin
  210.                
  211.                (* read text line from input file *)
  212.                readln(SysInFile,SysInLine);
  213.                
  214.                (* assign output string to value read in *)
  215.                SysOutLine := SysInLine;
  216.                
  217.                (*================================================
  218.                (* FOR SYSTEM.PAS this is the primary work core
  219.                (*
  220.                (* title: KEYWORD.INC
  221.                (*
  222.                (* current application flow:
  223.                (*
  224.                (* identify   KEYWORD,    and adjust indent
  225.                (* SysUserTrace start/stop of structures
  226.                (* toggle sysmarkwrite
  227.                (* OutSTR = exit line
  228.                (* indentPOS = current left margin position
  229.                (* indentNUM = actual indent group length
  230.                (* lineMAX   = max length of text line = 79
  231.                (* markWRITE = enable comments write to disk
  232.                *)
  233.                
  234.                (* writing parms are long for indentifiability *)
  235.                (* procedure parms are small so line will be < 127 *)
  236.                
  237.                (* long vars to short vars *)
  238.                pSysVarUPdt; (*::: SysUtl.INC *)
  239.                
  240.                (*
  241.                (*   Indent for dBASE-II
  242.                (**)
  243.                
  244.                IF SysPgmMod = 'DB'
  245.                then
  246.                pKEYDB( SOLL, SIP, SIN, SLM, SMW, SLI, SLC, SLW);
  247.                (*::: KeyDB.INC*)
  248.                
  249.                (*
  250.                (*   Indent for Turbo Pascal
  251.                (**)
  252.                
  253.                IF SysPgmMod = 'TP'
  254.                then
  255.                pKEYTP( SOLL, SIP, SIN, SLM, SMW, SEB,
  256.                SLI, SLC, SLW, SLB, SLR );
  257.                (*::: KeyTP.INC*)
  258.                
  259.                (* next application
  260.                (*   find string in file system , write to single file
  261.                (*   application in Treefile
  262.                (*  pFIND( RefStr, FndStr, fndcnt );*)
  263.                
  264.                (* short vars to long vars *)
  265.                pSysVarDNdt; (*::: SysUtl.INC *)
  266.                
  267.                (* line count prefixer, handled in STRING.INC *)
  268.                (* inc, concates number + string *)
  269.                IF SysLineCnt
  270.                   then pLINECOUNT(SysOutLine, SysLineNum);
  271.                (*::: string.inc *)
  272.                
  273.                (* WRITE the file data *)
  274.                IF (SysMarkWrite)
  275.                   then writeLn(SysOutFile,SysOutLine);
  276.                
  277.                (* DISPLAY data string *)
  278.                IF (SysDisplay) and (SysMarkWrite)
  279.                   then writeln(SysOutLine);
  280.                
  281.             end; (* WHILE not (eof(SysInFile)) do *)
  282.             (*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*)
  283.             
  284.             (* KEYWORD.INC application routine *)
  285.             (* appends level(stack) numbers to tail of OutFile *)
  286.             (* level/error audit trail *)
  287.             pSysLvlWrite; (*::: SysUtl.INC *)
  288.             
  289.             (*===================================*)
  290.             IF SysPgmTrace
  291.                then writeln('--- Close Files ---');
  292.             close(SysInFile);   (*  InFile.CMD *)
  293.             close(SysOutFile);  (* OutFile.TXT *)
  294.             
  295.             
  296.             (* LineCnt would produce a un-runnable command file *)
  297.             (* do not allow generated file to become file.CMD *)
  298.             (* else, OK to rename files *)
  299.             IF (not SysLineCnt)
  300.             then
  301.             begin
  302.                (* if SysPgmMod not "  " then type is recognized *)
  303.                (* mode must be valid, else leave file as .$$$ *)
  304.                pSysReName(SysIOcheck); (*::: SysUtl.INC *)
  305.             end;
  306.             
  307.             (* KEYWORD application routine *)
  308.             (* sends level(stack) numbers to video *)
  309.             (* works with KEYWORD.INC *)
  310.             
  311.             IF SysDisplay then
  312.             begin
  313.                
  314.                IF SysPgmMod = 'DB' then
  315.                writeln(SPMSL, ':I:',SLI,'  :C:',SLC,'  :W:',SLW, SPMSR);
  316.                
  317.                IF SysPgmMod = 'TP' then
  318.                writeln(SPMSL,'=B=',SLB,SPMSR);
  319.                
  320.             end;
  321.             
  322.             IF SysUserTrace
  323.                then writeln('--- End Read Loop --- Close Files ---');
  324.             
  325.          end; (* if SysIOcheck true *)
  326.          
  327.          IF not SysIOcheck
  328.             then writeln('SysIOcheck  = ',SysIOcheck);
  329.          
  330.          (*---------------------------*)
  331.          
  332.       end; (* FOR SysInSourceCnt := 1 to SysInSourceMAX *)
  333.       (*================================================*)
  334.       (* bottom of count through insource array *)
  335.       
  336.    end; (* IF SysEnableCore *)
  337.    (*///////////////////////*)
  338.    
  339.    (*=======> NOT CORE <=======*)
  340.    
  341.    (* IF no parameters entered, *)
  342.    (* then default is documentation / InStructions *)
  343.    
  344.    IF not SysEnableCore
  345.       then pSaySysDoc; (*::: SysScr.INC *)
  346.    
  347.    
  348. END.  (*  MAIN  *)
  349.  
  350. (*=====================================================================*)
  351. (*:B:0*)
  352. (*:B:0*)
  353. (*:B:0*)
  354. (*:B:0*)
  355. (*:B:0*)
  356. (*:B:0*)
  357. ===============================================================*)
  358. (*:B:0*)
  359. (*:B:0*)
  360. (*:B:0*)
  361. (*:B:0*)
  362. (*:B:0*)
  363. (*:B:0*)