Category : Pascal Source Code
Archive   : PULL55.ZIP
Filename : PULL55.DOC

 
Output of file : PULL55.DOC contained in archive : PULL55.ZIP



















MULTI-LEVEL PULL-DOWN MENUS
USER'S GUIDE

Version 5.5
August 24, 1989


Copyright (C) 1987-1989 Eagle Performance Software
All Rights Reserved.



_______
____|__ | (tm)
--| | |-------------------
| ____|__ | Association of
| | |_| Shareware
|__| o | Professionals
-----| | |---------------------
|___|___| MEMBER
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



T A B L E O F C O N T E N T S

1. INTRODUCTION . . . . . . . . . . . . . . . . . . . . . 4
Features . . . . . . . . . . . . . . . . . . . . . . 4
Using the Manuals . . . . . . . . . . . . . . . . . . 4
Licensing . . . . . . . . . . . . . . . . . . . . . . 5
Customer Service . . . . . . . . . . . . . . . . . . 5
ASP . . . . . . . . . . . . . . . . . . . . . . . . . 6

2. GETTING STARTED . . . . . . . . . . . . . . . . . . . . 7
Distribution Files . . . . . . . . . . . . . . . . . 7
Demonstration . . . . . . . . . . . . . . . . . . . . 7

3. PROGRAMMING MENUS . . . . . . . . . . . . . . . . . . . 11
Using the Shell . . . . . . . . . . . . . . . . . . . 11
Menu Modes . . . . . . . . . . . . . . . . . . . . . 11
Line Modes . . . . . . . . . . . . . . . . . . . . . 14
HiLite Control . . . . . . . . . . . . . . . . . . . 15
Adding Lines . . . . . . . . . . . . . . . . . . . . 16
Adding Menus . . . . . . . . . . . . . . . . . . . . 17
Adding Submenus . . . . . . . . . . . . . . . . . . . 18
Help Messages . . . . . . . . . . . . . . . . . . . . 20
Help Windows . . . . . . . . . . . . . . . . . . . . 21
Default Attributes . . . . . . . . . . . . . . . . . 23
Standard Borders . . . . . . . . . . . . . . . . . . 24
Control Flags . . . . . . . . . . . . . . . . . . . . 24
Summary . . . . . . . . . . . . . . . . . . . . . . . 26

4. SCREEN DESIGN . . . . . . . . . . . . . . . . . . . . . 27
Status Line . . . . . . . . . . . . . . . . . . . . . 27
Top Line Menu . . . . . . . . . . . . . . . . . . . . 27
Main Menu Row . . . . . . . . . . . . . . . . . . . . 27
Submenu Row . . . . . . . . . . . . . . . . . . . . . 28
Work Windows . . . . . . . . . . . . . . . . . . . . 28
Message Line . . . . . . . . . . . . . . . . . . . . 28
Help Windows . . . . . . . . . . . . . . . . . . . . 29
Start-Up Menu . . . . . . . . . . . . . . . . . . . . 29
Overriding Defaults . . . . . . . . . . . . . . . . . 30
Summary . . . . . . . . . . . . . . . . . . . . . . . 30

5. DATA WINDOWS . . . . . . . . . . . . . . . . . . . . . 32
Data Window Parts . . . . . . . . . . . . . . . . . . 32
Data Window Record . . . . . . . . . . . . . . . . . 32
Data Window Variable . . . . . . . . . . . . . . . . 33
Fields . . . . . . . . . . . . . . . . . . . . . . . 34
Titles . . . . . . . . . . . . . . . . . . . . . . . 35
Editing Keys . . . . . . . . . . . . . . . . . . . . 36
Key Sets . . . . . . . . . . . . . . . . . . . . . . 36
Key Translation . . . . . . . . . . . . . . . . . . . 37
Range Checking . . . . . . . . . . . . . . . . . . . 38
Help Messages . . . . . . . . . . . . . . . . . . . . 40
Help Windows . . . . . . . . . . . . . . . . . . . . 40
Default Attributes and Border . . . . . . . . . . . . 40
Default Location . . . . . . . . . . . . . . . . . . 41


2
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


Summary . . . . . . . . . . . . . . . . . . . . . . . 41

6. DATA ENTRY . . . . . . . . . . . . . . . . . . . . . . 42
Data Entry vs. Data Windows . . . . . . . . . . . . . 42
Data Entry Record . . . . . . . . . . . . . . . . . . 42
Adding Entries . . . . . . . . . . . . . . . . . . . 43
Displaying Fields . . . . . . . . . . . . . . . . . . 43
Sequential Entry . . . . . . . . . . . . . . . . . . 44
Edit Mode . . . . . . . . . . . . . . . . . . . . . . 46
Field Attributes . . . . . . . . . . . . . . . . . . 47
Single Entry . . . . . . . . . . . . . . . . . . . . 47
Summary . . . . . . . . . . . . . . . . . . . . . . . 47

7. WORK WINDOWS . . . . . . . . . . . . . . . . . . . . . 48
Making Steps . . . . . . . . . . . . . . . . . . . . 48
Reading the Keyboard . . . . . . . . . . . . . . . . 49
Multi-Level Windows . . . . . . . . . . . . . . . . . 51
Managing Winddows . . . . . . . . . . . . . . . . . . 52

8. USER WINDOWS . . . . . . . . . . . . . . . . . . . . . 54
Pull-Down Directory . . . . . . . . . . . . . . . . . 54
Interface . . . . . . . . . . . . . . . . . . . . . . 55

9. CONDITIONAL COMPILATION . . . . . . . . . . . . . . . . 57
Define Symbols . . . . . . . . . . . . . . . . . . . 57
Recompiling . . . . . . . . . . . . . . . . . . . . . 57

10. TROUBLE SHOOTING . . . . . . . . . . . . . . . . . . . 58
Goof Unit . . . . . . . . . . . . . . . . . . . . . . 58
Far Addresses . . . . . . . . . . . . . . . . . . . . 58
Multi-tasking . . . . . . . . . . . . . . . . . . . . 59
Customer Service . . . . . . . . . . . . . . . . . . 59

APPENDIX A: Other Products . . . . . . . . . . . . . . . . 60

APPENDIX B: Revision History . . . . . . . . . . . . . . . 62

APPENDIX C: Credits . . . . . . . . . . . . . . . . . . . 63

APPENDIX D: Glossary . . . . . . . . . . . . . . . . . . . 64

















3
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


1. I N T R O D U C T I O N


FEATURES

Welcome to PULL multi-level pull-down menus!

You have just obtained a copy of the highest performance pull-down menu
utilities available today for Turbo Pascal 5.5 (TP5). Both novice and
professional programmers will appreciate these simple and very powerful
utilities that are fully featured and fully configurable. They work on any
all IBM compatibles, including PS/2 and 3270 PC on any video page or any
text mode.

Here are some of the features you will discover:

- Uses the powerful routines of QWIK and WNDW.
- Work window(s) and complete interface for menus
- Pull-down menus with 3 menu modes and 8 line modes
- Pull-down file directory
- Highlighted command letters
- Unlimited levels of submenus
- Unlimited data entry windows for 9 types of data
- Data entry for the work window(s)
Free field entry with either fixed column or flexible
column length.
Full editing capability including insert cursor mode
Fields are easily selected with the cursor keys
Automatic NumLock for numerical data entry
Right or left justification for data entry output
Error messages for invalid data entries
Error messages for data entries out of range
- Automatic sizes and locations for menus
- Operation by cursor keys or command keys
- Pull/Pop between work window and nested submenu(s)
- Programmable control of pull and pop sequences
- Context-sensitive help windows
- Message lines for prompts and processing
- Writes direct to multi-tasking video buffers (MTVB).
- Full working shell for user development

PULL has been designed with a fill-in-the-blank concept. To get your
application up and running, you only need to fill in the appropriate
records or variables.

TP4 - The units provided in this distributed file only work under TP5.
However, the source code, provided with registration, compiles equally well
under TP4.


USING THE MANUALS

Disk Based Guides - The manuals for PULL are on disk so that you can
conveniently scan for the topic you are seeking. You can do this with any
list or search utility with a search function. You can also make a printed


Chapter 1, Introduction Page 4
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


copy. If you have not already printed this manual, refer to the READ.ME
file for instructions. At the present time, no bound manuals are being
offered with registration.

User's Guide - This manual, the one your are reading now, assumes that as a
programmer you are already familiar with Turbo Pascal 5.5, and that you
have a working knowledge of your disk operating system (DOS). It also
assumes that you are familiar with QWIK screen utilities in QWIK55.ARC and
WNDW55.ARC. This manual will provide the basic instructions for creating
and managing multi-level pull-down menus. It also contains a tutorial to
guide you step-by-step to create your own application.

Reference Guide - This manual describes in detail all procedures, functions
and variables used in PULL. It is a alphabetically arranged for easy
access in a format similar to the TP5 manual. Use this manual when you
have become familiar with the basic principles in the User's guide.


LICENSING

Registration - These routines and the documentation have been released for
distribution as Shareware. You have been given the chance to sample the
full capability of PULL without risk! If you find that PULL is a valuable
tool, then you are expected to register. You will find a reasonable
licensing schedule found in LICENSE.ARC to meet private or commercial
needs. When registering, be sure to specify the version for Turbo Pascal
(such as TP4 or TP5) you wish to receive.

Source Code - All registered users will receive source code when the signed
license agreement is returned with the registration. All source code
compiles under TP4 as well as TP5. The compiled units in the distributed
file were compiled with TP5 and only work in TP5.


CUSTOMER SERVICE

If you have questions, comments, or suggestions, the Eagle can be contacted
by four means - (1) CompuServe, (2) telephone, (3) The Eagle BBS, or
(4) mail.

CompuServe - The most dependable way to contact the Eagle is through
CompuServe. James (Jim) H. LeMay has written the TP5 version of QWIK, but
the person to contact is Jordan Gallagher who can be reached on the Borland
Forum by typing GO BPROGA from the CompuServe main menu. You will enter
the Forum for Turbo Pascal. You can contact Jordan with his PPN number of
73557,2342. Messages can also be left through EasyPlex.

Telephone - Jordan can also be reached by phone at (214) 539-7855 on
weekdays and Saturday from 9:00 a.m. to 8:00 p.m CST.

The Eagle BBS - You can also contact us on our 24-hour BBS at (214) 539-
9878, 1200/2400 N81.

Mail - For registration or problems, please write:



Chapter 1, Introduction Page 5
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


Eagle Performance Software
P.O. Box 292786
Lewisville, TX 75029-2786

In your written request for resolving problems, be sure to include:

. A 5 1/4 inch diskette of compilable source code of the problem.
. The Eagle product and version number.
. The computer make and model.
. The type of video card, video monitor and keyboard.


ASP

PULL is a Shareware program conforming to the standards of the Association
of Shareware Professionals (ASP). You can get more information about ASP
by writing to:

Association of Shareware Professionals
P.O. Box 5786
Bellevue,WA 98006

This program is produced by a member of the Association of Shareware
Professionals (ASP). ASP wants to make sure that the shareware principle
works for you. If you are unable to resolve a shareware-related problem
with an ASP member by contacting the member directly, ASP may be able to
help. The ASP Ombudsman can help you resolve a dispute or problem with an
ASP member, but does not provide technical support for member's products.
Please write to:

ASP Ombudsman
P.O. Box 5786
Bellevue,WA 98006

or send a CompuServe message via EasyPlex to ASP Ombudsman 7007,3536.























Chapter 1, Introduction Page 6
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


2. G E T T I N G S T A R T E D

This section will acquaint you with the files on distribution disk and show
you a couple of demonstrations to quickly see what PULL can accomplish.


DISTRIBUTION FILES

In this version, PULL55.ARC contains:

Read. .me: Note of printing instructions for manual.
Pull55 .doc: This document - a user's guide to PULL.
PullRef .doc: PULL Reference Guide document covering each
routine and variable in detail.
Pull55 .tpu: This unit has the full power of all of its
capabilities. Please note that because PULL55.TPU
uses P55-VAR.INC all constants have been assigned.
In order to make any changes in the data
requirements, the complete source code will be
required.
Pull55- .pas: Shows the interface portion of PULL55.
P55-var .inc: This file is the actual source code which lists
all of the types, constants, and variables used
for PULL55.TPU.
PullDemo.pas: Fully functional working demo.
PullWork.pas: Procedures for the main work window(s).
PullStat.pas: Stats to configure the menus including global
keys.
PullData.pas: Data to configure data entry windows and fields.
PullDir-.pas: Just interface for PULLDIR.PAS.
PullDir .tpu: Unit for a pull-down file directory.
PullShel.arc: Contains shell files to develop your own
application.
Qwik55 .tpu: Unit for quick screen writing.
Strs .tpu: Unit from QWIK55 for number-to-string conversions.
WndwP55 .tpu: Multi-level virtual window unit for PULL.TPU.
Wutil .tpu: Independent utilities unit used in WNDW.TPU.
Goof .pas: Unit to display errors.
License .arc: ARC file containing license agreement and ordering
details.


DEMONSTRATION

To get the feeling of the speed and features of PULL, let's run the
demonstration program that comes with the utilities. Do the following
steps:

1. Copy QWIK55.TPU to QWIK.TPU.
2. Copy WNDWp55.TPU (not WNDW55.TPU) to WNDW.TPU. !!!
3. Copy PULL55.TPU to PULL.TPU.
4. Make, compile and run PULLDEMO.PAS. (If you get an ERROR
15 or 70, then steps 1-3 were not done carefully.)
5. Follow along in the overview below.



Chapter 2, Getting Started Page 7
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


Familiar Environment - You will probably feel right at home with the
environment created with PULL as it appears very similar to the TP5 editor.
It is interesting to note that PULL was developed with TP3 before TP4 was
ever released. However, you should find the operation quite similar.
While you are running the demo, let's get familiar with the format and
operation of the environment and follow along with this overview:

. Status Line - Row 1 just holds the title of this program. It is
optional.

. Top Line Menu - Row2 has been optionally assigned to be the top
line menu. Press F10 at any time to access it.

. Work Window - For this demo, Rows 4 to 23 has a 20x78 window for
the major part of your input/output. You can also have multi-
level work windows.

. Main Menu - To access a main menu, press RETURN or a command
letter (LTR) while the top line menu is highlighted on any
selection. Or, you can use a combination of the ALT key and a
letter, such as Alt-F to get to the File menu.

. Submenu - A submenu is a menu under a Main Menu. To access a
submenu, press RETURN when the HiLite is at a menu line with the
three-bar symbol (which looks like a menu). You can see three
levels of menus by pressing Alt-A/Tires/Brands.

