home *** CD-ROM | disk | FTP | other *** search
/ Share Gallery 1 / share_gal_1.zip / share_gal_1 / LA / LA010.ZIP / DEMO.PAS < prev    next >
Pascal/Delphi Source File  |  1980-01-01  |  14KB  |  444 lines

  1. Program demo;
  2.  
  3.  
  4. {This program can be used standalone to enter data in
  5. a file for later processing, or it can be incorporated 
  6. as a procedure in some other program that you develop.
  7. Don't forget to change the first word to "Procedure" 
  8. and the last period to a semi-colon if you want to use 
  9. it as a procedure.} 
  10.  
  11.  
  12.  
  13. Const 
  14.   Windows =  8;  { the number of input fields that you defined in your screen }
  15.   Wtab       : array[1..Windows, 1..7] of Integer = (
  16.               (0, 7, 78, 63, 6, 66, 6),
  17.               (0, 7, 78, 59, 8, 60, 8),
  18.               (0, 7, 78, 62, 8, 63, 8),
  19.               (0, 7, 78, 65, 8, 66, 8),
  20.               (0, 7, 78, 24, 10, 49, 10),
  21.               (0, 7, 78, 60, 10, 66, 10),
  22.               (0, 7, 78, 25, 12, 27, 12),
  23.               (0, 7, 78, 39, 12, 66, 12));
  24.              { |  |  |   |   |   |   |
  25.                |  |  |   |   |   |   |
  26.                |  |  |   |   |   |   |___ending 'y' coordinate
  27.                |  |  |   |   |   |
  28.                |  |  |   |   |   |_______ending 'x coordinate
  29.                |  |  |   |   |
  30.                |  |  |   |   |___________beginning 'y' coordinate
  31.                |  |  |   |
  32.                |  |  |   |_______________beginning 'x' coordinate
  33.                |  |  |
  34.                |  |  |______________________________
  35.                |  |_______________                  |
  36.                |                  |                 |
  37.          textcolor          textbackground       blink}
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46. Type
  47.     Output_Info = Record
  48.             Delete:  String[1];  {invisible field used for}
  49.                                  {record management       }
  50.             Check_No:  Integer;
  51.             Month:  Integer;
  52.             Day:  Integer;
  53.             Year:  Integer;
  54.             Payee:  String[26];
  55.             Amount:  Real;
  56.             Cat:  String[3];
  57.             Comment:  String[28];
  58.            CR: String[1]; { invisible field used to put }
  59.                           { C/R at end of each record }
  60.         End;
  61.      Str12 =  String[12];
  62.      Str80 =  String[80];
  63.      Str255 = String[255];
  64.  
  65.  
  66. Var
  67.       Output_File:      File of Output_Info;
  68.       New_Output_File:  File of Output_Info;
  69.       Old_File:         File of Output_Info;
  70.       Output_Record:    Output_Info;
  71.       MaxX,             { max and min       }
  72.       MinX,             { window position   }
  73.       MaxY,             { expressed as X,Y  }
  74.       MinY,             { screen position   }
  75.       Entry_Field,      { used as index for window array }
  76.       X,Y,              { screen coordinates }
  77.       XY,               { ScrBuf array subscript }
  78.       k,i,              { loop counter, subscript }
  79.       ErrorPos,         { when converting string expressions to  }
  80.                         { numeric expressions this variable will }
  81.                         { be zero if the conversion is successful }
  82.                         { and will indicate the postition of the }
  83.                         { non-numeric char if the conversion fails }
  84.       Current_File_Pos, { the current record of the output file    }
  85.       Tone: Integer;    { for beeper }
  86.       EXISTS,
  87.       BadName,          { used in checking for valid file name }
  88.       Good_Char,        { used in checking for valid file name }
  89.       Done_Adding,      { done adding records to the data file }
  90.       Done_Reading_Kbd:  Boolean;
  91.       ScrBuf: array [1..1920] of Char;  { this array holds all the input  }
  92.                                { data so it can be revised before}
  93.                                { the input variables are written }
  94.                                { to the data file                }
  95.       TempVar: String[255]; { each of the input data fields is first }
  96.                             { converted to this temporary string, then }
  97.                             { it is converted to the proper data type }
  98.                             { i.e. INT, REAL }
  99.  
  100.       Line: String[255];
  101.  
  102.       File_Name: String[12];{ name of the file that will hold the data }
  103.                             { that is entered                          }
  104.  
  105.       BackUp_File_Name: String[12];{ this name is automatically assigned by   }
  106.                             { the program - it will be the same as the }
  107.                             { regular file name except it will be a    }
  108.                             { .bak type file                           }
  109.  
  110.     Init_Val_1,
  111.     Init_Val_2,
  112.     Init_Val_3,
  113.     Init_Val_4,
  114.     Init_Val_5,
  115.     Init_Val_6,
  116.     Init_Val_7,
  117.     Init_Val_8:  String[255];
  118.  
  119.  
  120.  
  121.  
  122. {$I ExtProc1.Pas}
  123.  
  124.  
  125. Procedure Read_Record_and_Write_It;
  126. Begin
  127.     Seek(Output_File,Current_File_Pos-1);
  128.     Read(Output_File,Output_Record);
  129.     If Output_Record.Delete <> 'X' Then Begin
  130.       Banner_Line;
  131.       Entry_Field:= 0;
  132.       With Output_Record Do Begin
  133.         Tab; Str(Check_No:4, TempVar); Write_It_In_A_Field(TempVar);
  134.         Tab; Str(Month:2, TempVar); Write_It_In_A_Field(TempVar);
  135.         Tab; Str(Day:2, TempVar); Write_It_In_A_Field(TempVar);
  136.         Tab; Str(Year:2, TempVar); Write_It_In_A_Field(TempVar);
  137.         Tab; TempVar:= Payee; Write_It_In_A_Field(TempVar);
  138.         Tab; Str(Amount:7:2, TempVar); Write_It_In_A_Field(TempVar);
  139.         Tab; TempVar:= Cat; Write_It_In_A_Field(TempVar);
  140.         Tab; TempVar:= Comment; Write_It_In_A_Field(TempVar);
  141.         End;
  142.       End { if output_record.delete <> x }
  143.     Else Begin
  144.       Blank_Fields;
  145.       GotoXY(2,25);
  146.       TextColor(Black);
  147.       TextBackground(LightGray);
  148.       For i:= 1 to 65 Do Write(Chr(32));
  149.       GotoXY(2,25);
  150.       Write('       This record has been deleted.  (f4=undelete)');
  151.       End; { else }
  152.     End; {procedure Read_Record_and_Write_It }
  153.  
  154.  
  155.  
  156.  
  157.  
  158. {$I ExtProc2.Pas}
  159.  
  160.  
  161.  
  162. Procedure Write_Init_Val;
  163.  
  164. Begin
  165.   Blank_Fields;
  166.  
  167.   Entry_Field:= 0;
  168.   Tab;
  169.   Write_It_In_A_Field(Init_Val_1);
  170.   Tab;
  171.   Write_It_In_A_Field(Init_Val_2);
  172.   Tab;
  173.   Write_It_In_A_Field(Init_Val_3);
  174.   Tab;
  175.   Write_It_In_A_Field(Init_Val_4);
  176.   Tab;
  177.   Write_It_In_A_Field(Init_Val_5);
  178.   Tab;
  179.   Write_It_In_A_Field(Init_Val_6);
  180.   Tab;
  181.   Write_It_In_A_Field(Init_Val_7);
  182.   Tab;
  183.   Write_It_In_A_Field(Init_Val_8);
  184.   
  185.   Tone:= 8000;
  186.  
  187. End; { procedure write_init_val }
  188.  
  189. {$I ExtProc3.Pas}
  190.  
  191.   Procedure WriteScreen; 
  192.   Begin 
  193.   TextColor(1);  TextBackground(7);
  194.   Write('                                                                 ');
  195.   Write('               ');
  196.   TextColor(14);  TextBackground(7);
  197.   Write('                                                                 ');
  198.   Write('                                                                 ');
  199.   Write('                                        ');
  200.   TextColor(0);  TextBackground(3);
  201.   Write('╔═════════════════════════════════════════════════════════╗');
  202.   TextColor(14);  TextBackground(7);
  203.   Write('                     ');
  204.   TextColor(0);  TextBackground(3);
  205.   Write('║');
  206.   TextColor(14);  TextBackground(3);
  207.   Write('                                                         ');
  208.   TextColor(0);  TextBackground(3);
  209.   Write('║');
  210.   TextColor(14);  TextBackground(7);
  211.   Write('                     ');
  212.   TextColor(0);  TextBackground(3);
  213.   Write('║');
  214.   TextColor(15);  TextBackground(3);
  215.   Write('         ');
  216.   TextColor(14);  TextBackground(3);
  217.   Write('   ');
  218.   TextColor(15);  TextBackground(3);
  219.   Write('                     ');
  220.   TextColor(14);  TextBackground(3);
  221.   Write('      ');
  222.   TextColor(15);  TextBackground(3);
  223.   Write('CHECK NO.  ');
  224.   TextColor(0);  TextBackground(3);
  225.   Write(' ');
  226.   TextColor(0);  TextBackground(7);
  227.   Write('    ');
  228.   TextColor(15);  TextBackground(3);
  229.   Write('  ');
  230.   TextColor(0);  TextBackground(3);
  231.   Write('║');
  232.   TextColor(14);  TextBackground(7);
  233.   Write('           ');
  234.   TextColor(15);  TextBackground(7);
  235.   Write('          ');
  236.   TextColor(0);  TextBackground(3);
  237.   Write('║');
  238.   TextColor(15);  TextBackground(3);
  239.   Write('                                                         ');
  240.   TextColor(0);  TextBackground(3);
  241.   Write('║');
  242.   TextColor(15);  TextBackground(7);
  243.   Write('                     ');
  244.   TextColor(0);  TextBackground(3);
  245.   Write('║');
  246.   TextColor(14);  TextBackground(3);
  247.   Write('                 ');
  248.   TextColor(15);  TextBackground(3);
  249.   Write('                   CHECK DATE ');
  250.   TextColor(0);  TextBackground(7);
  251.   Write('  ');
  252.   TextColor(0);  TextBackground(3);
  253.   Write('/');
  254.   TextColor(0);  TextBackground(7);
  255.   Write('  ');
  256.   TextColor(0);  TextBackground(3);
  257.   Write('/');
  258.   TextColor(0);  TextBackground(7);
  259.   Write('  ');
  260.   TextColor(15);  TextBackground(3);
  261.   Write('  ');
  262.   TextColor(0);  TextBackground(3);
  263.   Write('║');
  264.   TextColor(15);  TextBackground(7);
  265.   Write('         ');
  266.   TextColor(14);  TextBackground(7);
  267.   Write('  ');
  268.   TextColor(15);  TextBackground(7);
  269.   Write('          ');
  270.   TextColor(0);  TextBackground(3);
  271.   Write('║');
  272.   TextColor(15);  TextBackground(3);
  273.   Write('                                                         ');
  274.   TextColor(0);  TextBackground(3);
  275.   Write('║');
  276.   TextColor(15);  TextBackground(7);
  277.   Write('           ');
  278.   TextColor(14);  TextBackground(7);
  279.   Write('          ');
  280.   TextColor(0);  TextBackground(3);
  281.   Write('║');
  282.   TextColor(14);  TextBackground(3);
  283.   Write('  ');
  284.   TextColor(15);  TextBackground(3);
  285.   Write('PAYEE     ');
  286.   TextColor(0);  TextBackground(7);
  287.   Write('                          ');
  288.   TextColor(15);  TextBackground(3);
  289.   Write('  AMOUNT $');
  290.   TextColor(0);  TextBackground(7);
  291.   Write('       ');
  292.   TextColor(14);  TextBackground(3);
  293.   Write('  ');
  294.   TextColor(0);  TextBackground(3);
  295.   Write('║');
  296.   TextColor(14);  TextBackground(7);
  297.   Write('           ');
  298.   TextColor(15);  TextBackground(7);
  299.   Write('          ');
  300.   TextColor(0);  TextBackground(3);
  301.   Write('║');
  302.   TextColor(15);  TextBackground(3);
  303.   Write('                             ');
  304.   TextColor(14);  TextBackground(3);
  305.   Write('                            ');
  306.   TextColor(0);  TextBackground(3);
  307.   Write('║');
  308.   TextColor(14);  TextBackground(7);
  309.   Write('                   ');
  310.   TextColor(15);  TextBackground(7);
  311.   Write('  ');
  312.   TextColor(0);  TextBackground(3);
  313.   Write('║');
  314.   TextColor(15);  TextBackground(3);
  315.   Write('  CATEGORY   ');
  316.   TextColor(0);  TextBackground(7);
  317.   Write('   ');
  318.   TextColor(14);  TextBackground(3);
  319.   Write('   ');
  320.   TextColor(15);  TextBackground(3);
  321.   Write('COMMENT ');
  322.   TextColor(0);  TextBackground(7);
  323.   Write('                            ');
  324.   TextColor(14);  TextBackground(3);
  325.   Write('  ');
  326.   TextColor(0);  TextBackground(3);
  327.   Write('║');
  328.   TextColor(14);  TextBackground(7);
  329.   Write('                     ');
  330.   TextColor(0);  TextBackground(3);
  331.   Write('║');
  332.   TextColor(14);  TextBackground(3);
  333.   Write('                                                         ');
  334.   TextColor(0);  TextBackground(3);
  335.   Write('║');
  336.   TextColor(14);  TextBackground(7);
  337.   Write('                     ');
  338.   TextColor(0);  TextBackground(3);
  339.   Write('╚═════════════════════════════════════════════════════════╝');
  340.   TextColor(14);  TextBackground(7);
  341.   Write('                                                                 ');
  342.   Write('                                                                 ');
  343.   Write('                                                                 ');
  344.   Write('                                                                 ');
  345.   Write('                                                                 ');
  346.   Write('                                                                 ');
  347.   Write('                                                                 ');
  348.   Write('                                                                 ');
  349.   Write('                                                                 ');
  350.   Write('                                                                 ');
  351.   Write('                                                                 ');
  352.   Write('                ');
  353.   TextColor(15);  TextBackground(7);
  354.   Write('                                                                 ');
  355.   Write('              ');
  356.   End; { precedure write_screen } 
  357.  
  358. {$I ExtProc4.Pas}
  359.  
  360. Procedure Set_Up_Output_Record;
  361.  
  362. Begin
  363.   Repeat
  364.     Entry_Field:= 0;
  365.     Gather_Input_Info;
  366.     Strip_Spaces;
  367.     Val(TempVar, Output_Record.Check_No,ErrorPos);
  368.     If ErrorPos <> 0 Then Find_Error;
  369.   Until ErrorPos = 0;
  370.   Repeat
  371.     Entry_Field:= 1;
  372.     Gather_Input_Info;
  373.     Strip_Spaces;
  374.     Val(TempVar, Output_Record.Month,ErrorPos);
  375.     If ErrorPos <> 0 Then Find_Error;
  376.   Until ErrorPos = 0;
  377.   Repeat
  378.     Entry_Field:= 2;
  379.     Gather_Input_Info;
  380.     Strip_Spaces;
  381.     Val(TempVar, Output_Record.Day,ErrorPos);
  382.     If ErrorPos <> 0 Then Find_Error;
  383.   Until ErrorPos = 0;
  384.   Repeat
  385.     Entry_Field:= 3;
  386.     Gather_Input_Info;
  387.     Strip_Spaces;
  388.     Val(TempVar, Output_Record.Year,ErrorPos);
  389.     If ErrorPos <> 0 Then Find_Error;
  390.   Until ErrorPos = 0;
  391.   Entry_Field:= 4;
  392.     Gather_Input_Info;
  393.     OutPut_Record.Payee:= TempVar;
  394.   Repeat
  395.     Entry_Field:= 5;
  396.     Gather_Input_Info;
  397.     Strip_Spaces;
  398.     Val(TempVar, Output_Record.Amount,ErrorPos);
  399.     If ErrorPos <> 0 Then Find_Error;
  400.   Until ErrorPos = 0;
  401.   Entry_Field:= 6;
  402.     Gather_Input_Info;
  403.     OutPut_Record.Cat:= TempVar;
  404.   Entry_Field:= 7;
  405.     Gather_Input_Info;
  406.     OutPut_Record.Comment:= TempVar;
  407.   Write_To_OutPut_File;
  408.   End; { procedure set_up_output_record }
  409.  
  410.  
  411.  
  412.  
  413.  
  414. Begin { main procedure }
  415. ClrScr;
  416. Open_File;
  417. Init_Val_1:= '';
  418. Init_Val_2:= '';
  419. Init_Val_3:= '';
  420. Init_Val_4:= '';
  421. Init_Val_5:= '';
  422. Init_Val_6:= '';
  423. Init_Val_7:= '';
  424. Init_Val_8:= '';
  425. For XY:= 1 to 1920 Do
  426.   ScrBuf[XY]:= Chr(32);
  427. WriteScreen;
  428. Banner_Line;
  429. Write_Recno;
  430. Done_Adding:= False;
  431. Repeat
  432.   If Current_File_Pos = FileSize(Output_File)+1 Then Write_Init_Val;
  433.   Entry_Field:= 0;
  434.   Done_Reading_Kbd:= False;
  435.   Tab;
  436.   Repeat
  437.     ReadKbd;
  438.   Until Done_Reading_Kbd;
  439.   If not Done_Adding Then Set_Up_Output_Record;
  440. Until Done_Adding;
  441. Close(Output_File);
  442.  
  443. End.
  444.