home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-01-22 | 39.2 KB | 1,045 lines |
-
-
-
-
-
-
-
- Professional Program Shell for Turbo Pascal 4.0/5.0 developers.
-
- TP5MENU
-
- Version 1.0
-
-
- (c) Copyright BittWare Computing, 1988, ALL RIGHTS RESERVED
-
-
-
-
-
- Contents:
-
- License................................................. ii
- Features................................................ iii
- Order Form.............................................. iv
- Files on this Disk...................................... v
- General Information..................................... 1
- Using the mouse......................................... 2
- Using Demo Program...................................... 3
-
- Getting down to Development Work
- Screen Pointers.................................... 4
- Headers............................................ 5
- Pull Down menus.................................... 6
- Without Data Entry........................... 8
- With Data Entry.............................. 9
- Complete Data Entry Example.................. 12
- Using Mask................................... 13
- Updating Menus............................... 14
- Pick Lists......................................... 15
- Help............................................... 16
- Error Messages..................................... 17
- General Windows.................................... 18
-
- Advanced Features
- Using Disk to Save/Recall Menus.................... 19
- Setting up HotKeys................................. 19
-
-
-
- ii
- IMPORTANT!!!
-
- Make sure you READ and UNDERSTAND the ShareWare agreement
- below, BEFORE you use and/or redistribute this package.
- ^^^^^^
- This software is intended to ease the development of a
- Professional User interface for your programs, and there are
- no royalties. If you like this system, show your
- appreciation by registering your copy. Print out the order
- form by typing:
-
- dos> print ordform.txt <cr>
-
- Furthermore, you are allowed, and in fact encouraged, to pass
- this software along to anyone you wish, or to upload it to a
- bulletin board, provided the following criteria are met:
-
- Absolutely NO MODIFICATIONS can be made when copying or
- redistributing this software. Your unique registration
- number will already be on the order form when you purchase
- full registration, and you will receive a $5.00 commission
- when someone registers with your number.
-
- 1) This software may not be sold for profit.
- {public domain and user-supported software dealers please
- contact us for permission}
-
- 2) The software and documentation may not be modified in
- any way, and redistributed. This includes, but is not
- limited to, the copyright notices.
-
- 3) ALL ORIGINAL documentation and files MUST be included.
- ^^^ ^^^^
- 4) The Source Code included with the registration can NEVER
- be copied or redistributed (copies for the sole purpose
- of backup/archive are allowed).
-
- WARRANTY:
- The author(s) and BittWare Computing make no warranty of any
- kind, expressed or implied.
-
- DISCLAIMER:
- The author(s) and BittWare Computing do not assume any
- liability for the use of this software. This includes but is
- not limited to lost profits, or other incidental damages, due
- to the use of this software.
-
- By using this software you have agreed to all terms in this
- agreement.
-
-
-
- iii
- ShareWare for Turbo Pascal 4.0 Developers
-
- This is NOT just a collection of routines, but a complete
- program shell.
- - Define your Menus and Variables
- - Insert your procedures in the Supplied unit
- - Compile
-
- POP-UP: Header Select Lines, Pull-Down-Menus, Pick-From-List,
- Context-Sensitive Help, Errors, Windows
-
- - Bullet-Proof Data Entry accomplished from Pull-Down-Menu or
- Window, includes line-editor
-
- - Pull-Down Menus can have options "masked." Masked
- selections appear in a different color and are skipped over
- by highlight bar.
-
- - Pick From List includes an example routine to pop-up a
- window and select a file with definable directory and search
- mask.
-
- - Includes easy to understand Source Code for Example Shell,
- menu initialization, and global variables.
-
- - User-definable window/menu colors, sizes, borders, titles,
- and placement
-
- - Easily create context-sensitive help and error messages
-
- Autodetect and Support for VGA, EGA, CGA, ATT, and Monochrome
- Microsoft Serial Mouse Driver (may support others)
- NO Royalties!
-
- Complete Registration also includes:
- ALL Source Code (additional source code is NOT shareware)
- $5.00 sales commission on subsequent registrations with
- your number
-
-
-
- Professional Program Shell for Turbo Pascal 4.0/5.0
- Registration Number = 0000
- Version = 1.0
-
- Check or Money Order Payable to: "BittWare Computing"
-
- Mail To: BittWare Computing
- P.O. Box 66164
- Baltimore, MD 21239
- Phone: (201)455-1019
-
- For $10.00:
- - Latest Version
- - Documentation on Disk
- - Source Code for interfacing/initializing menus
- - Complete Source Code Example Shell
- - Compiled Units (.tpu files) for actual menu/input routines
- - NO royalties!
- - Great feeling for participating in User-Supported Software
-
- For $25.00 (TUG Members: $20.00 with membership #)
- - All of the Above PLUS
- - Free Upgrade
- - A unique Registration Number
- ($5.00 commission for all registrations made with your #)
- - Full Source Code for Everything!
-
- Desired Features:________________________________________________
-
- _________________________________________________________________
-
- Any Known Bugs:__________________________________________________
-
- _________________________________________________________________
-
- We'll Customize a User Interface for you, contact for details.
-
- Are you interested in a Digital Signal Processing Workstation for
- the IBM PC? ( )yes ( )no
-
- Would you like to be put on our mailing list? ( )yes ( )no
-
- ShareWare Copies @ $10.00 ea. Qty. ( ) $_________
-
- Source Copies @ $25/20* ea. Qty. ( ) $_________
-
- Total $_________
- * TUG Membership # ____________
-
- Shipping Address:
- Name: _____________________________
-
- Company, Mail Stop: _____________________________
-
- Street: _____________________________
-
- City, State, Zip: _____________________________
-
-
-
- v
- Getting Started:
- What the files are:
-
- README.DOC :IMPORTANT INFORMATION, PLEASE READ!!
- TP5MENU.DOC :Documentation file, ready to print
- ORDFORM.TXT :Order form, ready to print
- TP5MENU.EXE :Ready to run demo program
- TP5MENU.PAS :Source code for main demo routine
- PPS_GLOB.PAS :Global variables, source
- PPS_INIT.PAS :Menu Initialization code, source
- PPS_USR.PAS :User-Defined Procedures, source
- * INP_VAR.TPU :Some input routines, object
- * BEEPKEY4.TPU :Keyboard, sound routines, object
- * MENUVARS.TPU :Menu Data Structures, object
- * MENUCODE.TPU :Menu Manipulation, object
- * MENUMOUS.COM :Ram-resident uSoft mouse interface
- PPS_HELP.EXE :Generates Help Message File, executable
- PPS_HELP.PAS :Generates Help Message File, source
- TP5MENU.HLP :Help message file
- INSTALL.BAT :Creates directory/copies files to harddisk
-
- * Source with registration
-
- Hard Disk Users: Insert tp5menu floppy in drive a:,
- select drive a: and type install.bat. This will create a
- directory off of the root (c:\tp5menu) and copy all
- necessary files.
-
-
-
-
- 1
- General Information:
-
- The best way to use this system is:
-
- 1) Run the demo program for ideas on what the system can do
-
- 2) Determine the features that are best for your application
-
- 3) Read the manual (tp5menu.doc) and look at the code
-
- The following files need to be modified in order to
- customize this program for your system:
-
- You MUST rename these files and the corresponding include
- directives before modification. Remember only unmodified
- files may be copied and redistributed.
-
- 1) PPS_GLOB.PAS
- 2) PPS_INIT.PAS
- 3) PPS_USR.PAS
- 4) TP5MENU.PAS
- 5) PPS_HELP.PAS
-
- 1. PPS_GLOB.PAS includes the global variables that your
- procedures defined in #3 will use. These variables should
- be initialized in the initialization section of this unit,
- as shown.
-
- 2. PPS_INIT.PAS includes all the menu variable
- declarations, memory allocation for heap variables, and
- initialization of heap variables. This is where you will
- modify/create menus for your own application.
-
- 3. PPS_USR.PAS is where the user-defined procedures are
- located. This is where you can put the "meat" of your
- program. The shell is currently set up to call these
- routines from the "Execute" part of the main menu, but you
- may call these routines from where-ever you like.
-
- 4. TP5MENU.PAS is the main program. This code consists
- mainly of case statements based on the menu selections.
- Here is where you set up what happens with the current menu
- choice.
-
- 5. PPS_HELP.PAS is a separate program that generates the
- help message file. Important note when editing this file
- is that the constants used here MUST be the same as those
- used in the main program. The help constants for the demo
- routine are currently defined in the PPS_GLOB.PAS unit.
-
-
-
- 2
- Using a mouse:
-
- The program menumous.com is a ram-resident mouse driver
- which works with the microsoft serial mouse (may also
- support others).
-
- mouse movement ==> arrow keys
- right button ==> <enter>
- left button ==> <esc>
-
- The mouse is a very effective means for using the menus.
- The only time the keyboard is actually required is for data
- entry.
-
- To use the mouse driver:
- - Install the mouse driver supplied with your mouse,
- probably mouse.com.
- - type dos> menumouse <cr>
-
- Now moving your mouse will act like cursor keys, pressing
- the left button is the same as <esc> and the right button
- like <enter>.
-
-
-
- 3
- Using Demo Program
-
- If you have a mouse, run mouse.com (mouse driver) and
- menumous.com (supplied) before running the demo.
-
- To run the demo:
-
- dos> tp5menu <enter>
-
- Now, just play with the program a little bit, scroll
- through the menus, enter some data, try to fool the system.
- Press <F1> for help anywhere within the program. The
- complete source code for the demo interface to the menu
- procedures is included as tp5menu.pas, (there is source
- code for some of the other units also.)
-
- The examples given in the following text generally use
- source code from the demo program. Familiarity with the
- demo program is essential for a good understanding of the
- text.
-
- A good way to work is edit some of the menus in
- pps_init.pas and see how the changes affect the demo, BUT
- pps_init.pas MUST be renamed before editing. When changing
- the name of any of the units, you will also need to change
- the name of the include directives in the corresponding
- units. A good method of this is to use the "grep" program
- supplied with turbo 4.0. For example, if you change
- pps_init.pas look for pps_init in the source code files:
-
- dos> grep -i pps_init *.pas
-
- File PPS_INIT.PAS:
- unit pps_init;
- File PPS_USR.PAS:
- pps_init,
- File TP5MENU.PAS:
- pps_init,
-
- After renaming the file pps_init.pas you must also rename
- the unit name internal to pps_init.pas, and the include
- directives in pps_usr, and tp5menu.pas. But, because
- you've now edited pps_usr and tp5menu, they must now be
- renamed. The best thing to do is rename all source files!
-
- To recompile, just use the make option
-
- dos> tpc /m tp5menu
-
- and make sure all source code, (or compiled units), are in
- the current directory.
-
-
-
- 4
- Screen Pointers
-
- Most of the menus, PickLists, etc. require a pointer to a
- screen save buffer so the screen can be restored. The
- following buffers have been defined in menuvars.pas.
-
- ScreenPtr :pointer to 4000 bytes
- HalfScreenPtr :pointer to 2240 bytes (14 lines)
- QuarterScreenPtr :pointer to 1000 bytes
- EighthScreenPtr :pointer to 500 bytes
-
- Memory has been allocated as follows in pps_init.pas
-
- HelpScreen :HalfScreenPtr;
- HalfScreen1 :HalfScreenPtr;
- HalfScreen2 :HalfScreenPtr;
- QuarterScreen1 :QuarterScreenPtr;
- EighthScreen1 :EighthScreenPtr;
- EighthScreen2 :EighthScreenPtr;
- TextScreen :ScreenPtr;
-
- new(HelpScreen);
- new(HalfScreen1);
- new(HalfScreen2);
- new(QuarterScreen1);
- new(EighthScreen1);
- new(EighthScreen2);
- new(TextScreen);
-
-
-
-
- 5
- Create/Use program Header:
-
- Create program Header:
- All modification is done in PPS_INIT.PAS, and an actual
- example is given from that file.
-
- 1) define variable
- HdrList :HdrPtr;
-
- 2) allocate memory on heap
- new(HdrList);
-
- 3) initialize variables
-
- {the ".str" variables set what text is displayed}
- {".max" is the number of selections available up to a max of 6}
- {".sel" item currently selected, initialized in this case to 1}
- {the colors for this variable are set in the initialization}
-
- MenuSelFg :Foreground color, item is selected
- MenuSelBg :Background color, item is selected
- MenuNoSelFg :Foreground color, item is NOT selected
- MenuNoSelBg :Background color, item is NOT selected
-
- HdrList^.str[1] := 'Execute';
- HdrList^.str[2] := 'File Select';
- HdrList^.str[3] := 'Data Entry';
- HdrList^.str[4] := 'Quit';
- HdrList^.max := 4;
- HdrList^.sel := 1;
-
- Use Program Header
- 1) set byte variable to PickHeader(RowNumber,HeaderVar)
-
- var
- menu1 :byte;
- begin
- menu1 := PickHeader(1,HdrList);
- case menu1 of
- 1: begin
- {pull down execute menu}
- {see next section for details}
- end;
- 2: begin
- {File Select}
- end;
- 3: begin
- {Data Entry}
- end;
- 4: begin
- {exit procedure}
- end;
- end;
- end.
-
-
-
- 6
- Create/Use Pull Down Menus
-
- There are 2 different ways to use the pull down menus:
- 1) Menu selection
- 2) Data Entry
-
- The two types are very similar, and in fact are the same data
- type. In order not to waste memory, space is allocated
- specifically when variables are required. See VarPtr in
- MenuPtrType below. The VarPtr is explained in detail in the
- section on Data Entry Below.
-
- Here is the data type defined in menuvars.pas. Examples of
- implementation with/without data entry follow.
-
- type
- MenuPtr = ^MenuPtrType;
- MenuPtrType = record
-
- {text for selections} str :array[1..MenuMax]
- of string[MaxTextWidth];
- {selection "mask"} SelPattern :MenuString;
- {number of selections} max :byte;
- {item currently selected} sel :byte;
- {upper-left, x-position} x :byte;
- {upper-left, y-position} y :byte;
- {column width, char's} width :byte; *
- {width of text portion} TxtLen :byte; *
-
- * Width should be equal to TxtLen for "No Data Entry"
-
- COLORS:
- {border background} BorderBg :byte;
- {border foreground} BorderFg :byte;
- {not-masked,not selected} Fg :byte;
- {masked foreground} NoSelFg :byte;
- {selected item background} SelBg :byte;
- {selected item foreground} SelFg :byte;
- {unselected background} NoSelBg :byte;
- {variables background} VarBg :byte;
- {variables foreground} VarFg :byte;
- {menu title, text} title :title_type;
- {screen-save buffer pointer} ScreenBufPtr :Pointer;
- {pointer to variables} VarPtr :Pointer;
- {save old window up-left} OldWindMin :word;
- {save old window lo-right} OldWindMax :word;
- end;
-
-
-
- 7
-
- The following examples are from pps_init.pas, source included.
-
- *Declare menus
- var
- PullDowns :array[1..MaxPullDowns] of MenuPtr;
-
- *Allocate memory
- *Initialize Masks to Full, and Color Defaults
- begin
- for indx := 1 to MaxPullDowns do begin
- new(PullDowns[indx]);
- for i2 := 1 to MenuMax do
- PullDowns[indx]^.SelPattern[i2] := '*';
- PullDowns[indx]^.BorderBg := MenuBorderBg;
- PullDowns[indx]^.BorderFg := MenuBorderFg;
- PullDowns[indx]^.Fg := MenuHiFg;
- PullDowns[indx]^.SelFg := MenuSelFg;
- PullDowns[indx]^.SelBg := MenuSelBg;
- PullDowns[indx]^.NoSelBg := MenuNoSelBg;
- PullDowns[indx]^.NoSelFg := MenuLoFg;
- PullDowns[indx]^.VarFg := MenuVarFg;
- PullDowns[indx]^.VarBg := MenuVarBg;
- PullDowns[indx]^.VarPtr := nil; {just to be safe}
- end;
- end;
-
-
-
-
- 8
- *Initialize individual Menu
- No Data Entry Example
-
- *Menu Text Initialization
- PullDowns[ExeMenu]^.str[1] := 'User 1 ';
- PullDowns[ExeMenu]^.str[2] := 'User 2 ';
- PullDowns[ExeMenu]^.str[3] := 'Good Beep ';
- PullDowns[ExeMenu]^.str[4] := 'Bab Beep ';
- PullDowns[ExeMenu]^.max := 4;
- PullDowns[ExeMenu]^.sel := 1;
-
- *Co-ordinates of upper-left corner
- PullDowns[ExeMenu]^.x := 1;
- PullDowns[ExeMenu]^.y := 2;
-
- *TxtLen and Width are equal for Non-Data Entry
- PullDowns[ExeMenu]^.TxtLen := 14;
- PullDowns[ExeMenu]^.Width := 14;
- PullDowns[ExeMenu]^.title := '';
-
- PullDowns[ExeMenu]^.ScreenBufPtr:= EighthScreen1; *
-
- *EighthScreen1 is a POINTER to adequate memory for width*height*2
- *of menu defined, here 1/8 of screen (500 bytes) is sufficient
- *Hint, make sure two menus that use the same save buffer
- *can NEVER be active simultaneously
-
- Using Pull-Down Menus, No Data Entry
-
- OpenPullDownMenu(PullDowns[ExeMenu]);
- Repeat
- Menu2 := PullDownMenu(PullDowns[ExeMenu]);
- Case Menu2 of
- 1 :Do_User_1;
- 2 :Do_User_2;
- 3 :Good_Beep;
- 4 :Bad_Beep;
- end; {case Menu2}
- Until( (Menu2 = 0) or Rtn2Main );
- ClosePullDownMenu(PullDowns[ExeMenu]);
-
- The repeat, of course, is optional. This shows how to repeat
- different operations until either <esc> or <F10> is pressed.
- Rtn2Main is a global variable that gets set with <F10>.
-
-
-
-
- 9
- Data Entry Example
-
- The "InpStrType" is defined in menuvars.pas
- "Str" is what will be displayed in the menu
- "Typ" defines the variable type, currently supported
- int, longint, real, string
-
- type
- InpStrPtr = ^InpStrType;
- InpStrType = array[1..MenuMax] of record
- Str :string[MaxTextWidth];
- Typ :byte;
- Width :byte;
- end;
-
- *declare variable
- var
- VarVars :InpStrPtr;
-
- begin
-
- *allocate memory
- new(VarVars);
-
- PullDowns[VarMenu]^.str[1] := 'Set Mask';
- PullDowns[VarMenu]^.str[2] := 'String Var';
- PullDowns[VarMenu]^.str[3] := 'Real Var #1';
- PullDowns[VarMenu]^.str[4] := 'Real Var #2';
- PullDowns[VarMenu]^.str[5] := 'Int Var';
- PullDowns[VarMenu]^.str[6] := 'LongInt';
- PullDowns[VarMenu]^.str[7] := 'Auto Mode';
- PullDowns[VarMenu]^.str[8] := 'Pick Num';
- PullDowns[VarMenu]^.str[9] := 'Switch Var';
- PullDowns[VarMenu]^.max := 9;
- PullDowns[VarMenu]^.sel := 1;
- PullDowns[VarMenu]^.x := 1;
- PullDowns[VarMenu]^.y := 2;
-
- *set VarPtr = to pointer for variables allocated above
- PullDowns[VarMenu]^.VarPtr := VarVars;
- PullDowns[VarMenu]^.TxtLen := 14;
- PullDowns[VarMenu]^.Width := 28;
- PullDowns[VarMenu]^.title := 'Bullet-Proof Entry';
- PullDowns[VarMenu]^.ScreenBufPtr:= EighthScreen1;
-
- PullDowns[VarMenu]^.SelPattern := MaskId[MaskVar];
-
- *The SelPattern is what "masks" out selections, see section
- *below on using masks for details.
-
-
-
- 10
- Example from file PPS_INIT.PAS, procedure InitMenuVars
- *initialize variables
- *Please, don't be scared off by how this looks,
- *it's really quite easy!
- *There is a string variable which shows up when the menu is
- called, a variable which defines the type of variable at that
- location (i.e. string, integer, real, etc.), and a width
- variable which defines the character width. If the width of the
- variable is wider than the menu a separate window will
- automatically open up, demo example is file path.
-
- var
- vp :InpStrPtr;
- begin
- * vp = pointer to InpStrType (defined above),
- vp := PullDowns[VarMenu]^.VarPtr;
-
- * w = number of character spaces available, up to max
- * for the above example (Width=28) - (TxtLen=14) - 2 ==> 12
-
- w := PullDowns[VarMenu]^.Width - PullDowns[VarMenu]^.TxtLen - 2;
- for indx := 1 to 9 do
- vp^[indx].Width := w;
-
- * MaskVar is an example global variable which defines what
- * mask is active
- * StringCode tells entry routine this is a string
- vp^[1].Str := MaskList^.str[MaskVar];
- vp^[1].Typ := StringCode;
-
- vp^[2].Str := StringVar;
- vp^[2].Typ := StringCode;
-
- *For Variable initialization, variable values are converted to
- *strings for menu display (this is done automatically from now on)
- *RealVar1 is a real variable which is initialized in pps_glob.pas
-
- vp^[3].Str := Real2Str(RealVar1,w,2);
- vp^[3].Typ := RealCode;
-
- vp^[4].Str := Real2Str(RealVar2,w,2);
- vp^[4].Typ := RealCode;
-
- str(IntVar,vp^[5].Str);
- vp^[5].Typ := IntCode;
- * integers can't be any longer than 6 chars (-32768)
- vp^[5].Width := 6;
-
- str(LongIntVar,vp^[6].Str);
- vp^[6].Typ := LongIntCode;
- vp^[7].Str := OnOffList^.str[BoolVar];
- vp^[7].Typ := IntCode;
- str(MenuNum,vp^[8].Str);
- vp^[8].Typ := LongIntCode;
- vp^[9].Str := VarTypeList^.str[FrChgVar];
- vp^[9].Typ := IntCode;
-
-
-
- 11
- Data Entry Usage:
-
- All that has to be done is call the routine
- "inpvars" with the menu name, a return code (which is not
- used in most cases) and the address of the variable. The
- routine inpvars "knows" which item is selected, and what
- data type it is, so the bullet proof entry takes over, and
- won't change the variable unless a valid entry is received.
- If an invalid entry is received, the error window pops up
- with the invalid entry-ignored message. Pressing the <Esc>
- key aborts. Usage and a complete example follow on the
- next page.
-
- The example gives the source code in tp5menu.pas for
- the data entry portion of the demo program. This also
- shows how to use the ChgVar procedure which is how
- variables are "scrolled" through. This also shows how the
- HelpNum changes so <F1> gives "context-sensitive" help.
- The usage of repeat, and update are also demonstrated.
- Mvp is a pointer to InpStrType, much the same as Vp was in
- the initialization section.
-
-
-
-
- 12
- Usage:
- InpVars(PullDown Menu Name, Rtn Code, Variable Address);
-
- example:
- var
- mvp :InpStrType;
- begin
- OpenPullDownMenu(PullDowns[VarMenu]);
- repeat
- HelpNum := DataEntryHelp;
- UpdateMenu(PullDowns[VarMenu]);
- menu2 := PullDownMenu(PullDowns[VarMenu]);
- mvp := PullDowns[VarMenu]^.VarPtr;
- case menu2 of
- 1 :begin
- HelpNum := MaskListHelp;
- OpenPickList(MaskList);
- menu3 := PickList(MaskList);
- if menu3 <> 0 then begin
- mvp^[menu2].str := MaskList^.str[menu3];
- PullDowns[VarMenu]^.SelPattern := MaskId[menu3];
- end;
- ClosePickList(MaskList);
- end;
- 2 :InpVars(PullDowns[VarMenu],x,@StringVar);
- 3 :InpVars(PullDowns[VarMenu],x,@RealVar1);
- 4 :InpVars(PullDowns[VarMenu],x,@RealVar2);
- 5 :InpVars(PullDowns[VarMenu],x,@IntVar);
- 6 :InpVars(PullDowns[VarMenu],x,@LongIntVar);
- 7 :begin
- HelpNum := ChgVarHelp;
- ChgVar(OnOffList,BoolVar);
- Mvp^[Menu2].str := OnOffList^.str[BoolVar];
- if BoolVar = 1 then CommandMode := true
- else CommandMode := false;
- end;
- 8 :begin
- HelpNum := MenuNumHelp;
- GetMenuNum(MenuNum,SpclNum,Pulldowns[NumPtsMenu]);
- str(MenuNum,Mvp^[Menu2].str);
- end;
- 9 :begin
- HelpNum := ChgVarHelp;
- ChgVar(VarTypeList,FrChgVar);
- Mvp^[Menu2].str := VarTypeList^.str[FrChgVar];
- end;
- end;
- until ((menu2=0) or Rtn2Main);
- ClosePullDownMenu(PullDowns[VarMenu]);
- end;
-
-
-
- 13
- Using the Pull Down Menu Masks:
-
- The menus have a variable called SelPattern in the
- PullDownMenu record, see complete record above.
-
- The SelPattern is a string variable of length MenuMax
- (Maximum number of menus allowed in the PullDownMenus).
- When a PullDownMenu is opened or updated this variable is
- checked.
-
- '*' ==> Unmasked
- ' ' ==> Masked
-
- See Example Masks in the pps_init.pas file, and usage in
- the data entry portion of the demo, tp5menu.pas.
-
- For example the Odd Mask might look like this
- PullDowns[VarMenu]^.SelPattern := '* * * * * *';
-
- The Even Mask might look like this
- PullDowns[VarMenu]^.SelPattern := ' * * * * * ';
-
- The Full Mask might look like this
- PullDowns[VarMenu]^.SelPattern := '***********';
-
- The First Half Mask might look like this
- PullDowns[VarMenu]^.SelPattern := '****** ';
-
- The Last Half Mask might look like this
- PullDowns[VarMenu]^.SelPattern := ' *****';
-
- The true implementation has variables equal to each one of
- these patterns and the
-
- PullDowns[VarMenu]^.SelPattern := MaskID[MaskVar];
-
- where MaskID[MaskVar] are the patterns shown above.
-
- See complete example on page 12.
-
-
-
- 14
- Using Update
-
- Update is a procedure that is called whenever a parameter,
- or mask has changed in a PullDownMenu without closing and
- reopening the menu. Update does exactly that, it updates
- the menu on the screen to the current status. If the new
- mask masks out the item currently selected, the mask is
- changed to allow the current selection. Update also
- reflects the new values of any variables being displayed.
-
- Usage:
- UpdateMenu(MenuName);
-
- Example:
- UpdateMenu(PullDowns[FileMenu]);
-
- See complete example on page 12.
-
-
-
-
- 15
- Pick Lists
-
- Pick Lists are used much the same as the pull down menus
- without data entry. The window is opened, a variable is
- set to a function call (PickList) and the window is closed.
- Either the selection value is returned, or 0 if <Esc> is
- pressed. Simple!
-
- usage:
- OpenPickList(ListName);
- ByteVariable := PickList(ListName);
- Case ByteVariable of
- 1 :
- 2 :
- end;
- ClosePickList(ListName);
-
- ListName is of type PickListPtr which points to:
-
- PickListPtrType = record
- str :array[1..PickListMaxStr] of
- string[PickListStrW];
- max :integer;
- maxX :byte;
- sel :byte;
- y :byte;
- x :byte;
- title :title_type;
- ScreenBufPtr :Pointer;
- OldWindMin :word;
- OldWindMax :word;
- BorderBg :byte;
- BorderFg :byte;
- Fg :byte;
- SelBg :byte;
- NoSelBg :byte;
- NoSelFg :byte;
- end;
-
- All Variables should be obvious, except MaxX which is the number
- of selections on each line.
-
- A pick list usage example is included in the data entry
- example on page 12.
-
-
-
- 16
- Help Messages
-
- Help files are first generated using pps_help.pas. To
- create help, just assign a constant equal to the help name
- and define a record for that assignment. Then within the
- main program code, set the variable HelpNum equal to the
- constant. Constants must be defined consistantly in both
- the pps_help.pas and the main program, or in an included
- unit such as pps_glob.pas.
-
- There is a variable within the help record called NextRec,
- which should be set to the constant for the next page of
- the help, or set to 0 for the last page (or if there is
- only one page).
-
- A help procedure is automatically called with the current
- help number (global variable HelpNum) whenever F1 is
- pressed.
-
- Below is the record which is stored on disk for each help
- message.
-
- HelpMessType = record
- {NextRec = 0 if last, else}
- {NextRec = Seek Number of Next "Page" of Message}
- NextRec :integer;
- Str :array[1..MaxHelpLines]
- of string[HelpLineWidth];
- end;
-
- Usage for Creating help in pps_help.pas:
- const
- MainHeader = 1;
- begin
- HelpVar[MainHeader].NextRec := 0;
- HelpVar[MainHeader].str[1] := 'Welcome to the ...';
- HelpVar[MainHeader].str[2] := 'This Help utili...';
- HelpVar[MainHeader].str[3] := 'current choices...';
- HelpVar[MainHeader].str[4] := 'Select an item,...';
- ...
- end;
-
- Help Usage, tp5menu.pas
-
- const {constants may defined anywhere like pps_glob.pas}
- MainHeader = 1;
- begin
- HelpNum := MainHeader;
- ...
- end.
-
- Now whenever <F1> is pressed the preceding message is
- displayed in the "help window."
-
-
-
- 17
- Error Messages
-
- Contrary to Help messages, Error messages are stored in
- memory. This gives an example of each so the user can
- decide which method is best for their application.
-
- There is an array defined ErrorMessStr which contains the
- messages that will be popped up when an error occurs. The
- user should define constants that initialize the error
- message array, and set the global variable ErrorNum equal
- to that number when the error occurs. The main routine
- checks for a non-zero condition of the ErrorNum and reports
- the error when it occurs.
-
- Define Error constants in pps_glob.pas
-
- const
- {Error Codes}
- xyzError = 1;
-
- Define the string that is to be displayed with the error
-
- ErrorNum := NoError; {initialize to no error}
- ErrorMessStr[xyzError] := 'xyz Error Occurred...';
-
- Have procedure set up error number
-
- procedure User_Proc;
- begin
- if xyz then ErrorNum := xyzError;
- end;
-
- Usage in tp5menu.pas, when an error occurs
- begin
- User_Proc;
- if ErrorNum <> NoError then ErrorMessage
- else HunkyDory;
- ...
- end;
-
-
-
- 18
- General Windows
-
- The error window is an example of a "general window."
- Other examples are given in the pps_user.pas file as User1
- and User2. One general window defined is called IoList.
-
- Example:
- OpenIoWindow(IoList);
- do whatever you want
- CloseIoWindow(IoList); restores screen and returns
-
-
-
- 19
- Advanced Features
-
- Saving/Restoring Menus (reduces code size significantly)
-
- There are two additional procedures included for this exact
- purpose. Edit the code in the pps_init.pas to run
- SaveMenus after the initialization code has run. Running
- the program now will create a file with containing all the
- menu information. Next, comment out all the initialization
- code (except for pointers which must be defined at run
- time), and insert the RecallMenus procedure call. The
- pointer variables must be defined AFTER RecallMenus,
- because pointers will be destroyed when RecallMenus is run.
-
- In the demo program the savings are minimal because there are
- only 5 pull down menus, about 1500 bytes are cut off of the
- executable file, 5%. The savings will become much more
- substantial if the program is large.
-
-
- Setting up HotKeys
-
- Hot Keys are setup by editing the source code for the
- BeepKey4 procedure (included with registration). There is
- one routine used for all keyboard entry (and mouse entry
- for that matter), the hot key routines should be called
- from here. F1 is considered a hot key for help. Whenever
- F1 is pressed, the help procedure is called and the program
- resumes where it left off. The user may set up their own
- hot key procedures in the same manner.
-