Local Keys and Letter Commands - While a window is shown, several keys
operate for just that window. These keys can be listed in the message line
or they can be assumed to be the command letters highlighted on each menu
line.

. Help Windows (F1) - While the Brands menu is still showing,
press F1 to get context-sensitive help. A help window is
assigned to every window and menu.

. Keys on Message Line - The bottom line of the CRT, being closest
to the keyboard, indicates the available keys that can be used
for the current context. It is also used for help or error
messages. While the help window is displayed, the next key
pressed will also pass through as a command. For instance, press
RETURN now and see the help window removed and Firestone will
also become flagged.

. Pop and Pull (F2) - F2 is a pop-and-pull key that toggles between
the pull-down menus and the work window. Press F2 twice and you
will see that it remembers the last menu that was pulled.

. Command Letters (LTR) - If you wanted to select WeatherGuard on
the Brands menu, just type the letter "W" which is highlighted.
These letters will work in any menu.

. Cursor Keys - All of the cursor keys like the arrows, Home and
End keys, have assigned functions as well as the control-shifted
cursor keys. You can discover what they do by experimenting with


Chapter 2, Getting Started Page 8
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


them in a menu.

. ESC Key - The ESC key always backs out of the current menu/window.

Global Keys - Extended key combinations can be used to access any part of
the program. In this demo, some have been assigned with the ALT key.
Press down ALT for a half second and see the available global keys listed
on the message line.

. Directory (Alt-D) - Press Alt-D now to get a directory of your
disk. If you would like to continue testing the directory, press
F1 for instructions.

. Exit (Alt-X) - To exit the program, one alternative is to use
Alt-X, but don't do it now.

. Top Line Menu (F10) - As mentioned before, to get to the top line
menu, press F10 at any time.

Data Entry Windows - Each menu can additionally pull down a data entry
window which is indicated with a small dot symbol on the menu line. These
windows are fully configurable and have full editing capability. They have
a free-field entry concept where a entire string is typed and edited before
entering. Let's try a few fields.

. Data Entry Types - Press Alt-E to see a menu of all the data
entry types available. Press RETURN when the HiLite is at a menu
line with a small dot symbol. Pressing RETURN again will exit
the window entering the data shown. You can clear any data
entered by pressing ESC which also removes the window.

. Editing - Press "I" while the main menu is still shown and enter
a value for the integer. The virgin entry is highlighted until
you press a key. The entry has full edit capability using the
cursor keys and some familiar WordStar control keys. Press F1
for a list. Even the insert mode is indicated with a half-block
cursor.

. Options - All sorts of options are available for these windows
including range checking, fixed and flex fields, character
control and translation, automatic NumLock, justification,
titles, and attributes.

Work Window Data Entry - The same procedures used for the data entry
windows can be used for entering data in the work windows. In addition,
PULL has a smart algorithm that knows where several fields are on the
screen. So moving from field to field with all the cursor keys is
intuitive.

. Moving the HiLite - Press F2 to get back to the work window with
all of the data entry fields. One field will be highlighted
which means it can be moved to select another field. All of the
cursor keys move the HiLite including the control-shifted keys
and the Tab and Shift-Tab keys. Move the HiLite to the Integer
field.


Chapter 2, Getting Started Page 9
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



. New Values - To enter a new value for the integer, simply start
typing some numbers and the HiLite will change colors. You can
see that only numbers and the sign can be entered. Press RETURN
to enter the new value or press ESC to restore the old value.

. Editing - To edit the value currently shown in a field, press
RETURN or any WordStar control key.

Other Features - There are many other features in the menus which will be
covered later including menu and line modes, and direct menu control. You
may continue to discover other features in the demo if you want. When
finished, press Alt-X to quit.

Multi-tasking - This demo is already set to work in multi-tasking
environments compatible to DESQview, TaskView, and IBM 3270 PC.









































Chapter 2, Getting Started Page 10
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


3. P R O G R A M M I N G M E N U S

This section will get you familiar with the basics of window programming
by starting with very basic menus and then taking you step-by-step through
the full variety of options and modes available.


USING THE SHELL

Shell Program - Let's experiment will PULL by developing our own
application to see how powerful it can be. A shell program, which is a
bare bones application, has been provided with PULL in the file
PULLSHEL.ARC. These files will help you get started for any application.
But for now, it can be an excellent learning tool. To keep these files
separate from the PULLDEMO files, create another working directory and
unarchive the files in PULLSHEL.ARC. The files to be extracted are:

PullShel.pas
PullData.pas
PullStat.pas
PullWork.pas

In addition, the follow files need to be on you unit path or copied into
the same directory:

Qwik.tpu

Wndw.tpu
Wutil.tpu
Strs.tpu
Pull.tpu
Goof.pas

Running the Shell - To make sure we have everything available, load
PULLSHEL.PAS, make, and run the program. You should be able to operate
this program the same as PULLDEMO.PAS. There are only two menus - First
and Quit. To Quit, you can either use the Quit menu or use the global key
Alt-X.

Features Available - The shell has every feature available. They can be
added or eliminated. However, some code cannot be entirely eliminated or
altered unless you are registered with the source code. But let's continue
to see what the program can really do.


MENU MODES

In this section, we will delve right into the menus and see how they
function and what changes can be made. PULL has three menu modes for every
menu - ExecChoice, SingleChoice, and MultipleChoice. These modes determine
how all the lines in the menu can interact as a whole.

SingleChoice - You probably noticed that the First menu had one flag on it
because it was a SingleChoice menu. One and only one item could be flagged
by pressing return on any one line. Let's examine the data record of menu
and see how it was made to be single choice.


Chapter 3, Programming Menus Page 11
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



1. Load the file PULLSTAT.PAS into the TP editor.
2. Set PULLSHEL.PAS to be the Primary file.
3. Search for "with TopMenu".
4. See the following code:

GetMainMenu (FirstMenu);
MenuMode := SingleChoice;
SingleFlagLine := 3;
Title := 'First';
Line[1] := 'A line';
Line[2] := 'B line';
Line[3] := 'C line';
Line[4] := 'D line';
DefaultLine := 2;
MsgLineNum := ord(MainML);
HelpWndwNum := ord(MainMenuHW);
SaveMainMenu;

TopMenu - All these variables are fields in the current menu record called
TopMenu. Notice that MenuMode is set to SingleChoice. And that's how it
is done! That's all it takes to tell PULL that all items on the menu are
single choice. The program simply takes care of any selection. So how do
you know which line has been selected? Just get the value of
TopMenu.SingleFlagLine. But also notice that SingleFlagLine has been
initially assigned to line 3. Now you know why the "C line" is flagged
when the program first starts. Setting SingleFlagLine is only needed for
the SingleChoice mode. So how do you make it multiple choice?

MultipleChoice - Let's change MenuMode to MultipleChoice and run the
program again. Do it now. This time you won't see any flags initially,
but each line can be toggled on and off by selecting any line with RETURN.
Ok, how do we know which line has been flagged now? There are several more
variables in the menu record other than shown here. Each Line has an
associated boolean variable called Flagged. For example, if you want to
see if Line[3] has been flagged, just test and see if Flagged[3] is true.
But suppose we want some of those lines to be initially flagged?

Flags - All the code we have seen is within a procedure called
GetUserPullStats which initializes all the menus from InitPull. The
procedure GetMainMenu simply grabs a copy of the current menu record from
the heap which happens to be cleared with all zeros at this time. That
means everything is a default value of zero unless we change it. So, the
value of Flagged for each line is false. Let's see if we can set a couple
of lines to be initially true by modifying the code to:

...
MenuMode := MultipleChoice;
SingleFlagLine := 3;
Title := 'First';
Line[1] := 'A line'; Flagged[1] := true;
Line[2] := 'B line'; Flagged[2] := true;
...

Run the code again and verify that the first two lines are initially


Chapter 3, Programming Menus Page 12
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


flagged. If they are, then you are already getting the hang of how to
program pull-down menus! PULL is based on a fill-in-the-blank concept
where you supply the data and the program takes care of the rest.

Changed Flags - If there are several flags in the menu and just one is
changed, how can you know? Anytime a flag is altered in the menu, the
variable "Changed" in the menu record is set to true which gives a quick
survey for any action that may be needed. This value remains true until
your application program manually sets it false.

Executing Procedures - But having a simple flag may not be enough for your
application. Suppose you may also want to DO something as well. So how
can we execute a procedure along with the selection? Again, each line has
an associated execution pointer ProcPtr. Simply assign any valid procedure
address to it and it executes it! Try the following code:

...
MenuMode := MultipleChoice;
SingleFlagLine := 3;
Title := 'First';
Line[1] := 'A line'; Flagged[1] := true; ProcPtr[1] := @DummyProc;
Line[2] := 'B line'; Flagged[2] := true; ProcPtr[2] := @DummyProc;
...

Run this code and you will find that every time line 1 or 2 is toggled, the
message "Processing ..." is displayed briefly on the message line which is
all this dummy procedure was supposed to do. After it is processed, the
line is then flagged. The procedure DummyProc is actually back a few lines
in the code just before GetUserPullStats. This makes it very convenient to
have these procedures in the same file, but they don't have to be. Since
the pointer is FAR, these procedures, which have been forced to FAR, can be
called from other units as well.

Nil Pointer - So how come procedures were not executed before the pointers
were assigned? Again, all values are zero until changed. So, the pointer
was Nil. The program simply ignores nil pointers and therefore does not
execute anything.

ExecChoice - This mode only executes procedures with ProcPtr and just
ignores all flagging. This is also the default mode. Let's try this by
adding the following braces:

...
{ MenuMode := MultipleChoice;
SingleFlagLine := 3; }
Title := 'First';
Line[1] := 'A line'; Flagged[1] := true; ProcPtr[1] := @DummyProc;
Line[2] := 'B line'; Flagged[2] := true; ProcPtr[2] := @DummyProc;
...

Run it again. You found that both line 1 and 2 executed the dummy
process, but the flags weren't toggled. ExecChoice just ignores flagging.
Flags are usually not useful with ExecChoice mode and they can remain
false. Lines 3 and 4 did absolutely nothing since the pointers were nil.



Chapter 3, Programming Menus Page 13
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


Default Mode - How come MenuMode was not assigned to ExecChoice and instead
was commented out with braces? We could have if we wanted, but ExecChoice
is the default mode with an ordinal value of zero. So, it saves code to
leave it out.


LINE MODES

In this section, we will discover how each line in the menu can have one of
several different modes and then test each one to see its effect.

Seven Line Modes - Not only does the whole menu have a mode, but each line
can have one of eight different modes:

Choice - permits flagging with Single- or MultipleChoice and
executes the ProcPtr.
ExecOnly - executes the ProcPtr without flagging.
NoChoice - disabled by the your program.
Comment - bypassed by the highlight.
Partition - mid-menu horizontal border.
ToDataWndw - to pull a data entry window.
ToSubMenu - to pull next submenu level.
ToUserWndw - like ExecOnly, and adds a Submenu symbol.

These names are the actual identifiers used in LineModeType. Each line has
an associated line mode saved in the variable LineMode. For example, to
see what mode is on line 3, just check the value of LineMode[3].

Choice - This is the default and, as you would guess, its ordinal value is
zero, so we never have to set it. With this line mode and a menu mode of
SingleChoice or MultipleChoice, the line can be flagged like we have seen
in the previous examples. But it is rare that any menu would have only
flags. So, what other alternatives are there?

ExecOnly - Let's suppose that just one of the lines on our First menu
should never be flagged, but all the others can. How can we isolate it?
Back to the current example, revise the menu to be MultipleChoice with the
following changes:

...
MenuMode := MultipleChoice;
{ SingleFlagLine := 3; }
Title := 'First';
Line[1] := 'A line'; Flagged[1] := true; ProcPtr[1] := @DummyProc;
Line[2] := 'B line'; LineMode[2] := ExecOnly; ProcPtr[2] := @DummyProc;
...

Run it again and see that we can't toggle the flag on line 2 since it was
assigned as ExecOnly. All it does is execute DummyProc even though the
menu mode is MultipleChoice.

Comment - Suppose we wanted a title or some type of comment or help message
inside the menu itself. That line should not be considered as a valid
choice. In fact, the line should never be highlighted. Try changing line
3 to the following:


Chapter 3, Programming Menus Page 14
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



...
Line[2] := 'B line'; LineMode[2] := ExecOnly; ProcPtr[2] := @DummyProc;
Line[3] := 'My comment'; LineMode[3] := Comment;
...

Run it and move the HiLite up and down. You can see that the HiLite passes
right over line 3 and never accesses it. By the way, notice also that the
first letter of "My comment" was not highlighted as a command letter. In
fact, the entire line is a different attribute. Also notice that the menu
has automatically increased in width to accommodate the new longest line.

Partition - Sometimes it is easier to understand a menu when it is divided
into separate sections. This can be done with the line mode of Partition.
Change LineMode[3] as follows:

...
Line[2] := 'B line'; LineMode[2] := ExecOnly; ProcPtr[2] := @DummyProc;
{ Line[3] := 'My comment'; } LineMode[3] := Partition;
...

When you pull down the menu, you will see that line 3 has become an
extension of the border with the same style and attribute. Moving the
highlight up and down will also show that the partition is passed over just
like a Comment. Since Line[3] was unecessary and was commented out with
braces.

NoChoice - Suppose you want a line to be temporarily unavailable because it
didn't apply at a given stage in your program. You can overwrite the menu
record with a line mode of NoChoice which has the same effect as a Comment,
except you can enable it again by changing the line mode back to what it
was. The command letter will again become available for that line. In
contrast, Partition and Comment never have a command letter.

Other Line Modes - There are three remaining modes, ToDataWndw, ToSubMenu,
and ToUserWndw, which will pull down another level of a menu or a window.
These can also be assigned to LineMode which will be covered in more detail
later.


HILITE CONTROL

Highlight Line - The menu highlight bar is tracked by a variable called
HiLiteLine which is also in TopMenu. Any time the highlight (also called
HiLite) is moved, this value is updated to the current line number and
saved. So, upon re-entering the menu, the HiLite will still be on the same
line before as before.

Default Line - The HiLite has to start somewhere. In our current example,
the variable DefaultLine controls the initial line for the HiLite. When
you run it, you can see that the first time the menu is pulled, line 2 is
highlighted. Now move the HiLite down to line 4. If you exit and re-enter
the menu, the HiLite is still on line 4. So, we know that it always
remembers the current line. But what is the default for DefaultLine?
Let's find out. Comment out the following line:


Chapter 3, Programming Menus Page 15
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



