home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / 30TURUTL / MENUDEMO.PAS < prev    next >
Pascal/Delphi Source File  |  1985-02-18  |  6KB  |  142 lines

  1. (*$C-,V-,U-*)
  2. Program MenuDemo;
  3.  
  4. (*----------------------------------------------------------------------*)
  5. (*              MenuDemo --- Demonstrate TURBO Menu Routines            *)
  6. (*----------------------------------------------------------------------*)
  7. (*                                                                      *)
  8. (*  Author:   Philip R. Burns                                           *)
  9. (*  Date:     January, 1985                                             *)
  10. (*  Version:  1.0                                                       *)
  11. (*  Systems:  For MS-DOS on IBM PCs and close compatibles only.         *)
  12. (*            Note:  I have checked these on Zenith 151s under          *)
  13. (*                   MSDOS 2.1 and IBM PCs under PCDOS 2.0.             *)
  14. (*                                                                      *)
  15. (*  Overview: This program provides a short demo of the routines in     *)
  16. (*            PIBMENUS.PAS.  A single menu, to select a baud rate       *)
  17. (*            in a communications program, is created.                  *)
  18. (*                                                                      *)
  19. (*            Suggestions for improvements or corrections are welcome.  *)
  20. (*            Please leave messages on Gene Plantz's BBS (312) 882 4145 *)
  21. (*            or Ron Fox's BBS (312) 940 6496.                          *)
  22. (*                                                                      *)
  23. (*            I hope that you find this program useful -- and,          *)
  24. (*            if you expand upon it, please upload your extensions so   *)
  25. (*            that all of us can enjoy them!                            *)
  26. (*                                                                      *)
  27. (*----------------------------------------------------------------------*)
  28.  
  29. (*----------------------------------------------------------------------*)
  30. (*                   Global Color Variables                             *)
  31. (*----------------------------------------------------------------------*)
  32.  
  33. Var
  34.  
  35.    ForeGround_Color : Integer      (* Color for ordinary text           *);
  36.    BackGround_Color : Integer      (* Usual background color            *);
  37.  
  38.    Menu_Text_Color  : Integer      (* Color for menu text               *);
  39.    Menu_Frame_Color : Integer      (* Color for menu frame              *);
  40.  
  41. (*$IGLOBTYPE.PAS *)
  42. (*$IASCII.PAS    *)
  43. (*$IMINMAX.PAS   *)
  44. (*$IPIBMENUS.PAS *)
  45.  
  46. (*----------------------------------------------------------------------*)
  47. (*                   Local constants and variables                      *)
  48. (*----------------------------------------------------------------------*)
  49.  
  50. Const
  51.                                    (* Baud Rates available *)
  52.  
  53.    Baud_Rates: Array[ 1 .. 8 ] OF Integer
  54.                = ( 110, 150, 300, 600, 1200, 2400, 4800, 9600 );
  55.  
  56. Var
  57.    Baud_Menu   : Menu_Type         (* Hold the menu itself *);
  58.    Baud_Rate   : Integer           (* Selected baud rate   *);
  59.    I           : Integer           (* Loop index           *);
  60.  
  61. (*----------------------------------------------------------------------*)
  62. (*                         Begin Main Program                           *)
  63. (*----------------------------------------------------------------------*)
  64.  
  65. Begin (* MenuDemo *)
  66.  
  67.                                    (* Select color/mono screen *)
  68.  
  69.    Get_Screen_Address( Actual_Screen );
  70.  
  71.                                    (* Establish colors         *)
  72.  
  73.    If Color_Screen_Active Then
  74.       Begin
  75.          ForeGround_Color := Yellow     (* Color for ordinary text  *);
  76.          BackGround_Color := Black      (* Usual background color   *);
  77.  
  78.          Menu_Text_Color  := Green      (* Color for menu text      *);
  79.          Menu_Frame_Color := Red        (* Color for menu frame     *)
  80.       End
  81.    Else
  82.       Begin
  83.          ForeGround_Color := White      (* Color for ordinary text  *);
  84.          BackGround_Color := Black      (* Usual background color   *);
  85.  
  86.          Menu_Text_Color  := White      (* Color for menu text      *);
  87.          Menu_Frame_Color := White      (* Color for menu frame     *);
  88.  
  89.       End;
  90.  
  91.    Set_Global_Colors( ForeGround_Color, BackGround_Color );
  92.  
  93.                                    (* Set up the menu          *)
  94.    Baud_Menu.Menu_Size    := 8;
  95.    Baud_Menu.Menu_Row     := 11;
  96.    Baud_Menu.Menu_Column  := 30;
  97.    Baud_Menu.Menu_Tcolor  := Menu_Text_Color;
  98.    Baud_Menu.Menu_Bcolor  := BackGround_Color;
  99.    Baud_Menu.Menu_Fcolor  := Menu_Frame_Color;
  100.    Baud_Menu.Menu_Width   := 0;
  101.    Baud_Menu.Menu_Height  := 0;
  102.  
  103.                                    (* Default baud rate = 1200 = *)
  104.                                    (* fifth entry in menu        *)
  105.    Baud_Menu.Menu_Default := 5;
  106.  
  107.                                    (* Define positions, values   *)
  108.                                    (* for each baud rate         *)
  109.    For I := 1 to 8 Do
  110.       With Baud_Menu.Menu_Entries[I] Do
  111.       Begin
  112.          Menu_Item_Row    := I;
  113.          Menu_Item_Column := 2;
  114.          Case I Of
  115.             1:  Menu_Item_Text:= '110';
  116.             2:  Menu_Item_Text:= '150';
  117.             3:  Menu_Item_Text:= '300';
  118.             4:  Menu_Item_Text:= '600';
  119.             5:  Menu_Item_Text:= '1200';
  120.             6:  Menu_Item_Text:= '2400';
  121.             7:  Menu_Item_Text:= '4800';
  122.             8:  Menu_Item_Text:= '9600';
  123.          End (* Case *);
  124.       End;
  125.                                    (* Set title of menu *)
  126.  
  127.    Baud_Menu.Menu_Title := 'Choose Baud Rate: ';
  128.  
  129.                                    (* Display the menu *)
  130.  
  131.    Menu_Display_Choices( Baud_Menu );
  132.  
  133.                                    (* Get selected menu item *)
  134.  
  135.    Baud_Rate := Baud_Rates[ Menu_Get_Choice( Baud_Menu , Erase_Menu ) ];
  136.  
  137.    GoToXY( 1 , 20 );
  138.    Writeln('The Selected Baud Rate Is ', Baud_Rate );
  139.    Delay( 3000 );
  140.  
  141. End   (* MenuDemo *).
  142.