menu help 
Author Message
 menu help

Hi there,
          I am currently working on a stock take program and I
was wondering how I can get all the items of stock listed below
in the array to only be accepted into the program if entered as
they appear below. Another problem that I am finding with the
program is that when I get all the information about the stock in
the table, I can't get the program to read any one record of
stock. The procedure that I have entered is Produce Report. This
would be useful so that I am able to get info on any one item of
stock and then obtain a printout of it.

-----------------------------------------------------------------
program stocktake;
uses
    wincrt,windos;
    const
           shop : array [0..3] of string  =
('GALA','EDIN','GLAS','OBAN');
           item : array [1..27] of string =
('AND','BUC','BLW','CMB','CMR','CEL','MDK','FOS',

'DGR','MGR','GUN','MMD','HMD','MCL','MCK','MCR',

'MCN','DRR','RRP','RBS','GRS','RSK','HST','HST',
                                              'STU','SUV','GUV');
    type
        SalesDetails=record
                           Item:string[10];
                           Code:string [1];
                           Stock_Code:string[4];
                           Location:string[4];
        end;

        SalesFile=file of SalesDetails;

        function File_Exist(FileName:pchar):boolean;
        var
           File_Info:TSearchRec;
        begin
             FindFirst(FileName,faAnyFile,File_info);
             File_Exist:=(DosError=0);
        end;

    procedure Enter_Details(var FileName:SalesFile);
    var
       StockRec:SalesDetails;
       Reply:char;
       File_Size:longint;
    begin
         reset(FileName);
         File_Size:=filesize(filename);
         seek(FileName,File_size);

    repeat
              clrscr;
              gotoxy (22,2);
              write('Input Details');
              gotoxy (22,3);
              write('-------------');
              gotoxy (10,6);
              write('Enter Item : ');
              readln(StockRec.Item);
              gotoxy (10,9);
              write('Enter Code : ');
              readln(StockRec.Code);
              gotoxy (10,12);
              write('Enter Stock Code : ');
              readln(StockRec.Stock_Code);
              gotoxy (10,15);
              write('Enter Location of Item : ');
              readln(StockRec.Location);
              gotoxy (10,17);
              write(FileName,StockRec);
              gotoxy (10,20);
              write('Enter another record ? (Y/N) ');
              readln(reply);

           until reply in ['N','n'];
         end;

 procedure TheWholePicture(Var TWP_Username : String);
 procedure FindTime(var h,m,s,hund:word);

    function LeadingZero(w : Word) : String;
       var
          s : String;
       begin
            Str(w:0,s);
             if Length(s) = 1 then
             s := '0' + s;
              LeadingZero := s;
       end;

   begin
   GetTime(h,m,s,hund);
   Writeln('  At ',LeadingZero(h),':',
           LeadingZero(m),':',LeadingZero(s),
           '.',LeadingZero(hund));
   writeln;
   writeln;

   end;

 procedure FindDate(var y,mo,d,dow:word);

  const
   days : array [0..6] of String[9] =
     ('Sunday','Monday','Tuesday',
      'Wednesday','Thursday','Friday',
      'Saturday');

 begin
   clrscr;
   gotoxy (10,3);
   writeln ('Login Info');
   gotoxy (10,4);
   writeln ('----------');
   gotoxy (5,7);
   write(TWP_username,'  ');
   GetDate(y,mo,d,dow);
   Write('Logged On ', days[dow],', ',
           mo:0, '/', d:0, '/', y:0);
 end;

 var
 h,m,s,hund,y,mo,d,dow:word;
 begin

      FindDate(y,mo,d,dow);
      FindTime(h,m,s,hund)
 end;

  procedure TheWholePicture2(Var TWP2_username:string);
 procedure FindTime(var h,m,s,hund:word);

    function LeadingZero(w : Word) : String;
       var
          s : String;
       begin
            Str(w:0,s);
             if Length(s) = 1 then
             s := '0' + s;
              LeadingZero := s;
       end;

   begin
   GetTime(h,m,s,hund);
   Writeln('  At ',LeadingZero(h),':',
           LeadingZero(m),':',LeadingZero(s),
           '.',LeadingZero(hund));
   writeln;
   writeln;

   end;

 procedure FindDate(var y,mo,d,dow:word);

  const
   days : array [0..6] of String[9] =
     ('Sunday','Monday','Tuesday',
      'Wednesday','Thursday','Friday',
      'Saturday');

 begin
   clrscr;
   gotoxy (10,3);
   writeln ('Log Off Info');
   gotoxy (10,4);
   writeln ('------------');
   gotoxy (5,7);
   write(TWP2_username,'  ');
   GetDate(y,mo,d,dow);
   Write('Logged Off ', days[dow],', ',
           mo:0, '/', d:0, '/', y:0);

 end;

 var
 h,m,s,hund,y,mo,d,dow:word;
 begin

      FindDate(y,mo,d,dow);
      FindTime(h,m,s,hund)
 end;

 Procedure Delete_Records (Var Filename: SalesFile);

    begin

    end;

 Procedure Produce_Report (Var Filename: SalesFile);
   var
       file_size : longint;
       record_num : integer;
       stockrec : salesdetails;
       choice : char;

    begin
         clrscr;

         Write ('Enter the record number: ');
         readln (stockrec.item);

         reset(FileName);
         read(FileName,stockRec);
         seek (Filename,File_Size);

         writeln;
         Writeln ('The data for record number ',stockrec.item,'
is : ');

         writeln;
         writeln(' ',stockRec.item,' ':16-length(stockRec.item),
         stockrec.code,'
':10-length(stockrec.code),stockrec.stock_code,' ':15
         -length(stockrec.stock_code),stockrec.location);
         writeln;
         writeln ('Do you wish to print this Y/N ? ');

         readln;
         writeln;
         clrscr;
         writeln;
         write ('Press any key to return to main menu : ');
         readkey;

    end;

    Procedure Display_File_Contents(var FileName:SalesFile);
    var
       stockRec:SalesDetails;
       choice:char;
       count : integer;

    begin
         clrscr;
              gotoxy(22,2);
              writeln('Stock File');
              gotoxy(22,3);
              writeln('----------');
              gotoxy(0,5);

writeln('____________________________________________________');
              gotoxy(1,4);
              writeln('Item');
              gotoxy(16,4);
              writeln('Code');
              gotoxy(28,4);
              writeln('Stock Code');
              gotoxy(44,4);
              writeln('Location');
              writeln;

              reset(FileName);
              while not Eof(FileName) do
                 begin
                    read(FileName,stockRec);
                    writeln(' ',stockRec.item,'
':16-length(stockRec.item),
                    stockrec.code,'
':10-length(stockrec.code),stockrec.stock_code,' ':15

-length(stockrec.stock_code),stockrec.location);

              end;
           writeln;
           write('Press a key to return to menu:  ');
           readkey;

          end;

               {----Main Program-----}

    var
       MainSalesFile:SalesFile;
       choice:char;
       pass,username:string;

       begin
            ASSIGN(MainSalesFile,'A:\stock.DAT');
            if File_Exist('A:\stock.DAT')
            then
                reset(MainSalesFile)
            else
                rewrite(MainSalesFile);

             begin
              repeat
                  clrscr;
                  gotoxy (15,5);
                  Writeln ('Welcome to Stock Take Control');
                  gotoxy (15,6);
                  writeln ('-----------------------------');
                  gotoxy (13,10);
                  write('Please enter your username: ');
                  readln(username);

            until username = 'greg';

            TheWholePicture(username);
            gotoxy (10,10);
            write('Press Enter to access system! ');
            readkey;

            repeat
                  clrscr;

                  gotoxy (15,3);
                  writeln ('*** Stock Level Program ***');
                  gotoxy(10,5);
                  writeln('1). Enter Stock Details ');
                  gotoxy(10,6);
                  writeln('2). Display Stock Details ');
                  gotoxy(10,7);
                  writeln('3). Delete main file ');
                  gotoxy (10,8);
                  writeln ('4). Produce report ');
                  gotoxy (10,9);
                  writeln ('5). Exit program ');
                  gotoxy(10,12);
                  write('Enter your designated choice (1-5) : ');
                  readln(choice);

                  case choice of
                       '1':Enter_Details(MainSalesFile);
                       '2':Display_File_Contents(MainSalesFile);
                       '3':Delete_Records(MainSalesFile);
                       '4':Produce_Report(MainSalesFile);

                  end;
            until choice='5';
            close(MainSalesFile);
            TheWholePicture2(username);
            end;
            end.

I would be very grateful if you could look at the problems that I
am having and suggest ways of fixing it.

Thanks a lot

Greg Stone

* Sent from RemarQ http://www.*-*-*.com/ The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



Wed, 18 Jun 1902 08:00:00 GMT  
 menu help
Hi there,
          I am currently working on a stock take program and I was
wondering how I can get all the items of stock listed below in the
array to only be accepted into the program if entered as they appear
below. Another problem that I am finding with the program is that when
I get all the information about the stock in the table, I can't get the
program to read any one record of stock. The procedure that I
have entered is Produce Report. This would be useful so that I am able
to get info on any one item of stock and then obtain a printout of it.

-----------------------------------------------------------------------
program stocktake;
uses
    wincrt,windos;
    const
           shop : array [0..3] of string  =
('GALA','EDIN','GLAS','OBAN');
           item : array [1..27] of string =
('AND','BUC','BLW','CMB','CMR','CEL','MDK','FOS',

'DGR','MGR','GUN','MMD','HMD','MCL','MCK','MCR',

'MCN','DRR','RRP','RBS','GRS','RSK','HST','HST',
                                              'STU','SUV','GUV');
    type
        SalesDetails=record
                           Item:string[10];
                           Code:string [1];
                           Stock_Code:string[4];
                           Location:string[4];
        end;

        SalesFile=file of SalesDetails;

        function File_Exist(FileName:pchar):boolean;
        var
           File_Info:TSearchRec;
        begin
             FindFirst(FileName,faAnyFile,File_info);
             File_Exist:=(DosError=0);
        end;

    procedure Enter_Details(var FileName:SalesFile);
    var
       StockRec:SalesDetails;
       Reply:char;
       File_Size:longint;
    begin
         reset(FileName);
         File_Size:=filesize(filename);
         seek(FileName,File_size);

    repeat
              clrscr;
              gotoxy (22,2);
              write('Input Details');
              gotoxy (22,3);
              write('-------------');
              gotoxy (10,6);
              write('Enter Item : ');
              readln(StockRec.Item);
              gotoxy (10,9);
              write('Enter Code : ');
              readln(StockRec.Code);
              gotoxy (10,12);
              write('Enter Stock Code : ');
              readln(StockRec.Stock_Code);
              gotoxy (10,15);
              write('Enter Location of Item : ');
              readln(StockRec.Location);
              gotoxy (10,17);
              write(FileName,StockRec);
              gotoxy (10,20);
              write('Enter another record ? (Y/N) ');
              readln(reply);

           until reply in ['N','n'];
         end;

 procedure TheWholePicture(Var TWP_Username : String);
 procedure FindTime(var h,m,s,hund:word);

    function LeadingZero(w : Word) : String;
       var
          s : String;
       begin
            Str(w:0,s);
             if Length(s) = 1 then
             s := '0' + s;
              LeadingZero := s;
       end;

   begin
   GetTime(h,m,s,hund);
   Writeln('  At ',LeadingZero(h),':',
           LeadingZero(m),':',LeadingZero(s),
           '.',LeadingZero(hund));
   writeln;
   writeln;

   end;

 procedure FindDate(var y,mo,d,dow:word);

  const
   days : array [0..6] of String[9] =
     ('Sunday','Monday','Tuesday',
      'Wednesday','Thursday','Friday',
      'Saturday');

 begin
   clrscr;
   gotoxy (10,3);
   writeln ('Login Info');
   gotoxy (10,4);
   writeln ('----------');
   gotoxy (5,7);
   write(TWP_username,'  ');
   GetDate(y,mo,d,dow);
   Write('Logged On ', days[dow],', ',
           mo:0, '/', d:0, '/', y:0);
 end;

 var
 h,m,s,hund,y,mo,d,dow:word;
 begin

      FindDate(y,mo,d,dow);
      FindTime(h,m,s,hund)
 end;

  procedure TheWholePicture2(Var TWP2_username:string);
 procedure FindTime(var h,m,s,hund:word);

    function LeadingZero(w : Word) : String;
       var
          s : String;
       begin
            Str(w:0,s);
             if Length(s) = 1 then
             s := '0' + s;
              LeadingZero := s;
       end;

   begin
   GetTime(h,m,s,hund);
   Writeln('  At ',LeadingZero(h),':',
           LeadingZero(m),':',LeadingZero(s),
           '.',LeadingZero(hund));
   writeln;
   writeln;

   end;

 procedure FindDate(var y,mo,d,dow:word);

  const
   days : array [0..6] of String[9] =
     ('Sunday','Monday','Tuesday',
      'Wednesday','Thursday','Friday',
      'Saturday');

 begin
   clrscr;
   gotoxy (10,3);
   writeln ('Log Off Info');
   gotoxy (10,4);
   writeln ('------------');
   gotoxy (5,7);
   write(TWP2_username,'  ');
   GetDate(y,mo,d,dow);
   Write('Logged Off ', days[dow],', ',
           mo:0, '/', d:0, '/', y:0);

 end;

 var
 h,m,s,hund,y,mo,d,dow:word;
 begin

      FindDate(y,mo,d,dow);
      FindTime(h,m,s,hund)
 end;

 Procedure Delete_Records (Var Filename: SalesFile);

    begin

    end;

 Procedure Produce_Report (Var Filename: SalesFile);
   var
       file_size : longint;
       record_num : integer;
       stockrec : salesdetails;
       choice : char;

    begin
         clrscr;

         Write ('Enter the record number: ');
         readln (stockrec.item);

         reset(FileName);
         read(FileName,stockRec);
         seek (Filename,File_Size);

         writeln;
         Writeln ('The data for record number ',stockrec.item,' is : ');

         writeln;
         writeln(' ',stockRec.item,' ':16-length(stockRec.item),
         stockrec.code,'
':10-length(stockrec.code),stockrec.stock_code,' ':15
         -length(stockrec.stock_code),stockrec.location);
         writeln;
         writeln ('Do you wish to print this Y/N ? ');

         readln;
         writeln;
         clrscr;
         writeln;
         write ('Press any key to return to main menu : ');
         readkey;

    end;

    Procedure Display_File_Contents(var FileName:SalesFile);
    var
       stockRec:SalesDetails;
       choice:char;
       count : integer;

    begin
         clrscr;
              gotoxy(22,2);
              writeln('Stock File');
              gotoxy(22,3);
              writeln('----------');
              gotoxy(0,5);

writeln('____________________________________________________');
              gotoxy(1,4);
              writeln('Item');
              gotoxy(16,4);
              writeln('Code');
              gotoxy(28,4);
              writeln('Stock Code');
              gotoxy(44,4);
              writeln('Location');
              writeln;

              reset(FileName);
              while not Eof(FileName) do
                 begin
                    read(FileName,stockRec);
                    writeln(' ',stockRec.item,'
':16-length(stockRec.item),
                    stockrec.code,'
':10-length(stockrec.code),stockrec.stock_code,' ':15
                    -length(stockrec.stock_code),stockrec.location);

              end;
           writeln;
           write('Press a key to return to menu:  ');
           readkey;

          end;

               {----Main Program-----}

    var
       MainSalesFile:SalesFile;
       choice:char;
       pass,username:string;

       begin
            ASSIGN(MainSalesFile,'A:\stock.DAT');
            if File_Exist('A:\stock.DAT')
            then
                reset(MainSalesFile)
            else
                rewrite(MainSalesFile);

             begin
              repeat
                  clrscr;
                  gotoxy (15,5);
                  Writeln ('Welcome to Stock Take Control');
                  gotoxy (15,6);
                  writeln ('-----------------------------');
                  gotoxy (13,10);
                  write('Please enter your username: ');
                  readln(username);

            until username = 'greg';

            TheWholePicture(username);
            gotoxy (10,10);
            write('Press Enter to access system! ');
            readkey;

            repeat
                  clrscr;

                  gotoxy (15,3);
                  writeln ('*** Stock Level Program ***');
                  gotoxy(10,5);
                  writeln('1). Enter Stock Details ');
                  gotoxy(10,6);
                  writeln('2). Display Stock Details ');
                  gotoxy(10,7);
                  writeln('3). Delete main file ');
                  gotoxy (10,8);
                  writeln ('4). Produce report ');
                  gotoxy (10,9);
                  writeln ('5). Exit program ');
                  gotoxy(10,12);
                  write('Enter your designated choice (1-5) : ');
                  readln(choice);

                  case choice of
                       '1':Enter_Details(MainSalesFile);
                       '2':Display_File_Contents(MainSalesFile);
                       '3':Delete_Records(MainSalesFile);
                       '4':Produce_Report(MainSalesFile);

                  end;
            until choice='5';
            close(MainSalesFile);
            TheWholePicture2(username);
            end;
            end.

I would be very grateful if you could look at the problems that I
am having and suggest ways of fixing it.

Thanks a lot

Greg Stone



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. wmfh10.zip TP units for windows, menus, help, etc

2. Help: Can't create Pop Menu

3. Menu System Help

4. Help needed re: Menu Procedure

5. Help please with right-click menu on TDBEdit

6. Please help MENU SYSTEM

7. need help with programmatic assignment of Popup menu using TTreeView component

8. HELP !!!! Pascal OOPS - Menu Question

9. HELP !!!! Pascal OOPS - Menu Question

10. HELP ON MAKING MENU

11. Help. Source for pull-down menus

12. Help on Inputting Menus

 

 
Powered by phpBB® Forum Software