...
Line[4] := 'D line';
{ DefaultLine := 2; }
MsgLineNum := ord(MainML);
...

Run the program and you will find that the HiLite starts on line 1 and not
zero. InitPull takes a second look at all menu records and makes sure that
all DefaultLines have been set. If not, it sets DefaultLine to line 1.
But suppose we want the HiLite to start on the same line every time the
menu is pulled?

Back To Default Line - You can force the HiLite to same initial line by
setting BackToDefault to true. Let's try it on our current example:

...
Line[4] := 'D line';
DefaultLine := 2;
BackToDefault := true;
MsgLineNum := ord(MainML);
...

When you pull-down the menu this time, the default line is 2. But move the
HiLite to line 4 and exit the menu. When the menu is pulled again, the
HiLite goes back to line 2. Looking at the code, the Quit menu record is a
few lines down from the First menu. There you can see that BackToDefault
is set to true for that menu as well which would keep a user from
inadvertently exiting the program.


ADDING LINES

Adding Lines - To add more lines to a menu is a snap - just add a line.
Try the following modification on the First menu.

...
Line[4] := 'D line';
Line[5] := 'E line'; { add this line }
DefaultLine := 2;
...

The program automatically knows how many lines are in the menu so that it
is sized correctly and the HiLite knows how far to extend. How many lines
can be added?

Maximum Lines - To control the size of the menu record, the maximum number
of lines per menu is set by MaxMenuLines. Go to a file called P55-VAR.INC
and you will find it to be the very first constant in the file and it has
been arbitrarily set to 15 lines. This is one of several configuration
constants preset in PULL. To be able to change these values, you must have
the source code to PULL which includes the file P55-VAR.INC.

Maximum Characters - Each menu line is also limited to a maximum length.
You can discover this by testing this code:


Chapter 3, Programming Menus Page 16
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



...
Line[4] := 'D line';
Line[5] := 'E line is longer than 20 characters';
DefaultLine := 2;
...

The menu is only wide enough to accommodate 20 characters which is also
preset with the constant MaxCharsPerLine.


ADDING MENUS

Now that you are familiar with the scope of a single menu, you can take the
next step and learn how to include additional menus.


Main Menu Name - The first thing needed is a name for a new main menu. On
the first page of PULLSTAT.PAS, find an enumerated type called
MainMenuNames and insert a new name called SecondMenu:

MainMenuNames = (NoMainMenu,FirstMenu,SecondMenu,QuitMenu);

It is important that these names are in order so that InitPull will
arrange them correctly.

Main Menu Record - Now the record of SecondMenu can be added. Between the
FirstMenu and QuitMenu records add the following code:

GetMainMenu (SecondMenu);
MenuMode := MultipleChoice;
Title := 'Second';
Line[1] := 'A2 line';
Line[2] := 'B2 line';
Line[3] := 'C2 line';
Line[4] := 'D2 line';
MsgLineNum := ord(MainML);
HelpWndwNum := ord(MainMenuHW);
SaveMainMenu;

Now run the program. You can see that there are now three menus that can
be pulled down. They are arranged in the order of the MainMenuNames. Just
for fun, let's reverse the names in MainMenuNames and see what happens:

MainMenuNames = (NoMainMenu,SecondMenu,FirstMenu,QuitMenu);

When you test this, you will find the two menus in different positions.
This makes rearranging a snap. We didn't even have to change anything
about the MainMenu records themselves.

Title - For a main menu, the title is required. By default, the first
letter is used for command letter after pressing F10. Press F10 now and
then press "S". This will pull down the SecondMenu. But what about the
global key Alt-S? Press F2 to get back to the work window and try Alt-S.
Nothing happens.


Chapter 3, Programming Menus Page 17
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



Global Key - To assign an extended key combination to this menu, go to the
bottom of the file to the section called Check Global Keys. In this code,
an assignment can be made for this menu. Insert the following line into
the code:

...
AltF: SetCmdSeq ('F');
AltS: SetCmdSeq ('S'); { insert this line }
AltQ: SetCmdSeq ('Q');
...

This is part of a case statement, so the order is not important. In
addition, a value must be assigned to the constant AltS. Back up a few
lines and add:

...
AltF = #33;
AltS = #31; { insert this line }
AltQ = #45;
...

Now run the code and try Alt-S again to find that it now works. But what
did we just do? Any time an extended key is pressed at the keyboard, the
program always passes through the procedure called CheckGlobalKeys. If the
extended keycode matches one in the case statement, the program sets a
sequence of normal key codes that would be pressed just as if pressing F10
and then "S". The keycode constant can be referenced in Appendix C of the
TP5 reference manual.


ADDING SUBMENUS

Every menu can pull down another submenu. This section will show how to
include one. The method is much the same as with main menus.


Submenu Name - Also at the beginning of PULLSTAT.PAS is an enumerated type
called SubMenuNames which looks like:

SubMenuNames = (NoSubMenu,MySubMenu);

Let's go ahead and use the name MySubMenu.

Submenu Record - Just after the main menu record QuitMenu is an area for
submenus. There is already a record made for MySubMenu and looks like the
following:

GetSubMenu (MySubMenu);
MenuMode := SingleChoice;
SingleFlagLine := 5;
Line[1] := '1 line';
Line[2] := '2 line';
Line[3] := '3 line';
Line[4] := '4 line';


Chapter 3, Programming Menus Page 18
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


MsgLineNum := ord(SubML);
HelpWndwNum := ord(SubMenuHW);
SaveSubMenu;

It is exactly like the main menu record, except to get and save it,
GetSubMenu and SaveSubMenu are used. A title is not required for a
submenu as InitPull automatically gives it the name of the parent menu.
Now let's link the submenu to a main menu.

Linking Menus - Choose SecondMenu line 2 for the line where MySubMenu is to
be linked. In the SecondMenu (not the submenu) record, modify line 2 to
the following code:

...
Title := 'Second';
Line[1] := 'A2 line';
Line[2] := 'B2 line'; LineMode[2] := ToSubMenu;
LinkNum [2] := ord(MySubMenu);
...

Run the code and see that the submenu is pulled down when you press RETURN
on line 2 of SecondMenu. This is probably simpler than you thought! You
can also see a three-bar symbol on this line which indicates the line is
linked to a submenu. By setting the line mode to ToSubMenu, the program is
prepared to pull-down another menu. LinkNum identifies the record to be
pulled which is MySubMenu. LinkNum is a byte type so using Ord is
required.

Linking Configuration - The submenus link in a slide-up rather than a
slide-under configuration. Menus grow vertically as the list expands. If
the list gets too long, it can slide up when it hits the bottom of the
screen. This leaves both the main menu and submenu in full view. In
contrast, the data windows, which are covered later, use the slide-under
configuration.

Default Linking Direction - Most Submenu are linked to the main menu in a
right-preferred arrangement. When menus get crowded to the right, InitPull
will automatically reverse to the left and all dot and 3-bar symbols will
also appear on the left. Each subequent Submenu will continue to link in
the same direction as its parent as far as it can.

Manual Linking Direction - As long as LinkDir is not specified like in our
example, InitPull will configure it for you. However, this may not be
preferred in all cases. To specify it manually, set the value of LinkDir
in that menu record to Left or Right which forces all submenus to be linked
in that direction.

Global Key - Suppose this is a frequently used submenu and we want to
assign an extended key, say Alt-M, to access it. To do this, it is much
the same as with a main menu, except there is an additional keystroke. Add
the following line to CheckGlobalKeys:

AltM: SetCmdSeq ('SB');

and include a value for the constant Alt-M:


Chapter 3, Programming Menus Page 19
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



AltM = #50; { the Alt-M extended key code }

When you run the program, pressing Alt-M will pull down both SecondMenu and
MySubMenu just as if you had sequentially pressed F10, "S" and "B".

SetCmdSeq - PULL saves the sequence of keystrokes for the current menu
level in a global string variable called CmdSeq. SetCmdSeq compares the
current location of CmdSeq with the new destination and sets two variables
for the shortest path - MoreCmdSeq and PopLevels. This will be covered
later in detail under the Control Flags section.

SubSubmenus - SubSubmenus can be added in just the same way as submenus.
In fact you could nest them as deep as you want. InitPull expects the
record names in SubMenuNames to be in a certain order so it can properly
locate each one on the CRT. Just be sure that the order is all Submenus
first, all SubSub-menus second, all SubSubSubmenus third, etc.


HELP MESSAGES

Each menu has a help message that is displayed on the last line of the CRT
where the application can indicate valid keys and status or error messages.
In this section, you will discover how these messages can be linked to any
menu while it is displayed.


Reserved Messages - PULL has already included some predefined messages for
several contexts including those for main menus and submenus. In
PULLSTAT.PAS, just below the last submenu record, you can find an array of
MsgLines. The ones reserved for main menus and submenus are MainML and
SubML, respectively:

MsgLine[ord(MainML)]:=' F1-help F2-pop LTR-cmd ESC-return '+
' '^[^Z' menus '^X^Y'-hilight CR-select';
MsgLine[ord(SubML)] :=' F1-help F2-pop LTR-cmd ESC-return '+
' '^X^Y'-hilight CR-select';

The concatenation is just so that it will fit within an 80 column width in
the source code. Back at the top of the file, you can find the enumerated
type MsgLineNames that helps identify each message. All the messages up to
HelpML are reserved as PULL expects them to be in that order. But new ones
can be added.

New Messages - To create a new message, just append a name in the
MsgLineNames type and write out your new message. Let's try it on the Quit
menu by changing MsgLineNum in its menu record as follows:

...
Line[2] := 'Quit'; ProcPtr[2] := @SetQuit;
BackToDefault := true;
MsgLineNum := ord(QuitML);
...

Then append the name QuitML to the end of MsgLineNames:


Chapter 3, Programming Menus Page 20
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



MsgLineNames = (NoML,WorkML,TopML,AltML,MainML,SubML,DW_ML,DE_ML,
SeqML,HelpML,ProcML,QuitML);

And finally, let's create the message itself:

MsgLine[ord(QuitML)] := ' Press "Q" if you are sure you want to quit.';

Short messages are no problem, because PULL will clear the rest of the
message line. Run the program now and see that the new message appears
when the Quit menu is pulled. By now, you are seeing that pull-down menus
can link other menus and messages quite easily.

Alt Key Message - You may have noticed when you hold down the Alt for more
than a half second, a message appears for the possible combinations. When
we created a submenu with global key access, it is not likely a first-time
user would know the key was available. The AltML message is reserved for
this purpose. Let's alter the line to:

MsgLine[ord(AltML)] :=' Alt: F-First M-MySubMenu '+
' X-Exit';

Run the program and hold down the Alt key to test the new message.


HELP WINDOWS

Many times the help message is not enough to fully explain the options
available for the context. In this section, you will discover how to
create context-sensitive help windows and apply them to the menus.


Help Window Record - Just as each menu has its own record, each Help Window
also has one called HelpWndw. There are only a couple of variables that
need adjustment, to link in the number of lines to be included in the
window. Let's try creating a help window for a main menu.

Example Window - Run the current example program again and test the F1
key while the SecondMenu is pulled down. You should see a two-line help
window with the message "Main menu help message". So, some help window is
already there, but the message is just bare bones. Let's find out how the
message got there and alter it.

Help Lines - In PULLSTAT.PAS after the MsgLine messages, there is another
section for setting HelpLines. You should be able to see the code:

HelpLine[ord(HLm1)]:='Main menu help message';
HelpLine[ord(HLmL)]:='';

These are the actual messages you saw in the help window. Each window can
have a variable number of lines in the help window. The program will
automatically size the window to fit in all the lines. Let's edit and add
an extra line:




Chapter 3, Programming Menus Page 21
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


HelpLine[ord(HLm1)]:='Main menu help message';
HelpLine[ord(HLm2)]:='Press RETURN on the highlighted line to make';
HelpLine[ord(HLmL)]:='your selection.';

Since a new HelpLine name, HLm2, has been added, it must be inserted in the
enumerated type HelpLineNames at the top of the file:

...
HLt1,HLtL, { Top Line Menu }
HLm1,HLm2,HLmL, { Main menu } { Modify this line. }
HLs1,HLsL { Submenu }
...

Now run the program and test the modified help window. This time you
should see the three lines. With just a couple of changes, all help
windows are still in order along with the contents because it is so easy to
work with names instead of numbers. How did the program know how many
lines to display even though changes were made?

Number of Help Lines - In the section just below the HelpLines, see the
following code:

...
HelpMsgLineNum := ord(HelpML); { Standard message for a Help window }
SetHelpLines (WorkWndwHW,HLw1,HLwL);
SetHelpLines (TopMenuHW ,HLt1,HLtL);
SetHelpLines (MainMenuHW,HLm1,HLmL);
...

The call to SetHelpLines is a trivial procedure listed earlier in the code
that simply sets the first and last line number into the help window record
by using HelpLineNames. Notice that the first and last line names end with
1 and L respectively. This makes it handy so these statements never need
to be altered when new lines are added or inserted.

Help Window Names - The window name is MainMenuHW which in listed the
enumerated type HelpWndwNames at the beginning of PULLSTAT.PAS:

HelpWndwNames = (NoHW,WorkWndwHW,TopMenuHW,MainMenuHW,SubMenuHW,
DataWndwHW);

Help Window Record - A help window record is assigned to each one of these
names. In the SecondMenu record, we can find the window record name by
examining the following:

...
MsgLineNum := ord(MainML);
HelpWndwNum := ord(MainMenuHW);
SaveMainMenu;
...

So now we can finally see how this help window was assigned to the main
menu. Rather than having a standardized help window for each main menu as
a whole, you can even create new ones just as new message lines were
created:


Chapter 3, Programming Menus Page 22
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



1. Append HelpWndwNames.
2. Append HelpLineNames.
3. Make HelpLine assignments.
4. Use SetHelpLines to identify the first and last help lines.
5. Assign the HelpWndwNum to the menu record.

Help Message - Even the help window needs a help message. One has already
been standardized for you called HelpML. InitPull will initialize all help
windows to be assigned the message number in HelpMsgLineNum.

Window Width - All help windows have a standard width which is set by a
configuration constant in P55-VAR.INC called HelpCharsPerLine currently set
at 50. The program adds 2 to this value to leave a space between the left
and right borders. The value can only be changed with the source code.

No Help Window - If there are selected records where a help window is not
wanted, just set:

HelpWndwNum := NoHW;

Integrated Help Windows - This system will integrate the help windows into
the EXE file. With enumerated names, up to 255 lines can be included. If
you need more, it is suggested that you develop a disk-based help system
which is currently beyond the scope of the this utility.


DEFAULT ATTRIBUTES

This section will show the variables used to create default attributes for
menus, windows and messages.


InitPull - At the very first of the procedure GetUserPullStats, several
default attribute variables can be given assignments. For instance,
MainMenuWattr will be used by InitPull to give all main menus the same
window attribute for Wattr in the menu record. This saves you from having
to make the same assignment to every menu record.

Attributes - As a personal preference, many users prefer the screen to have
different attribute when possible. The following is the list of default
attributes and what they affect:

Record
Default variable Variable Description
---------------- --------- ------------------------------------------
TopLineMenuAttr n/a Full length of the top line menu.
TopLineMenuHattr n/a Top line menu HiLite.
TopLineMenuLattr n/a Top line menu command Letter.

MainMenuWattr Wattr Main menu Window.
MainMenuBattr Battr Main menu Border.
MainMenuHattr Hattr Main menu HiLite.
MainMenuLattr Lattr Main menu command Letter.
MainMenuCattr Cattr Main menu Comment line.


Chapter 3, Programming Menus Page 23
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



SubMenuWattr Wattr Sub menu Window.
SubMenuBattr Battr Sub menu Border.
SubMenuHattr Hattr Sub menu HiLite.
SubMenuLattr Lattr Sub menu command Letter.
SubMenuCattr Cattr Sub menu Comment line.

HelpWndwWattr Wattr Help Window Window.
HelpWndwBattr Battr Help Window Border.

MsgLineAttr n/a Message line full length.
ErrMsgAttr n/a Error messages.
KeyStatusAttr n/a Key status of NumLock, Caps, and ScrollLock.

Find the variable MainMenuBattr and modify it to inverse video:

MainMenuBattr := LightGrayBG;

When you run the program, you will find that every main menu has this new
attribute. All the other variables work similarly.

Mono vs. Color - You probably noticed an "if" statement in the code testing
the current video mode. The results of this test allows you to configure
the menus for either Monochrome or color monitors. Refer to your technical
reference manual for the effects of one attribute on either monitor.


DEFAULT BORDERS

This section will show the variables used to create default border styles
for the menus and windows just like the attributes mentioned above.


Border Styles - The following is a list of default border style variables
and what they affect:

Record
Default variable Variable Description
---------------- --------- -----------------
MainMenuBrdr Border All main menus.
SubMenuBrdr Border All submenus.
HelpWndwBrdr Border All help windows.

The shell program has assigned MainMenuBrdr to a custom border UserBrdr1.
Let's modify this to SingleBrdr:

MainMenuBrdr := SingleBrdr;

In addition, you can optionally comment out the assignment of UserBrdr1 in
the previous line since it is no longer needed. When the program is run,
all main menus will now have a single-line border style including the
partitions.


CONTROL FLAGS


Chapter 3, Programming Menus Page 24
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



The pull-down menus can be programmably controlled in your program by
toggling various pull-down control flags. This helps direct the users to
the needed menus automatically instead of manually pressing a key sequence.
In this section, you will discover these flags and what they control. Save
the shell program now for later use and get back to PULLDEMO for this
section.

Control Variables - Here is the list of variables that control the menus:

PopToWorkWndw - (Type: boolean) if true, all menus are removed and
control is returned to the work window.
PopToTop - (Type: boolean) if true, control is set to the Top Line
menu.
PopLevels - (Type: byte) number of levels (or menus) to pop.
Popped - (function) pops all menus before execution of ExecPtr.
MoreCmdSeq - (Type: string) series of command letters to do after
popping.
PullDown - (Type: boolean) if true, the menus will be pulled down
according to MoreCmdSeq.

Examples - Run PULLDEMO and access Alt-I/Update. In the Update menu, there
are six examples of how the menus can be controlled in combination with
executing a ProcPtr. Execute each of those six lines to see what they do.
In PULLSTAT.PAS, search for "GetSubMenu (UpdateMenu)" and see that each
line is executing ProcPtr in the menu, so let's find out what those
procedures are doing.

Process Then Pop - Back up until you find the ProcessThenPop procedure.
Very simply, the program first executed DummyProc and then set
PopToWorkWndw true. When the flow of execution passes back through the key
dispatcher, PULL will immediately pop all menus and return to the top work
window.

Pop Then Process - But suppose we want to do the reverse. Anytime ProcPtr
is used for execution, a copy of it is kept in the global variable ExecPtr.
By using Popped, the function sets the appropriate flags to pop the menus.
The first time Popped is tested, it is false. So, DummyProc is not
executed. Once the menus are popped back to the work window, PULL executes
ProcPtr again via ExecPtr. This time Popped will be true and DummyProc
will be executed.

Pop, Process, and Pull - Let's go one step further and pull the same menus
back down that were popped. Looking few lines down further in the
PopProcessAndPull procedure, the new line that was added is setting
PullDown to true. But how does the program know what menus to pull? PULL
keeps a copy of the last command sequence in the string MoreCmdSeq. When
PullDown is true, the menus are pulled down by MoreCmdSeq. This is useful
when there is something under the menus that needs to be changed like
accessing another work window.

Popping Levels - Or, if you just want to back up a number of menu levels,
just specify the number of levels to pop with PopLevels. In the procedure
PopNumOfLevels, rather than making the menu completely disappear only to
needlessly pull them back down again, this procedure pops back as far as it


Chapter 3, Programming Menus Page 25
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


needs to go and then additionally pulls down another submenu (or data
window). This sequence is useful when you know exactly where you are and
where you are going.

Popping to New Menus - If you need to go to a new menu, you can use the
flag PopToTop which will pop the menus up to the Top Line. By setting
PullDown true and MoreCmdSeq to the desired menu, you can get to the new
destination like the procedure PopToNewMenu.

Smart Pop and Pull - But suppose the menus will execute the same ProcPtr
from three different locations in the menus, and still want it to appear
smart like PopNumOfLevels does? PULL has a procedure called SetCmdSeq that
compares the current location, CmdSeq, with your destination. It sets
MoreCmdSeq and PopLevels to the shortest path. In fact, PopNumOfLevels
could have looked like:

procedure PopNumOfLevels;
begin
PullDown := true;
SetCmdSeq ('IY');
end;

The parameter for SetCmdSeq is the full sequence of command letters to be
pressed from the Top Line.

Sequential Data Windows - One application of these control flags may be
sequential entry for data windows. Access Alt-I/Date and press RETURN a
few times to see how the menus are cycled in a loop for the date. To see
how it was done, follow the ProcPtrs in the DateMenu and see what flags
were set.


SUMMARY

At this point in the tutorial, you've been able to master the configuration
of the top line, main, and sub menus with all the menu modes and most of
the line modes. In addition, you found how to add menus and submenus
and assign help messages and help windows. You changed the appearance of
the menus with attributes and borders. You could even programmably control
the sequence of menus that were pulled down. These were all accomplished
by just filling out the appropriate variables.
















Chapter 3, Programming Menus Page 26
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


4. S C R E E N D E S I G N

You are now at a point where you understand most of the fundamental
features in PULL. In this section, you will discover how to control the
arrangement of the major components of full screen design. You will be
able to relocate the Status line, Top Line menu, Main menus, Work
window(s), and Message line. Arrangement of the components will depend on
the human factors needed for your application.


STATUS LINE

The Status line is a row that you can reserve for pertinent information.
In the shell program, the status line is assumed to be row 1 where a
program name, title, and copyright were placed. In the TP5 environment,
row 2 is the status line for line, column, and insert status. Actually,
PULL does nothing to program this line, but PULL was designed to work
around it.


TOP LINE MENU

Showing the Top Line - The top line menu is automatically created by
assembling the titles from each main menu. So, the string is already
created for you in the string variable TopLineStr. To write this string to
the screen, simply call ShowTopLine. But where is it placed?

Top Line Placement - Back in GetPullUserStat, search for the variable
TopLineRow. It is found in a section called Top Line Defaults. This is
the variable that determines where the top line is placed:

TopLineRow := 2; { Top Line menu to appear on row 2. }

Let's try reversing the Status line and the Top line menu in the shell
program. Set TopLineRow to 1 and then look in PULLSHEL.PAS and modify the
row of the Status line to 2:

WWrite ( 2, 1,'PULLSHELL v5.5 Multi-level Pu'+
'll-down Menus Copr 1989 J H LeMay');

Now run the program and see both lines reversed, but when the main menus
are pulled, they are still on row 3. How can they be moved?


MAIN MENU ROW

Main Menu Row - The row on which the main menus appear is controlled by
the value of MainMenuRow. The Main menus do not have to be attached to Top
Line menu and can appear on any row provided they do not interfere with
the Message line.

Moving the Row - Let's shift the Main menus back up so they will appear
to be attached to the Top Line menu. In PULLSTAT.PAS, search for:

MainMenuRow := 3; { First row of main menus to appear on row 3 }


Chapter 4, Screen Design Page 27
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



and change it to 2. Run the program again to see that the main menus pull-
down now on row 2. But also check the submenu by pressing Alt-M. Even the
submenu is correctly placed! InitPull accommodates the changes.


SUBMENU ROW

SubMenu Row - Try to arrange the lines in your menus that link submenus so
that they are as high in the menu as practical. Otherwise, long menus will
bottom out on the CRT and PULL will be sliding up the menus to keep them in
view. PULL handles this well by using the slide-up configuration, but the
menus will not appear to have much foresight in your design. The
Alt-A/Tires/Brands menu is a good example of keeping menus high.



WORK WINDOWS

Window Modes - The major portion of the screen is intended to be the work
window for your application. This area can have one or more windows and
they can be in any window mode that you chose - even virtual. Usually one
of the modes can be PermMode since there is no data to save under the
screen, but with a TSR, you may need to save the screen, too.

Window Size - The example in the shell program uses a 22x80 PermMode window
with border. Let's get rid of the Status line, make the window larger, and
at the same time, take off the double border. In PULLSHEL.PAS, comment out
the Status line with braces and modify the MakeWindow statement to the
following:

{ WWrite ( 1, 1,'PULLSHELL v5.5 Multi-level Pu'+
'll-down Menus Copr 1989 J H LeMay'); }
ShowTopLine;
SetWindowModes (PermMode);
MakeWindow (2,1,CRTrows-2,CRTcols,White+BlueBG,White+BlueBG,NoBrdr,
Window1);

Running the program, you will see the work window took up all but the Top
Line menu in Row 1 and the Message line on the last row. Notice also that
the contents of the window also moved because they have window-relative
coordinates. This shows you the flexibility of your screen design.


MESSAGE LINE

Message Line - This is the line on which all messages will appear and is
usually in reference to CRTrows to accommodate different video modes. If
the message line is intended to list key commands, for human factor
reasons, it is best to keep it near the bottom row.

Location - The location of the line is set by the variable MsgLineRow in
GetUserPullStats. To whatever line it is assigned, be sure that there is
no possibility that it may be covered by other windows. You may need to
set the window margins to do this.



Chapter 4, Screen Design Page 28
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



HELP WINDOWS

There are two defaults that can be set for the Help windows - the bottom
row and the window modes. This section shows how these can be modified.

Bottom Row - All help windows are centered column-wise on the CRT.
However, the default bottom row of the window is assigned to HelpBottomRow
and is allowed to grow upward. This variable is used to calculate the
upper left corner of the window and sets the Row and Col for each help
window record.

Window Modes - The current example program uses a shadow with zoom effect
when the help window appears. The cursor mode is also turned off. This
default is assigned to HelpWndwModes which in turn assigns it to HWmodes in
each help window record.

Example - In the shell program, search for HelpWndwModes and modify the
code to the following:

...
HelpWndwModes := CursorOffMode;
HelpBottomRow := CRTrows-10;
...

When you test any help window this time, the window will appear instantly
without the zoom effect and is placed higher from the bottom.


START-UP MENU

Control Variables - When the program first starts, you can also have the
program pull down any menu using the Top Line variables MPulled, PullDown,
and MoreCmdSeq. Search again for TopMenuRow and see this code:

TopMenuRow := 1;
MPulled := ord(FirstMenu);
MoreCmdSeq := 'F';
PullDown := false;

MPulled - This is initial assignment for the main menu title that would be
highlighted when pressing F10 for the first time.

MoreCmdSeq - This is the actual variable that is set by the global key
routine SetCmdSeq. When F2 is pressed for the first time, it would emulate
pressing F10 and "F" from the keyboard as if it remembered the last
sequence of keystrokes. MoreCmdSeq can have as many characters as needed
to get down to the desired menu or window. It is a good practice to make
sure the first character matches the MPulled menu.

PullDown - If this is true, the program will pull-down the menus just as if
F2 had been pressed so that the menus pulled match the sequence in
MoreCmdSeq. Try setting PullDown to true and see if FirstMenu is indeed
pulled.



Chapter 4, Screen Design Page 29
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5




OVERRIDING DEFAULTS

PULL configures almost everything automatically, but sometimes things don't
always fit the mold. This section will show you how to override the
settings before and after PULL has configured them.


GetUserPullStats - Row/Col locations for submenus are located by default at
run time with the slide-up configuration when these values remain zero, and
likewise DWrow/DWcol for data windows for slide-under. You can override
PULL and locate them absolutely by giving them non-zero values in the
procedure GetUserPullStats.

Submenu Location - If submenus are unusually wide and will not fit in the
slide-up configuration, PULL will terminate the program with a warning
message to let you know of the problem. If you set the variable
LocationWarning false in GetUserPullStats, you can go ahead and test all
submenus to see the one not fitting the slide-up configuration. PULL will
attempt slide-under as a second best. If it still doesn't fit, then you
need an override for the Row and Col setting. If you are satisfied with
the menu locations, you can optionally set LocationWarning false. But be
sure to check all the menus on the CRT to make sure they have been properly
placed.

GetOverrideStats - This procedure in PULLSTAT is executed after all the
automatic configuration has been done. If there are exceptions in your
program, you can assign them inside this procedure. For just a few
changes, you can edit the records right in the heap. Take a look at this
procedure in PULLSTAT for PULLDEMO. What kind of things would you
typically change?

Menu Command Letters - Not all menus use the first letter for the command
letter. What happens when two lines start with the same one? Only the
first one will ever be reached. So, the command letters must be changed.
The variable in the menu record that contains these letter is CmdLtrs. For
instance, the command letters for FirstMenu are 'ABCD' where character one
corresponds to line 1, etc. They are always upper case in this string, but
can be lower case in the menu. So, you can edit this string to whatever
your command letters need to be. In addition, that letter will also be
highlighted in the menu. Inaccessible line modes like Comment and
Partition replace the command letter with #00.

Top Line Command Letters - You can also do the same with the Top Line
command letters which are kept in a global variable called TopCmdLtrs.

Attributes and Borders - Sometimes the default attributes and borders need
to be changed in a place or two. GetOverrideStats is the place to make
those changes.


SUMMARY

If you have completed the tutorial with the shell program up to this point,
you should now have enough confidence with the major components of screen


Chapter 4, Screen Design Page 30
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


design. You can now develop a concept for your application that can best
be suited the needs of your users. If you would like to stop now, save the
shell program so that it can to be used later in the following sections.






















































Chapter 4, Screen Design Page 31
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


5. D A T A W I N D O W S

Often when a menu line is selected from a menu, a means is needed to enter
data into the application such as numbers or file names. PULL already has
powerful utilities to do this for free-field data entry including flex
fields, set checking, key translation, and range checking for nine types of
data.


DATA WINDOW PARTS

There are two parts to a data entry window - the data entry field and the
window.

Data Entry Field - As the name implies, this is the place where characters
are allowed to be entered for the data. This is also called entry or field
for short.

Data Window - The window is the border and spacing surrounding the field.
Using the term data window loosely refers to both the field and the window
together.


DATA WINDOW RECORD

The arrangement of the records for data windows is very similar to the way
menu records have been done. So, the same concept of fill-in-the-blank is
used. In this section, you will find how these records can be filled out
in the program.


Top Data Window - Let's find the data window record and see what it
contains:

1. Load the file PULLDATA.PAS into the TP editor.
2. Set PULLSHEL.PAS to be the Primary file.
3. Search for "with TopDataWndw"
4. See the following code:

GetDataWndw (ord(aByteDW)); { Just gets cleared DataWndw }
VarAddr := @aByte;
{ TypeOfData := Bytes; } { This is the default }
Field := 3;
{ MsgLineNum := ord(DW_ML); } { This is the default }
{ HelpWndwNum := ord(DataWndwHW); } { This is the default }
SaveDataWndw; { Saves it in the heap }

In the tutorial program of PULLSHEL.PAS, the program does not have any data
windows linked to the menus yet, but this record has already been written
to speed things along. As you can see, only four lines were needed to be
set in the Data Window record which is named aByteDW. Let's go ahead and
link this record into one of the menus.

Linking Data Windows - Go back to PULLSTAT.PAS to find the FirstMenu record
and revise it to add this data window to line 3:


Chapter 5, Data Windows Page 32
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



GetMainMenu (FirstMenu);
...
Line[1] := 'A line';
Line[2] := 'B line';
Line[3] := 'Enter Byte'; LineMode[3] := ToDataWndw;
LinkNum [3] := ord(aByteDW);
Line[4] := 'D line';
...

When the program is run, pressing RETURN on line 3 will pull-down the data
entry window. The variable is a byte type which it was assigned by default
in the data window record. Go ahead and experiment with the entry by
making mistakes such as a number over 255. When you get an error message,
just press ESC. For the full list of editing keys, press F1 for the help
window.

Window Location - Notice that the location of the window is immediately
underneath the HiLite and shifted slightly to the right. This is called a
slide-under configuration. Since there is only one row in a Data Window,
they tend to grow horizontally. Should the window be too long for the
right side of the screen, the window would then slide under the HiLite to
the left until it fit. This location is determined at run time.

Justification - The entry is always left justified since it is an input-
only window.

Line Mode - If you remember about line modes, we did not get a chance to
test ToDataWndw. So, now you can see that this instructs PULL that a Data
Window is linked to the menu and it then uses the named data window record
for the window.

Link Number - The number of the Data Window record linked is of course the
value of the name aByteDW. Again, names are used to easily arrange and
identify the contents of the record. So, how is the name assigned?

Data Window Names - At the top of the file PULLSTAT.PAS (not PULLDATA.PAS),
the enumerated type DataWndwNames has the following list:

DataWndwNames = (NoDW,aByteDW);

Only one window name has been assigned and that is the one being tested.
There are no reserved names except NoDW since the window numbers are 1-
based. Notice that PULLDATA uses PULLSTAT. Since DataWndwNames is in the
interface, the names can also be used in PULLDATA. Ok, the data is plugged
into the window, but where is it being stored?


DATA WINDOW VARIABLE

Variable Address - To know where the variable is located, the record uses a
pointer to the variable location. The variable used in this window is
aByte which is a typed constant declared at the beginning of PULLDATA.PAS
and given a value of 100. To get the address of the variable, you just
place the "@" operator in front of the variable and it returns its FAR


Chapter 5, Data Windows Page 33
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


address.

Type of Data - Because a pointer is being used instead of the variable
itself, it is not known how many bytes the variable uses in memory and
neither is the type of data. So, PULL must be instructed what type of data
is being accessed. PULL can handle nine types of data which is enumerated
in P55-VAR.INC:

TypeOfDataType = (Bytes,Words,ShortInts,Integers,LongInts,Reals,UserNums,
Chars,Strings);

The associated data types should be intuitive. A special case is UserNums
which are really strings, but are meant to be displayed as numbers like hex
for example. Remembering that all zero values in the record are the
default, now you can see why TypeOfData defaulted to Bytes when nothing was
assigned - good ol' fill-in-the-blank again.

Matching the Type - Pascal has strong type checking and it can spoil you
easily. This arrangement of splitting the variable into a type and a
pointer is most convenient for the Data Window. However, it is up to your
skills as a programmer to ensure that the type truly matches the data at
that destination as PULL both reads and writes to it.

Validity Check - All numeric types are given a validity check by using the
Val procedure. If the data entry can successfully be converted to the
specified numeric type and without overflow, the data is considered valid.
If not, the error message "Invalid entry." is displayed. For now, here is
a hint about error messages. You can see the string for this message
earlier in the file:

ErrMsgLine[ord(InvalidEM)]:=' Invalid entry. ESC-acknowledge';


FIELDS

This section gives instructions on how to adjust the field sizes for the
data entry window.

Field - Let's see how easy it to add a new data window on our own for
strings and adjust the field sizes. Right after the aByteDW record, add
the following new record:

GetDataWndw (ord(MyStringDW));
VarAddr := @MyString;
TypeOfData := Strings;
Field := 25;
SaveDataWndw;

At the top of the file, declare the constant MyString:

...
aByte2: byte = 200;
MyString: string[25] = 'This is my string.';

Now let's link it into line 4 of the FirstMenu. So, in PULLSTAT, modify


Chapter 5, Data Windows Page 34
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


the FirstMenu record to:

GetMainMenu (FirstMenu);
...
Line[1] := 'A line';
Line[2] := 'B line';
Line[3] := 'Enter Byte'; LineMode[3] := ToDataWndw;
LinkNum [3] := ord(aByteDW);
Line[4] := 'My string'; LineMode[4] := ToDataWndw;
LinkNum [4] := ord(MyStringDW);
...

And let's not forget to add MyStringDW to the DataWndwNames type:

DataWndwNames = (NoDW,aByteDW,MyStringDW);

Run the program and test the data window. Since Field was set to 25, the
window was expanded to allow a 25 character entry with a space on either
side. So, whatever the field width is, that is how many characters can be
entered in the string. Notice that we were careful not to make Field
larger than the string size so it would not overwrite too many characters
at MyString's address. But what if the string can have up to 100
characters? How can that be made to fit?

Maximum Field - There are actually two variables to adjust the size of the
entry field, one is Field and the other is MaxField. Rather than
explaining it, let's see what it can do. First change the constant to:

MyString: string[100] = 'This is my string.';

and then add the variable setting of MaxField in the Data Window record:

...
Field := 25;
MaxField := pred(sizeof(MyString)); { = 100 }
SaveDataWndw;

Now when you run it, the field is flexible. You can now enter up to 100
characters even though the field only displays 25. These fields are called
flex fields.

Default Field - By default, program sets MaxField equal to Field. Anytime
MaxField has been set and is not the equal to Field, the flex field becomes
active. So, this can be used with any type of data and not just strings.


TITLES

If your field is wide enough, you can easily add a title. Try adding the
following code to the MyStringDW record:

GetDataWndw (ord(MyStringDW));
Title := 'Enter File Name';
VarAddr := @MyString;
...


Chapter 5, Data Windows Page 35
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



Pulling down this data window, the title will be centered on the top row of
the window. Titles are optional and will be truncated if necessary to fit
within the window.


EDITING KEYS

If you didn't get a chance to try out the full editing keys, here's the
list and their function:

Keys Movement
---------------------------- -----------------------------------------
Left Arrow / ^S Character Left/Right
Right Arrow / ^D Character Left/Right
Home / Ctrl Left Arrow / ^A First character
End / Ctrl Right Arrow / ^F Last character
Del / ^G Deletes character under cursor
Backspace / ^H Deletes character to left of cursor
Ins / ^V Toggles between insert and overwrite mode
^R/^U Restores original contents
^Y Deletes entire contents

Insert Toggle - PULL allows you to use both insert and overwrite mode. You
can tell the status by the shape of the cursor. The half-block cursor
indicates the insert mode which appears correctly in any video mode.

Cursor Handling - In flex fields, some special cursor handling has also
been included that you will appreciate when the cursor is at either end.
When adding characters to the far right there is always one space open
until the maximum character is reached. It helps identify the last
character and shows the character when the Del key is used. The same
principle is used when backspacing - at least one character is always shown
until the last one is deleted. The cursor always remains confined inside
the Field width on a flex field.

One-Column Field - A special case is considered when Field is 1 column in
width. The cursor does not move and any valid character typed in will
overwrite the contents. Del or Backspace also deletes the contents.
Please do not consider using flex fields for this case.

AutoNumLock - On machines with enhanced keyboards, it may be an advantage
to automatically turn on the NumLock when in Edit mode. If so, by setting
AutoNumLock true, numeric key pad will be have the NumLock turned on when
you start editing. After the edit, PULL will restore it to its original
mode, on or off. Please note that even though the "NUM" message appears on
the message line to show the true internal status of NumLock, many machines
do not have a smart enough BIOS to also toggle the NumLock LED on the
keyboard itself. Pressing the key can put it back in sync, but the "NUM"
message is the thing to watch.


KEY SETS

This section gives instructions on how to use TP's powerful sets to screen


Chapter 5, Data Windows Page 36
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


for valid keystrokes into the data entry.


Entry Sets - As a preventative measure, each keystroke is checked against a
set to see if it is valid before it is allowed into the field. If it is
not, the keystroke is simply ignored. Several set have included and a
default is given to each of the nine types of data:

SetNames = (NoSet,UnsignedSet,SignedSet,RealSet,CharSet,
HexSet,FileNameSet,PathSet,MaskSet);

where the following types are given the following sets:

Type Set
--------- -----------
Bytes UnsignedSet
Words UnsignedSet
ShortInts SignedSet
Integer SignedSet
LongInts SignedSet
Reals RealSet
UserNums CharSet
Chars CharSet
Strings CharSet

Four more practical sets have also been included for your use. To examine
the contents of the sets, they are located in P55-VAR.INC in an array
called EntrySet. Since it is in the include file for PULL, these can only
be modified when you have the complete source code.

Assigning Sets - Most of your work can be done by default, but once in a
while, a custom set will be required. Let's change MyString to be a file
name with only valid DOS characters by changing the MyStringDW record to:


...
Field := 25;
MaxField := pred(sizeof(MyString)); { = 100 }
SetName := FileNameSet;
SaveDataWndw;

Try entering a string into the window and find that invalid characters like
the space, "\", and "*" can not be entered. This gives the user immediate
cues about the validity of the entry before it is completely entered.


KEY TRANSLATION

As each key is entered, it is possible to intercept the keystroke before it
reaches the data entry editor. This section will show how it is done.


Translation Pointer - Each data window record has a translation pointer
called TranslateProc. You probably know by now, that the default is nil.
If a valid FAR procedure is assigned to this pointer, it will be executed.
Suppose you prefer to have the file name entries in upper case. Modify


Chapter 5, Data Windows Page 37
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


MyStringDW to:

...
Field := 25;
MaxField := pred(sizeof(MyString)); { = 100 }
SetName := FileNameSet;
TranslateProc := @TranslateCase;
SaveDataWndw;

Back up a few lines to find this procedure and you will see:

procedure TranslateCase;
begin
if not ExtKey then
Key := upcase(Key); { Simple upper case translation }
end;

In PULL, Key is the character returned from ReadKey, and ExtKey is true if
it is an extended key. Notice that $F+ and $F- are used to force the
procedure to FAR. Run the program again and find that all keys typed in
this data window are forced to upper case.

Every Key - All keys can be translated with this procedure. Even global
or editing keys can be intercepted and translated to whatever is desired.
It is also useful for foreign language translation.


RANGE CHECKING

After the entry is entered and checked as valid, there is one more option
of checking the entry to make sure it is in the range or form that is
acceptable to the program. This section will show how to create range
checking procedures and out of range error messages.


Three Parts - Before setting up a range check, you need to understand how
the data is transferred between the entry and the variable. There are
three parts to performing the data entry transfer - the data entry string,
data pad, and destination variable.

Data Entry String - The data entry string is the string that is seen and
edited on the CRT. This string is held in DataStr of type DataStrType and
is declared in P55-VAR.INC.

Reading - The data pad, called DataPad, is a two-way messenger that
transfers data between the variable and DataStr. When the data window is
initially displayed, the data pad reads the contents of the variable and
makes an exact copy of the value onto itself. Then the program converts
this value over to DataStr into a string form which the user can easily
read and edit.

Storing - As mentioned before, pressing RETURN after editing is completed,
the program attempts to store the entry to the variable. First, numeric
data must pass a validity check by converting DataStr to a value. If it
passes, a copy of the converted data is now on the data pad. Now is the


Chapter 5, Data Windows Page 38
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


time to do a data range check. By default, there is no check and the data
would continue to be stored from the data pad to the destination variable
as is. But to do the range check, you need to know the identifiers that
are used on the data pad.

Data Pad Identifiers - The data pad is completely generic. Any type of
data occupies the exact same address. So all you need to do is select the
right identifier to match the type of data for your variable. You can look
at the data pad record in P55-VAR.INC for the field list, but here is a
list of those identifiers:

Type Identifier
--------- ----------
Bytes Bdata
Words Wdata
ShortInts SIdata
Integers Idata
LongInts Ldata
Reals Rdata
UserNums UNdata
Chars Cdata
Strings Sdata

Example - Let's set up a range check for aByteDW. Modify its data window
record to:

GetDataWndw (ord(aByteDW)); { Just gets cleared DataWndw }
...
Field := 3;
CheckRangeProc := @CheckAbyte; { add this line. }
SaveDataWndw; { Saves it in the heap }

Arbitrarily, let the range for aByte be between 20 and 50 inclusive. Now
back up a few lines before the TranslateCase procedure and the following
procedure has already been added for you:

procedure CheckAbyte;
begin
with DataPad do
if ((Bdata<20) or (Bdata>50)) then
MakeErrMsg (20,50);
end;

Since aByte is byte type, Bdata is used for the comparison. For the range
check, any values under 20 or over 50 will run the MakeErrMsg procedure.
Try it and see if you can produce the error message.

Error Messages - How does PULL know if an error is found? It tests the
value of ErrMsg in DataPad. If the value remains zero, then the range
check is passed. Otherwise, it has failed. And, it uses this same value
as the error message name. The ErrMsgLines are much like the MsgLines
using names for indexes. Right after the implementation you can see the
error message names:

ErrMsgNames = (NoEM,UserEM,InvalidEM,MyEM);


Chapter 5, Data Windows Page 39
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



The names up to InvalidEM are reserved. The name UserEM is of most
interest. ErrMsgLine[ord(UserEM)] is meant to be customized by creating a
message at run-time. This saves you from making several hard-coded
messages. The example used MakeErrMsg, located a few lines back. It is a
good simple example how to set both ErrMsg and create a custom message on
the UserEM. But the important value is the change of ErrMsg.

Message Length - Error messages tend to be short, so there is no need to
allocate a full screen width for the message. The maximum length of a
message is set by MaxErrStrLength in P55-VAR.INC. The program will
automatically clear the remaining part of the line and takes special care
not to do a needless full-line clear and thereby preventing a flicker
effect.

Maximum Message - Similarly, the maximum number of ErrMsgLines is set by
NumOfErrMsgLines in P55-VAR.INC.

Summary - The outcome of the range check is determined by the value of
DataPad.ErrMsg. PULL sets it to zero. Compare your range with the DataPad
identifiers in any fashion. Only if it is out of range, set ErrMsg to the
ErrMsgLine you want to show.


HELP MESSAGES

A help message can be assigned to the Data Window record exactly the same
as the menus. One name has already been reserved for the Data Window
called DW_ML and is the default. But you can also assign new ones. The
MsgLines and names are in PULLSTAT.PAS.


HELP WINDOWS

Again, just like the menus, help windows can be assigned to the Data
Window. The record name reserved for Data Window records is called
DataWndwHW and is the default. If you have not seen this window, run the
program with a Data Window pulled and press F1. The Help Window records
and Help Lines are in PULLSTAT.PAS.


DEFAULT ATTRIBUTES AND BORDER

This section will show the variables used to create default attributes and
border for the Data Window.


Initialization - PULLDATA is self-initialized when it is included in the
USES list. There are two procedures that set up the colors and border:

SetDefaultColors - assigns colors and border to the default variables.
InitDataColors - assigns the defaults to the Data Window record.

SetDefaultColors - In PULLDATA, search for SetDefaultColors and see the
following code:


Chapter 5, Data Windows Page 40
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



DataWndwIattr := Black+BrownBG;
DataWndwOattr := Yellow+BlackBG;
DataWndwBattr := Black+BrownBG;
DataWndwBrdr := HdoubleBrdr;

InitDataColors - These variables in turn are assigned to the following
record variables in DataWndw:

Record
Default variable Variable Description
---------------- --------- ----------------------------
DataWndwIattr Iattr Attribute for Input
DataWndwOattr Oattr Attribute for Output
DataWndwBattr Battr Attribute of the Border
DataWndwBrdr Border Border of the window

Just like the menus, this saves you from having to make the same assignment
to every menu record. Try experimenting with the colors and border in the
shell program and see the results. Although NoBrdr is permissible, it is
not suggested.


DEFAULT LOCATION

The location of a data window is placed by PULL at run time. With the
slide-under configuration, the menu is placed underneath the HiLite and
shifted to the right 2 columns. If necessary, it is shifted to the left to
prevent wraparound. To alter this position manually, set Row and Col in
the menu record to your desired location.


SUMMARY

In addition to mastering the menus, you can now link data windows into the
menus by adding and linking data window records in PULLDATA.PAS. You have
been able to address the entry variable and create a window suitable for
the data type including the field type and size, title, key set and
translation, range checking, error and help messages, and help windows.
With this environment in your application along with the power and speed of
QWIK and WNDW, your programs can match and even better professional
programs.















Chapter 5, Data Windows Page 41
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


6. D A T A E N T R Y

Data Windows in the pull-down menus are not the only place where data is
needed to be entered. The work windows themselves may need several data
entry fields as well. PULL simply uses a subset of Data Windows to handle
the job very easily. In addition, a smart HiLite automatically knows the
location of each field in the window.


DATA ENTRY vs. DATA WINDOW

Data Windows have both a data entry field and a window surrounding it. In
work windows, all that is needed is the data entry field. So, to
distinguish between data entry in the pull-down menus and the work windows,
the Data Windows are only in the menus, while Data Entry will be considered
in this document to be in the work windows.


DATA ENTRY RECORD

One Data Entry field has already been included in the work window. Let's
take a look at its record. In PULLDATA, find GetDataEntryStats and search
for "with TopEntry" to see the following code:

GetDataEntry (ord(aIntegerDE));
VarAddr := @aInteger;
TypeOfData := Integers;
Row := 2;
Col := 11;
Field := 4;
MaxField := 3;
CheckRangeProc := @VerifyAinteger;
{ MsgLineNum := ord(DE_ML); } { This is the default }
{ HelpWndwNum := ord(DataWndwHW); } { This is the default }
SaveDataEntry;

The record identifiers should look quite familiar because they are the same
ones use in a Data Window record. The only differences are the Get and
Save procedures, because the record is of type DataEntryRec rather than
DataWndwRec. If you examine these type declarations in P55-VAR.INC, you
will find there is a DataEntryRec inside of DataWndwRec. So, Data Entry is
truly a subset of Data Windows.

Variable - The variable is aInteger which is a constant declared early in
the file and is of type Integers.

Row/Col - This time, a row and column is specified where the left column of
the field is to appear in the work window. These coordinates are window
relative.

Default Helps - Both the help message and help window are set to a default
so your program can be up and running without being concerned about
details. Being in a different part of the pull-down menu environment, the
DE_ML is different from DW_ML because the function of F2 is the opposite to
either case.


Chapter 6, Data Entry Page 42
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



Other Variables - All the other variables in the record should be familiar
to you from the explanations in the previous section on Data Windows. So,
there is no need to repeat them here.



ADDING ENTRIES

Entry Record - We have already seen how to add entries with the fill-in-
the-blank concept, so let's try adding another entry to the work window.
Just after the aInteger record, add the following code:

GetDataEntry (ord(aRealDE));
VarAddr := @aReal;
TypeOfData := Reals;
Row := 3;
Col := 11;
Field := 12;
Decimals := 2;
SaveDataEntry;

Decimal - This variable is just for reals to format the number of decimals
for the output display. If the value is negative, then no decimal is used.

aReal - Be sure to set up a default value for aReal. At the beginning of
PULLDATA, add the constant aReal:

...
aInteger: integer = 200;
aReal: real = 4.56e7;

aRealDE - Now append the data entry record name to the DataEntryNames list
at the beginning of the file:

DataEntryNames = (NoDE,aIntegerDE,aRealDE);

Now run the code and see if it appears in the Work Window. When it runs,
the field does not appear. Why?


DISPLAYING FIELDS

Work Window - The Work Window controls what is to appear inside the window
and this code is in the file PULLWORK.PAS. Note that PULLWORK uses
PULLDATA. Take a look at it and search for "case WorkWndwStep" and see:

...
WWrite (2,2,'Integer:');
DisplayFields (ord(aIntegerDE),ord(aIntegerDE));
WorkWndwStep := 1;
...

DisplayFields - This is the code that displayed the Integer field. The
DisplayFields procedure displays a sequence of fields in order of the list
of DataEntryNames. It is declared in the interface of PULL as:


Chapter 6, Data Entry Page 43
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



procedure DisplayFields (First,Last: word);

So, what it does is display each field starting with the record First and
ending with Last. Looking back in PULLWORK again, it displayed records
both beginning and ending with aIntegerDE. So, it never reached aRealDE.
Let's modify the parameter to include aRealDE as follows:

DisplayFields (ord(aIntegerDE),ord(aRealDE));

Field Label - Running it, the aRealDE will be displayed this time. But it
doesn't have a label, so add one to the window with:

...
WWrite (2,2,'Integer:');
WWrite (3,2,'Real:');
DisplayFields (ord(aIntegerDE),ord(aRealDE));
...

Justification - aReal now appears on the screen with the field right
justified. By default, numbers are justified to the right and strings to
the left. To alter this, just include your setting in the Data Entry
record. Let's try left justifying aReal by adding the following code in
PULLDATA:

GetDataEntry (ord(aRealDE));
...
Decimals := 2;
JustifyOutput := Left; { Add this line. }
SaveDataEntry;

Everything appears correctly on the screen. But when we try to move the
HiLite, it just stays on the Integer field. How can we make it select the
other field? Real easy - keep reading.


SEQUENTIAL ENTRY

With sequential entries of several fields, PULL gives you the advantage of
using not just one movement with the HiLite, but both relative and
sequential movement.


EnterSeq - PULL makes sequential entry as natural as can be. In PULLWORK,
search for EnterSeq and see:

EnterSeq (ord(aIntegerDE),ord(aIntegerDE),Start1);

This procedure is also in the interface of PULL.PAS and is declared as:

procedure EnterSeq (First,Last: word; VAR Start: word);

EnterSeq allows you to enter a whole block of entries in the DataEntry
array of records where First and Last are the first and last records in the
block. The aRealDE was not included in this block. So let's modify the


Chapter 6, Data Entry Page 44
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


code to:

EnterSeq (ord(aIntegerDE),ord(aRealDE),Start1);

Now run the code and find that the highlight can now move freely between
the two fields. That all there is to do! PULL handles the rest, now.

Start - Start is the record where the highlight is to begin. At the bottom
of the file, Start1 is initialized to aIntegerDE. Or, Start1 could be made
into a typed constant with a default value. This lets EnterSeq remember
where the HiLite is after using the menus.

Smart HiLite Algorithms - Take a break from PULLSHEL and go back to
PULLDEMO. Run the program and take a look at the work window with several
entries. PULL has smart algorithms that know where all the fields are
located on the screen. The HiLite can be moved freely to select any field
with the following keys:

Keys Movement Type of Movement
----------------------- ------------------------- ----------------
Left/Right Arrow Left/Right Relative
Up/Down Arrow Up/Down nearest cursor Relative
Home / Ctrl Left Arrow First one on the row Relative
End / Ctrl Right Arrow Last one on the row Relative
PgUp / Ctrl Home First in sequence Sequential
PgDn / Ctrl End Last in sequence Sequential
Tab / Shift Tab Next/Previous in sequence Sequential

Relative Movement - PULL checks the block of entries to see where to move
the HiLite relative to the current field. If the field is already at its
limit, say to the far left with the left arrow key, it does not wrap around
to the far right. When the HiLite is moved up or down, PULL looks for the
field nearest the cursor, not the full width of the field, and also does
not wrap.

Sequential Movement - Primarily, the Tab key is used for sequential
movement. If you reach the end of the sequence, the next Tab will wrap
back to the first. What determines sequential movement? It's the order of
the DataEntryNames. So, changing the sequence is as simple as reorganizing
the names - no interlinks between fields are necessary! Now you can insert
a new field without fretting over links.

Auto Tab - The value of sequential entry is the order in which you want to
enter fields. After entering one field, the program should be smart enough
to go the next one. With AutoTab set true, PULL will jump to the next
field in sequence automatically after each entry. Let's try it again on
the PULLDEMO program.

1. Get into the work window.
2. Press PgUp to get to the "Byte" entry field.
3. Enter any value in range and press RETURN.
4. See that the HiLite is now on "Integer".

To prove the point of relative and sequential movement, let's move one of
the fields to a different location. In PULLDATA, search for the data entry


Chapter 6, Data Entry Page 45
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


record for aChar2DE, and change the location to:

GetDataEntry (ord(aChar2DE));
VarAddr := @aChar2;
TypeOfData := Chars;
Row := 5; { Change the row (was 15) }
Col := 5; { Change the column (was 55) }
...

Run PULLDEMO and see the field moved to (5,5). Moving the up arrow as far
as it will go, the HiLite will end up on aChar2DE. But when you press Tab,
the next field is String. Now, suppose we want aChar2DE to be first in
sequence. How easy is it? Look for DataEntryNames at the top of the file
and see:

DataEntryNames = (
NoDE,aByte2DE,aWord2DE,aShortInt2DE,aInteger2DE,aLongInt2DE,aReal2DE,
aHex2DE,aChar2DE,aString2DE,FileNameDE);

There is a bunch of names here, but all we are interested in is moving
aChar2DE. Move the name to be right after NoDE. But now we have changed
the beginning name of the block from aByte2DE to aChar2DE. So, go into
PULLWORK and do a global search and replace of aByte2DE with aChar2DE.
Three familiar lines will be changed. Run the program now and see that
PgUp will now move the HiLite to the top and a subsequent tab will move it
to Byte. This makes organizing your screen very easy.

Setting AutoTab - In PULLDATA, search for AutoTab which is right at the
beginning of the Data Entry records. The current value is true. If this
value is set false, then the HiLite would stay in the same field after
entry.


EDIT MODE

When the HiLite moves from field to field, it is in Select Mode. But when
your are editing a field, it is in Edit Mode. What exactly makes it change
from Select to Edit mode?


Overwrite vs. Edit - To overwrite the contents, just start typing the new
entry. To edit the contents, the suggested key to use is the Return key.
When pressed, the HiLite changes color and the cursor is set past the last
character.

Non-Extended Keys - In addition to the Return key, any non-extended key
will work as well and will also apply that key to the field. For example,
while in select mode, if ^A is pressed, the HiLite would change into Edit
mode and, in addition, the cursor would be moved to the first character.

Invalid Characters - If the key pressed is not a member of the entry key
set, it acts the same as return on the first key, but is otherwise ignored.

Escape - To escape Edit mode and restore the original contents, just press
ESC and the HiLite will return to Select Mode. If ESC is pressed again,


Chapter 6, Data Entry Page 46
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


the program would escape the entire sequence of entry and would return
control to the WorkWindow procedure.


FIELD ATTRIBUTES

There are three attributes that can be modified for the Data Entry fields -
the display, the edit, and the HiLite attributes.


Default Attributes - Data Entry fields have default attributes for each
record just like the Data Windows. These variables are also set in
SetDefaultColors and InitDataColors.

SetDefaultColors - In PULLDATA, search for SetDefaultColors and see the
following code:

DataEntryIattr := Yellow+MagentaBG;
DataEntryOattr := Black+LightGrayBG;

InitDataColors - These variables in turn are assigned to the following
record variables in DataEntry:

Record
Default variable Variable Description
---------------- --------- --------------------
DataEntryIattr Iattr Attribute for Input
DataEntryOattr Oattr Attribute for Output

HiLite Bar - The HiLite attribute is set by the color on the data pad
called DataPad.Hattr. This variable is right next to AutoTab in PULLDATA.
Rather than having both the cursor and the HiLite, the HiLite can be turned
off by assigning Hattr the value of SameAttr. Then each field will appear
in its own display attribute.


SINGLE ENTRY

If you prefer to customize your own procedures, you can use the procedure
Enter in lieu of EnterSeq. The procedure is declared in PULL as:

procedure Enter (RecNum: word);

This accesses the same powerful editing features as EnterSeq, but only
works on the one field indicated in the parameter. It does not display the
fields before or after editing which must be done with DisplayFields.


SUMMARY

You have just covered enough features to master data entry in the work
windows or user windows. You can enter the records, display and locate the
fields, control the sequence of entry, and adjust the appearance with the
justification and attributes. You also learned how to direct PULL's built
in HiLite bar for field selection.


Chapter 6, Data Entry Page 47
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


7. W O R K W I N D O W S

The bulk of your application needs to be displayed somewhere, and the Work
Windows are used for this purpose. In this section, you will discover how
to integrate your work window procedures in a pull-down menu environment so
the program can randomly access any procedure. In addition, you can create
a sophisticated multi-level window environment.


MAKING STEPS

In this section, you will find how to break down procedures into individual
steps and still allow the flow of execution to cycle through the Key
dispatcher.


Requirements - When procedures are broken down into steps, your procedures
can do most anything. But each step must exit with two settings:

1. Assignment made for the next WorkWndwStep.
2. Assignment made for Key and ExtKey.

Example - Let's do an example to understand the flow of execution. Get the
original files for PULLDEMO.PAS - PULLWORK and PULLDATA. Now take a look
at the last of PULLWORK and see:

procedure WorkWndw;
begin
...
case WorkWndwStep of
0: ShowFields;
1: EditFields;
end;
end;

With this construct, your work can be separated into different steps. To
add a new step, just insert one. To demonstrate how to create a new step,
let's separate the left and right columns of the data entry fields into two
separate steps. So, let's add step 2:

...
0: ShowFields;
1: EditFields;
2: EditFields2;
end;

and change EditFields to:

procedure EditFields;
begin
DisplayFields (ord(FileNameDE),ord(FileNameDE));
EnterSeq (ord(aByte2DE),ord(aReal2DE),Start1); { Change this line. }
if Key=EscKey then { Add this line. }
WorkWndwStep := 2; { Add this line. }
end;


Chapter 7, Work Windows Page 48
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



This will isolate the sequence to the left column of fields. And now add
EditFields2:

procedure EditFields2;
begin
DisplayFields (ord(FileNameDE),ord(FileNameDE));
EnterSeq (ord(aHex2DE),ord(FileNameDE),Start2);
if Key=EscKey then
WorkWndwStep := 1;
end;

Start2 has already been added for you. Set the TP primary file to be
PULLDEMO.PAS. Now try the program and see that you can only access the
left or right sequence of fields. If you want to swap between the left and
right columns, just press ESC.

Flow of Execution - ESC has been assigned inside EnterSeq as the key that
is used to exit the procedure. This is called a gated exit. Once it
exits, it also exits WorkWndw and goes back into PULL to analyze the
keystroke in a key dispatcher. If no key combinations are used to access
the menus, execution will return right back to WorkWndw and into the right
step. You can catch the execution flow, by testing for the Esc key right
after EnterSeq. If so, then change the step as we did in the example.

Menu Access - Why even bother to test the key if ESC exits EnterSeq? The
Esc key is not the only key that would exit this procedure. Any menu key
like F10 will also exit the same way. So, the "if" statement is needed to
confirm the correct key before changing the step.

Updating the Window - Did you notice that DisplayFields was used twice for
just one field? Any time you exit a menu and re-enter the window, there is
a possibility that something may need to be updated. And this time the
File name field is a possibility because it was linked to the output of the
file directory. If you haven't had a chance, press Alt-D to get the
directory and pick a file by pressing RETURN. The selected file name will
appear in the File name field. The other link is that the file name data
entry field also preselects the initial file name when the directory is
pulled again. But there are other alternatives than using DisplayFields
twice.

Changing Steps - This example was quite simple. When step 1 was complete,
WorkWndwStep was incremented to step 2. When step 2 was done, it was
cycled back to step 1. It continues to stay in this loop until the program
is terminated, or until some other procedure changes the step number. In
step 0, if we had failed to assign a new step at the end of the step, the
program would have been locked in an infinite loop, because it never
accesses any keyboard input.


READING THE KEYBOARD

In some steps, the program may need keyboard input while others do not. In
this section you will find out how to read the keyboard within each step.



Chapter 7, Work Windows Page 49
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


Output-Only Step - Step 0 in the example, is an output-only step that
displays the fields in the window. No keyboard input was required. So, at
the end of the step, we needed to emulate a keystroke of some kind to meet
the Step requirements. By setting Key to NullKey (#00), the key dispatcher
and will bypass a call to the menus and ignore the key. This guarantees
that the flow of execution will return to back WorkWndw. ExtKey should
also be set properly if a valid combination is needed. Some keys do not
require it such as NullKey, EscKey, and RetKey. See your reference book
for more details.

Input and Output Step - Most steps will require both input and output.
Step 1 called EnterSeq which has a keyboard reading routine built in. So,
no keystroke emulation is needed. However, the last line in the step still
needs to check for a change of step.

Custom Input - There will be several occasions where you will want to have
your own procedures that read the key board. If you have the source code,
look at PULLDENT.INC for the construct of EnterSeq which looks like:

repeat
...
CheckForPullDown (ord(SeqML));
...
CheckForPop;
until (Key=EscKey) or Pop or PullDown;

CheckForPullDown is a procedure available to you to read the key board.
Its parameter, MsgLineNum, will show this message while the program pauses
for entry. A subroutine in CheckForPullDown is ReadKbd which can be used
instead. It just reads the keyboard and does not show a message.

CheckForPop - This procedure is also available to you to check if any menu
control flags have been set and regulates them. If the flags indicate a
pop it needed, then Pop will be set true.

Gated Exit - Now you can see two more possible reasons that would cause the
program to exit EnterSeq - Pop and PullDown. These are the very same flags
used for controlling the menus. By gating the exit, the flow of execution
is confined with the repeat/until construct until a control flag permits
the exit. Using these two flags allow EnterSeq to be used in either the
Work Window or a User Window in the menus. If the procedure is only going
to be used in the Work Window, then Pop is not necessary.

Non-Gated Exit - The step doesn't have to be gated at all. You can use
CheckForPullDown by itself if the flow of execution can continue through
the dispatcher every time a key is pressed. For EnterSeq, this would not
work, because the HiLite would flash with each keystroke. The next section
shows an example where a non-gated Exit works perfectly fine.

Idle Keyboard - Rather than just letting the program just sit there and
wait for keyboard input, you could be letting the program do other
background processing. An indirect call from PULL inside ReadKbd
continually runs the contents of the FAR procedure KbdIdle while no key is
pressed. Although KbdIdle is seen here in PULLWORK, it can be placed in
any file, but it MUST be included somewhere, even if the procedure is


Chapter 7, Work Windows Page 50
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


empty. The variable AddKbdIdle declares its address.


MULTI-LEVEL WINDOWS

One work window may not be enough for your application and others may be
needed. The following example shows how to add a simple hidden Work
Window.

Making the Step - Add step 3 to WorkWindow:

...
2: EditFields2;
3: EditWorkWndw2; { Add this line. }
end;

Now, create this editing step to just put ASCII keys into the window. A
non-gated procedure will work fine:

procedure EditWorkWndw2;
begin
CheckForPullDown (ord(WorkML));
if not ExtKey then
case Key of
#32..#126: write (Key);
RetKey: writeln;
EscKey: HideWorkWndw;
end;
end; { Non-gated exit }


The key chosen to hide the window is ESC although any key could be assigned
to do this. But we also need to initialize the second work window to be
available to the program. So, add the following line to InitWorkWndws:

procedure InitWorkWndws;
begin
ShowFields;
MakeWorkWndw2; { Add this line. }
...
end;

and then code the procedure to make a hidden window and place it just after
the ShowFields procedure. (The code is already there. Just remove the
braces for this example.)

procedure MakeWorkWndw2;
begin
SetWindowModes (HiddenMode);
MakeWindow ( 8,21,10,40,LightBlue+LightGrayBG,LightBlue+LightGrayBG,
DoubleBrdr,Window2);
SetWindowModes (0);
WriteToHidden (Window2);
TitleWindow (Top,Left ,SameAttr,'2');
TitleWindow (Top,Center,SameAttr,' Press ESC to hide ');


Chapter 7, Work Windows Page 51
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


TitleWindow (Top,Center,SameAttr,' Work Window 2 ');
WWriteC (1,'Type in any input');
WGotoRC (2,1);
WriteToCRT;
end;

At the beginning of the file, let's also activate the multi-level work
window code by placing the "$" code in front of the word "define" to look
like:

{$define MultiWorkWndws }

This activates the AccessWorkWndw procedure which simply accesses the
selected window set by TopWorkWndwName. When TopWorkWndwName has changed,
WorkWndwStep also needs to be reset. In the procedure ResetWorkWndwStep,
confirm that Window2 starts on the correct step:

Window2: WorkWndwStep := 3;

Now we need some keys to get access to these windows. Let Window1 and
Window2 be assigned to the Alt-1 and Alt-2 keys. To do this, go back to
PULLSTAT.PAS and edit CheckGlobalKeys to the following:

...
AltX: SetQuit;
Alt1: SetWorkWndw (Window1);
Alt2: SetWorkWndw (Window2);
else
...

The constants for Alt1 and Alt2 have already been set for you. SetWorkWndw
is located just before CheckGlobalKeys and looks like:

procedure SetWorkWndw (WN: WindowNames);
begin
PullDown := false;
PopToWorkWndw := true;
TopWorkWndwName := WN;
end;

This assigns a new Work Window name for the AccessWorkWndw procedure. Now
it is all set. Give the program a run. You will see that anytime you
press Alt-1 or Alt-2, it immediately accesses that window even if you are
in the menus! And, when you get Window2, the contents are preserved. If
you were able to program this successfully, you have attained a highly
sophisticated environment with little code.


MANAGING WINDOWS

We have just covered all the code necessary to have several work windows on
the screen at once. To randomly access any window, the Alt keys were
assigned to a particular window number. To hide a window, the Esc key was
used and the contents were saved.



Chapter 7, Work Windows Page 52
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


Should you decide to use temporary windows so that ESC would remove the
window, just replace the two occurrences of HideWindow with RemoveWindow.
Of course, you could make a combination of both. You now have the tools
for complete window management.





















































Chapter 7, Work Windows Page 53
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


8. U S E R W I N D O W S

While in the menus, you may have to create a window or a menu that differs
from the ones in PULL. This section will show you the pull-down directory
included with the package and how to integrate any user window into the
pull-down environment.


PULL-DOWN DIRECTORY

The pull-down directory unit has already been linked into the demo. By
now, you can probably figure out how the directory is accessed. Looking in
the FilesMenu, find the following code:

Line[3]:='Directory'; LineMode[3]:=ToUserWndw;
ProcPtr [3]:=@DoDir;

To pull down a user window, the line mode is set to ToUserWndw which places
a 3-bar symbol on that line. Then, DoDir is the procedure that will access
the directory and looks like:

procedure DoDir;
begin
{ Use (FileName,FileName) to initially Hilite a close match. }
{ Use (FileName,'') to start at default. }
PullDirectory (FileName,FileName);
end;

PullDirectory handles every thing once inside the procedure. A particular
emphasis was made on end-user human factors in its development.

. Single column - A single column, alphabetically sorted list is the
easiest to visually scan quickly. Multi-column lists such as the one
provided in the TP5 environment require difficult zig-zag scanning.

. Cursor key scanning - Cursor keys are the expected way to scan through
the directory. In addition, Home, ^Home, End, and ^End keys only move
the HiLite while PgUp, ^PgUp, PgDn, and ^PgDn move only the page.

. Letter key scanning - Any alpha-numeric key will scan for the first
file name starting with the same first letter. The page is moved and
the cursor is centered as much as possible.

. Lower-case text - Lower case text is more legible than the standard
upper-case text provided by DOS.

. Right justified extension - Visual searches for extensions are easier
to read when aligned. In addition, this also facilitates proper
alphabetic sorting.

. High speed sort - The sorting routine uses is a secondary-index quick
sort which is the fastest kind for this application. It is currently
set at a limit of 250 file names are permitted, but it can be set to
grow as much as your heap allows.



Chapter 8, User Windows Page 54
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


. High speed scroll - The display is expected to be fast when scrolling
and is. Neither the HiLite nor the screen ever flicker.

. Default HiLite - If a value file name is passed to the directory for
the default other than '', the directory searches for a close match to
HiLite. In either case, the HiLite is centered as much as possible.

. Picked file name - Pressing CR will replace the referenced file name
passed to the directory.


INTERFACE

If you have the source code to PULLDIR.PAS, take a look at PullDirectory
and see how the code interfaces the pull-down menus. This is an excellent
example of incorporating all the features to integrate with the menus:

procedure PullDirectory; { (VAR NameToChange: FileNameStr;
NameToHiLite: FileNameStr); }
begin
TurnArrows (On); { 1 }
with TopMenu do
CmdSeq := CmdSeq+CmdLtrs[HiLiteLine]; { 2 }
ShowDirMenu (NameToHiLite); { 3 }
repeat
with DirectoryMenu do
begin
CheckForPullDown (DirectoryMenu.MsgLineNum); { 4 }
if ExtKey then
begin
if HelpKeyPressed then
{$ifdef UseHelpWndwCode }
PullHelpWndw (HelpWndwNum) { 5 }
{$endif UseHelpWndwCode }
else ScanDirByCursor;
end
else
if Key<>RetKey then
ScanDirByLetter;
if (Key=RetKey) and (TotalFiles>0) then
begin
PopToWorkWndw := true; { 6 }
{ ... }
end;
CheckForPop { 7 }
end; { with }
until (Key=EscKey) or (Key=RetKey) or Pop; { 8 }
Key := NullKey; { 9 }
RemoveWindow; { 10 }
dec (CmdSeq[0]); { 11 }
TurnArrows (Off); { 12 }
end;

Comments - Comments for the numbered lines follow.



Chapter 8, User Windows Page 55
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


Line 1 - TurnArrows is a procedure that places arrow symbols on
the top menu to direct the user's attention to the new
menu.
Line 2 - Append CmdSeq so that PULL can know how it got to this
menu.
Line 3 - This procedure actually produces the window on the CRT
and it custom designed.
Line 4 - CheckForPullDown monitors keyboard entry and displays a
message.
Line 5 - You can include your custom help window here.
Line 6 - Once the item was selected on the menu, this option
commands PULL to return to the top work window. This is
optional.
Line 7 - CheckForPop analyzes all the menu controls flags,
including PopToWorkWndw, to see if a request has been
made to pop out of the menu. If so, Pop is set to true.
Line 8 - The repeat/until construct provides a gated exit.
Line 9 - Alter the value of Key so the next menu will ignore an
EscKey value. ESC is meant to pop only one menu. If the
key was not changed, the menus would continue to pop
until is was back into the work window.
Line 10 - The exit has been confirmed and the window/menu needs to
be removed from the CRT.
Line 11 - Adjust CmdSeq for one pop.
Line 12 - Turn the arrows back off of the top menu.

This same construct can be used for any user window/menu to be included
with the pull-down menus.





























Chapter 8, User Windows Page 56
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


9. C O N D I T I O N A L C O M P I L A T I O N

Many times your application may not need to use all of the features built
into PULL. Although most of the code is optimized out by the compiler,
some of the code is nested and it would be helpful to eliminate some of
that code. This section will show you how easy it is to do this.


DEFINE SYMBOLS

Here is a complete list of the define symbols used in PULL:

UseSubMenuCode - to include submenus.
UseHelpWndwCode - to include help windows.
UseDataEntryCode - to include data entry or data windows.
UseMsgLineCode - to include normal and error messages.
MultiWorkWndws - to include multi-level work windows.

Location - You can find these directives defined on the first page of all
*.PAS files. Most files will not have every one of them, but only the ones
that affect it.

Definition - When you see the define directive, it will look like:

{$define UseSubMenuCode }

With the "$" in its place, UseSubMenuCode would be defined and would
include all of the submenu code. If you do not want the code, then
undefine it by just removing the "$":

{ define UseSubMenuCode }

Affected Files - Should you decide to undefine a symbol, you should
undefine it in ALL affected files including PULL. You can get away without
changing PULL on all of them except UseMsgLineCode where you must change it
in PULL as well.


RECOMPILING

Once you have changed all the needed directives, do a Make and the code
will be ready for use.















Chapter 9, Conditional Compilation Page 57
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


10. T R O U B L E S H O O T I N G

PULL is a well thought out unit. If you find that the program has not done
what you expected, there may be something that you overlooked. This
section will try to help jog your memory as to what the problems may be.


GOOF UNIT

All programmers make mistakes, right? So, what happens when you try to
make more windows than there are records available? Since WNDW and PULL
are powerful tools and can even write in RAM, there is a good possibility
that your mistake may not even show up on the screen. How do you know if
anything has gone wrong? The GOOF unit was made especially for handling
errors.

Displaying Errors - When an error is found in your program, the ShowGoof
procedure is called and the program is terminated. The CRT will display an
error message in a flashing window. There are eight fatal errors that are
listed in APPENDIX B in WNDWREF.DOC to identify problems before they
happen. Please refer to it for the error messages and their solutions. If
you do not have a copy of WNDW55.ARC, you can get one direct from the
Eagle.

Flexibility - ShowGoof is accessed indirectly with an indirect call. This
means that you can freely edit the GOOF unit without needing to recompile
WNDW or PULL. You can even edit it for use in your own applications. The
error message numbers 1-50 are reserved. So, for your own applications, it
is suggested that you start with number 51. If you have thoroughly tested
your program, some of the messages can be eliminated.

Using GOOF - It is very important that GOOF be included in the USES list.
You may find that it compiles without it, but if an error does occur, your
system will surely crash. Notice that GOOF is the last unit in the USES
list in the main program.


FAR ADDRESSES

Because PULL uses several pointers for procedures and variables, it is
quite possible to lock up your computer if these are not properly
addressed. A debugger is most helpful in these circumstances. But if you
do not have one, here is a check list of possible causes:


Forcing FAR - The far pointers used by TranslateProc, CheckRangeProc, and
ProcPtr must be calling FAR procedures. All procedures that are not
declared in the interface of a unit must be forced to FAR with the
directive {$F+} when called by a pointer.

Indirect Calls - PULL has several inline calls for indirect FAR calls
outside of the calling unit. The addresses for these units must be
assigned in the destination unit with an Addr* variable and is usually done
in the BEGIN/END for initialization. Here is a list of those procedures
and calling address variables:


Chapter 10, Trouble Shooting Page 58
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5



Procedure Address Variable Unit
---------------- -------------------- --------
GetUserPullStats AddrGetUserPullStats PullStat
GetOverrideStats AddrGetOverrideStats PullStat
WorkWndw AddrWorkWndw PullWork
CheckGlobalKeys AddrCheckGlobalKeys PullStat
ShowGoof AddrGoof Goof
KbdIdle AddrKbdIdle Any

Using Units - Because of indirect calls, the compiler does not know that
some units need to be linked. PullStat, PullWork, and Goof are three units
that MUST be in the USES list of the main program.

KbdIdle - The far procedure KbdIdle must be used and can be located in any
unit. This procedure does background processing while the keyboard is
idle.

Data - The variable address and type of data in each data record must
exactly match or risk possible data loss. Strings lengths must not be
longer than MaxField.


MULTI-TASKING

This demo has already been set to work in multi-tasking environments
compatible to DESQview, TopView, and IBM 3270 PC Workstation. It uses the
multi-tasking video buffer (MTVB) whenever possible. To always disable
MTVB use, set PreferMultiTask to false in PULLSHEL.PAS.

CUSTOMER SERVICE

If you are still having problems, leave us a message or give us a call.
























Chapter 10, Trouble Shooting Page 59
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


A P P E N D I X A : O T H E R P R O D U C T S


Eagle Performance Software has developed identical products for both Turbo
C and Turbo Pascal. Our pledge is to provide you quality products with
unparalleled performance and ease of use.


QWIK

QWIK - For direct screen video, QWIK is the highest performance screen
writing tools available today for all text modes in any video
configuration. QWIK provides capabilities far beyond in the unit/library
that comes with your compiler. Here are some of the features:

. Writes on all IBM compatible computers, displays and adapters
including MDA, CGA, EGA, MCGA, VGA, 8514/A, Hercules and 3270
PC.
. Superior video detection routine.
. Eliminates snow and flicker.
. Writes directly to the screen in absolute rather than relative
coordinates.
. Writes in all text modes and column modes.
. Writes on all video pages.
. Writes on virtual screens in RAM.
. Writes text and attribute, text only, or attribute only.
. Reads strings, characters and attributes.
. Uses End-Of-String (EOS) marker for quick string chaining.
. Provides standardized cursor shapes for all adapters.
. Enhanced cursor movement.
. Compatible with DESQview and similar multitasking environments.
. Over 650% faster than standard direct screen writing.
. Only 2.7k bytes of code if all 43 utilities are used.
. Writes direct to multi-tasking video buffers (MTVB).
. Optimized by the compiler and drops unused code.
. Used in all other Eagle products.

Here are the product versions:

File name CIS name Compiler Release date
----------- ---------- -------- ------------
QWIK55.ARC QWIK55.ARC TP4-5.5 08-24-89
QWIKC21.ARC QWKC21.ARC TC2 07-06-89


WNDW

WNDW - For multi-level virtual windows, WNDW is the highest performance
window utilities available today. It offers very powerful utilities for
full window control and management you probably never thought possible.
They are simple and yet very powerful with high speed and tight code. With
WNDW, you can choose the absolute writing routines of QWIK, the window-
relative writing routines of WNDW, and even customize your own. Here are
some of the features you will discover:



Appendix A: Other Products Page 60
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


. Uses the powerful direct screen writing routines of QWIK.
. Up to 254 fixed or virtual windows can be on the screen at one time.
. Extremely high-speed virtual screens in RAM (up to 40 times faster).
. Virtual windows are fully updated on screen, even if covered!
. Virtual windows have virtual titles.
. Fully supported hidden windows saved in RAM.
. Fully supports all video pages.
. Adjustable-rate moving, resizing, and scrolling.
. All windows can be randomly accessed, not just stacked or tiled.
. 28 window-relative writing routines.
. 15 different border styles with shadow and zoom effects.
. Full line drawing procedures.
. Full cursor mode control for each window.
. Writes in all text modes and column modes.
. Writes direct to multi-tasking video buffers (MTVB).
. Only 13k bytes of code if all 69 utilities are used.
. Used in all other Eagle products.

Here are the product versions:

File name CIS name Compiler Release date
----------- ---------- -------- ------------
WNDW55.ARC WNDW55.ARC TP4-5.5 08-24-89
WNDWC21.ARC WNDC21.ARC TC2 08-01-89


PULL

Here are the product versions:

File name CIS name Compiler Release date
----------- ---------- -------- ------------
PULL55.ARC PULL55.ARC TP4-5.5 08-24-89
PULLC21.ARC PULC21.ARC TC2 08-01-89


ON-LINE SERVICES

CompuServe - All updated files and later versions can be found on the
CompuServe Borland Forums (GO BPROGA for TP and GO BPROGB for TC) or the
IBM Programming Forum (GO IBMPRO).



RELEASE DATES

Please note that the release dates are only estimates.











Appendix A: Other Products Page 61
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


A P P E N D I X B : R E V I S I O N H I S T O R Y

REVISIONS:

Version 2.0 (01-12-88):
. Converted to TP4 and incorporated QWIK40 and PULL40.
. Added pull-down directory with path and mask.
. Added global keys like Alt-F and Alt-X in PULLSTAT.PAS.
. Eliminated PULLUSER.INC and instead allow access to user
windows direct through PullProc.Process.
. Menu partitions now use Wndw.BrdrRec.
. Added TypeOfDataTypes Word and LongInt.
. Added "ClearScreen" option in InitPull.
. Deleted i and j variables in PULL20.PAS.
. Modified Pull.TempMsg; Deleted TempMsgArray.
. Top menu record is available from TopMenuRecPtr^.

Version 4.2 (01-03-89):
. Incorporated QWIK42 and WNDW42.
. Added excellent documentation.
. Expanded the fill-in-the-blank concept.
. Simplified work window data entry with sequential data entry
routines.
. Changed data windows to the slide-under configuration.
. Added complete editing in data entry fields.
. Added custom set control for data entry and deleted UserStrings.
. Added key translation and range checking pointers.
. Added multi-level window control.
. Deleted PullProc.pas and the Process and Transfer procedures and
replaced them with pointers.
. Added automatic menu and line counting.
. Simplified Menu Modes with execution pointers.
. Changed menu records from global to dynamic data.
. Improved submenu linking following the direction trend of the parent
menu.

Version 5.X (01-07-89):
. Compiled PULL42 under TP5. No other changes.

Version 5.Xa (01-11-89):
. Corrected right-arrow key problem in data entry (P5X-DATA.INC).
. Improved cursor mode handling during dynamic updates.

Version 5.Xb (03-04-89):
. Incorporated QWIK5XA and WNDW5XB for multi-tasking.
. Added new LineModeType of NoChoice for dynamic disabling of any line.

Version 5.Xc (05-29-89):
. Incorporated WNDW5XC. No other changes.

Version 5.5 (08-24-89):
. Compiled PULL5XC under TP 5.5. No other changes.





Appendix B: Revision History Page 62
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


A P P E N D I X C : C R E D I T S

Art Hill started some initial ideas on this with PullDown.arc

Art Hill
936 S. Kensington Ave.
La Grange, IL 60525
CIS 72307,3570

Copyright (c) 1986-1989 by James H. LeMay for Eagle Performance Software.
All Rights Reserved. Protected by the United States Copyright Laws.

Turbo Pascal is a trademark of Borland International.
WordStar is a trademark of MicroPro International.











































Appendix C: Credits Page 63
PULL Multi-level Pull-Down Menus User's Guide, Version 5.5


A P P E N D I X D : G L O S S A R Y

Command letter - A letter highlighted in a menu that executes that line.
Command sequence - The sequence of command letters pressed to arrive at a
window or menu.
Data entry - Field for entering data into the application program in the
work windows or user windows.
Data window - Window for entering data into the application program from
the menus.
Error message - A short message for data out of range.
Field - A highlighted area reserved for a data entry string to be
displayed.
Flex field - A field that allows more characters into the data entry
than what the field displays.
Free field - A field that allows a continuous string of characters to
expand in the field in any position. This is in contrast
to formatted fields where each column is designated an
entry.
Local key - A key that only works within the menu or window.
Gated exit - A procedure that lets the flow of execution pass through
back to PULL's key dispatcher only on specific keystrokes.
Global key - A key that accesses a different part of the program at any
time.
Help message - A message appear on the message line for keyboard
instructions.
Help window - A window displayed by pressing F1 that provides context-
sensitive help.
HiLited - A highlighted bar pointed at in a menu.
Level - A window or menu where the program is operating.
Line - A row of text.
Link - A menu line showing a symbol (three-bar or dot) that pulls
another menu or window. The symbol is also on the same
side where it is pulled.
Main menu - The first menu pulled from the Top Line menu.
Menu - A list of selectable lines.
Message line - The bottom row to display key helps or processing status.
MTVB - Multi-Tasking Video Buffer used in multi-tasking
environments.
Pop - removes menu and returns to the previous menu.
PullDown - pulls menus down to the previous level.
Selection - A line selected in a menu with a CR.
Shell - A bare bones program of pull-down menus to get you started
in your own application.
Slide-under - The configuration of data windows them to slide under the
HiLite if the field grows wider.
Slide-up - The configuration of submenus that allows them to slide
upward as the menu list grows.
Status line - A optional line reserved for status information pertinent
to your program.
Submenu - All subsequent menus pulled after a main menu.
Top Line menu - The menu always shown (usually in row 1 or 2).
Window - Not a menu.
Work window - The window where the bulk of the application is shown.




Appendix D: Glossary Page 64



  3 Responses to “Category : Pascal Source Code
Archive   : PULL55.ZIP
Filename : PULL55.DOC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/