home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 17
/
CD_ASCQ_17_101194.iso
/
vrac
/
ptgenr2.zip
/
PTG_USER.DOC
< prev
next >
Wrap
Text File
|
1994-08-01
|
51KB
|
1,736 lines
C O N T E N T S
───────────────────────────────────────────────────────────────────────────────
Introduction 1 Appendix B Environment variables 29
PtGen features ....................... 1
TVTool .............................. 1
TVToys.............................. 2
What's in this manual ................. 2
Typefaces used in these manuals........ 3
How to contact NederWare ............ 3
Acknowledgements ................... 4
Chapter 1 Getting started 5
File list .............................. 5
Installing PtGen ...................... 5
Environment variables .............. 5
Installing PtGen under Tools menu
of Borland IDE ..................... 6
Installing PtGen under Windows ..... 6
Needed units....................... 6
Accessing Help....................... 6
Demo files ........................... 7
Chapter 2 The PtGen
Development-cycle 9
PtGen development-cycle overview ..... 9
Ptgen single dialog box creating mode... 10
Chapter 3 PtGen basics 11
Mouse operation ..................... 11
Keyboard operation................... 11
Chapter 4 Sample applications 13
Creating a menubar and a statusline .... 13
Creating a dialog box.................. 17
Chapter 5 Turning your code into
an executable 21
An example of a simple main........... 21
A more elaborated main ............... 22
Let PtGen create a main for you ........ 23
Chapter 6 More advanced topics 25
Using string resource files.............. 25
Adding units......................... 25
Using resources ...................... 25
Using TVToys ........................ 26
Appendix A Command-line options 27
i
ii
I N T R O D U C T I O N
───────────────────────────────────────────────────────────────────────────────
PtGen is a tool is intended for Turbo Pascal programmers who
wish to enhance their productivity by rapidly building Turbo
Vision screens. PtGen outputs source code and is capable of
reading that source code for further editing. PtGen comes in a real
mode and in a protected mode version. This manual applies to
both varieties.
PtGen features
───────────────────────────────────────────────────────────────────────────────
PtGen provides you with many things to make TurboVision
programming easier, including
■ Creation of complete applications or just standalone dialog
boxes
■ Quick and interactive menubar building
■ Quick and interactive statusline building
■ Quick and interactive dialog box building
■ Full helptext support for statusline help as well as for helpfiles
(.HLP)
■ Build-in tutorial, covering creating of statuslines, menubars and
dialog boxes
■ Support for TVTool 2.0 (see below section TVTool)
■ Support for TVToys (see below section TVToys)
TVTool
───────────────────────────────────────────────────────────────────────────────
PtGen supports TVTool 2.0. TVTool is a TurboVision tool written
by Richard Hansen who can be reached at:
■ CompuServe: 70242,3367
■ email: 70242.3367@compuserve.com
■ fidonet: 1:282/115
The TV Tool Box package was created to fill a few holes in Turbo
Vision for Turbo Pascal. TV Tool Box includes formatted data
entry with input masks, scrolling data entry dialogs, data entry
field locking, check mark menus, enhancements to TApplication,
Introduction 1
some handy string routines, scrolling dialog boxes, 3D controls,
virtual list boxes, spin bars, sliders and more.
PtGen currently supports all 3D controls of TVTool. PtGen also
supports all TbxEditLine and derivatives (including mask
definition). Planned enhancements include support for a scrollable
dialog box, sliders, and spinbars..
Registered users of PtGen receive a 25% reduction on their TV Tool
Box package, just as registered users of TVTool receive a 25their
PtGen package.
The shareware version of TVTool is shipped with the registered
version of TVTool, just as the shareware version of PtGen is
shipped with every registered version of TVTool.
To receive your 25% registration discount YOU MUST INCLUDE
your PtGen registration number on your TV Tool Box order form.
THE SPECIAL 25% DISCOUNT IS ONLY AVAILABLE ON
ORDERS MADE DIRECTLY TO RICHARD HANSEN.
TVToys
───────────────────────────────────────────────────────────────────────────────
PtGen has basic support for TVToys. Note that TVtool and TVToy
are mutually inconsistent! You can use the one or the other, but not
both.
The advantage of using TVToys is its support for previous help
screens besides much more. See section 6 for how to make use of
TVToys.
What's in this manual
───────────────────────────────────────────────────────────────────────────────
This manual explains how to use PtGen to develop TurboVision
objects. It doesn't tell you how to write TurboVision programs.
■ Chapter 1, ``Getting started'', describes how to install, start, and
exit PtGen and how to access the Help system.
■ Chapter 2, ``The PtGen Development cycle'', introduces to the
way PtGen is meant to be used, or how the author uses it.
■ Chapter 3, ``PtGen basics'', gives an overview how mouse
buttons and function keys are assigned to perform tasks in
PtGen.
■ Chapter 4, ``Sample applications'', covers the creation of a
complete application with menubar, statusline and dialog boxes.
2 PtGen User Guide
■ Chapter 5, ``Creating an executable'', shows you how to write a
main program for PtGen. PtGen's code is always in a unit
(except for stand-alone dialog boxes). You need to include this
unit and to initialize some other units.
■ Chapter 6, ``More advanced topics'', describes some more
elaborated uses of PtGen.
■ Appendix A, ``Command-line options'', shows all
command-line options available with PtGen.
■ Appendix B, ``Environment variables'', describes the two
environment variables for PtGen.
Typefaces used in these manuals
───────────────────────────────────────────────────────────────────────────────
All typefaces used in this manual were produced by L
A
TE X2",
dvips on a HP Laserjet IV. Their uses are as follows:
Monospace type This typeface represents text as it appears on-screen or in a
program. It is also used for anything you must type (such as PTGEN
to start up PtGen).
Boldface This typeface is used in text for command-line options.
Italics Italics indicate identifiers that appear in text. They can represent
terms that you can use as they are, or that you can think up new
names for (your choice, usually). They are also used to emphasize
certain words, such as new terms.
Keycaps This typeface indicates a key on your keyboard. For example,
``Press Esc to exit a menu.''
Key1+Key2 Key combinations produced by holding down one or more keys
simultaneously are represented as Key1+Key2 . For example, you can
edit an object by holding down the Ctrl key and pressing the F8
function key. This key combination is presented as Ctrl+F8.
How to contact NederWare
───────────────────────────────────────────────────────────────────────────────
NederWare offers a variety of services to answer your questions
about PtGen. Of course, this is true for registered users. If you
don't have registered yet, support shareware (and me and my
family) by registering PtGen to day. We made it very easy for you.
You can register by CompuServe, fax, email or telephone, see
REGISTER.FRM for details.
CompuServe
Introduction 3
CompuServe ID 100120,3121 Subscribers to CompuServe can reach NederWare at 100120,3121.
The latest versions of PtGen are available in library 1 of the
BPASCAL forum.
Internet
NederWare can be reached on internet through
Email: berend@beard.nest.nl NederWare@beard.nest.nl or berend@beard.nest.nl. For the latest
PtGen check-out garbo.uwasa.fi.
Fidonet
Fidonet 2:281/527.23 NederWare can be reached on fidonet at 2:281/527.23. The latest
versions of PtGen are also available at 2:281/527, Contrast BBS,
The Netherlands. Its full international telephone number is
+31 70-3234903. From Holland dial 070-3234903.
Acknowledgements
───────────────────────────────────────────────────────────────────────────────
I would like to thank alpha tester Tom Kooij who provided me
with valuable suggestions about the PtGen user interface.
I would also express my thanks to the following people who
contributed much to PtGen's operation: Hans van der Veeke and
David MiddleBrooks. Also I wish to thank betatesters Christian
Haarmeijer and Frank van der Ham who pointed out
inconveniences and detected many errors.
Thanks to Wouter de Boer for creating the PtGen icon, so PtGen
can conveniently be called from your Microsoft Windows desktop
(shrudder...).
4 PtGen User Guide
C H A P T E R
───────────────────────────────────────────────────────────────────────────────
1
Getting started
File list
───────────────────────────────────────────────────────────────────────────────
Before installing PtGen, you should review the contents of the
Read the READ.ME file before READ.ME file on your PtGen distribution diskette. This file
proceeding contains important information (usage information, new features,
changes, known bugs, etc.) that became available after this manual
was printed. You should carefully review the READ.ME file before
using PtGen.
Installing PtGen
───────────────────────────────────────────────────────────────────────────────
PtGen is simple to install. But first make a backup copy of the
distribution diskette.
Create a directory if necessary to hold your copy of PtGen. You
can create any directory you like. Advised directory is C:/PTGEN.
Make sure this directory is in your path because because each
program developed with PtGen needs a seperate directory. You
will call PtGen from the directory of each application.
Next unpack PtGen with the directory option enabled. If PtGen is
packed with arj use arj x to unpack. If PtGen is packed with
pkzip use pkzip -d to unpack.
───────────────────────────────────────────────────────────────────────
Environment
Optionally you can set the environment variable PTGEN in your
variables
AUTOEXEC.BAT. All command-line options of PtGen can be
preset in this environment variable. If you specify
SET PTGEN=-50
PtGen will always start in 80x50 video mode. Specified
command-line options will override the environment variable
settings. See Appendix A for all command-line options.
Chapter 1, Getting started 5
The environment variable PTGINPUT specifies the directory
where PtGen should search for standard files PtGen needs when
you create a new application. For example the standard string
resource files ENGLISH.TVR should reside in this directory. Most
of the time you simply set PTGINPUT to the directory where the
PtGen executable resides.
───────────────────────────────────────────────────────────────────────
Installing PtGen
You can install PtGen also in the Tools section of the Borland IDE.
under Tools
Choose Options |Tools and press New. Specify under Title
menu of Borland ~P~ tGen, under Program path PtGen's directory, for example
c:\ptgen, under Command-line \$EDNAME \$SAVE ALL. As a
IDE
hotkey I suggest Shift+F9 but any other key or no key is alright too
of course.
───────────────────────────────────────────────────────────────────────
Installing PtGen
PtGen runs flawlessly under Windows. But don't use the graphic
under Windows
mouse switch (/GM ). Two pifs are supplied, one for the real and one
for the protected mode version, called PTGEN.PIF and
PTGENX.PIF respectively.
You can also use the PtGen icon PTGEN.ICO or PTGENX.ICO
(both are exactly the same).
───────────────────────────────────────────────────────────────────────
Needed units
Make sure your compiler can find units from
bp/examples/dos/tvdemo and /bp/examples/dos/tvfm. You
need CALCULATORS.PAS, GADGETS.PAS, HELPFILE.PAS,
VIEWTEXT.PAS, and maybe more.
Accessing Help
───────────────────────────────────────────────────────────────────────────────
PtGen offers a variety of online-help:
■ You can follow the online tutorials. Select a tutorial from the
Tutorial menu.
■ You can press F1 to popup help about current situations.
■ You can press Ctrl+F1 to get context-sensitive help about which
actions are currently available to you.
For example when you are creating a dialog box, pressing Ctrl+F1
shows you how to add subviews to a dialog box or how to
move/resize them, etc.
6 PtGen User Guide
Demo files
───────────────────────────────────────────────────────────────────────────────
The subdirectory sample has a sample file, SQLXPLMN.PAS,
which was created with PtGen. You can compile XPL2SQL.PAS to
run the full demo program. But you will also need TVTool for this.
Chapter 1, Getting started 7
8 PtGen User Guide
C H A P T E R
───────────────────────────────────────────────────────────────────────────────
2
The PtGen Development-cycle
PtGen development-cycle overview
───────────────────────────────────────────────────────────────────────────────
This section shows you how to work with PtGen. But first is the
underlying software development cycle discussed. PtGen is a
prototype generator, that means, that you should not expect that
PtGen can create complete applications for you. It will let you
build TurboVision screens very fast and very visually but that's
not the end. For example, when you create a dialog box a dummy
TListViewer is inserted. What you should do is to first to create the
dialog box including all buttons, helptexts, etc., than copy the
dialog box code PtGen has outputted, and past it into your
program. You don't have to copy/past all dialog code though.
Some dialog boxes are complete by themselves. But as soon as you
want a custom view to be inserted you need this copy/past
scheme. An examples of a complete, compilable application can be
found in the chapter titled Creating an Executable and the
accompanying source files DEMOMENU.PAS and
DEMOMAIN.PAS.
The steps followed when using PtGen are:
1. Create a separate directory for each application.
2. Copy PREAPP.PAS to this directory. PREAPP.PAS contains the
application object from which the application object PtGen
creates is derived.
3. Start PtGen in this directoryand build a menubar, a statusline,
dialog boxes and helptexts.
4. Save your work as a PtGen readable Pascal source file. PtGen
readable means that several PtGen directives are inserted in the
source file, but they won't affect compilation.
5. Create the main of your application. You probably want to
override the HandleEvent of the TApplcation object PtGen has
created in its source file. You probably need to copy/paste
some PtGen created code to your source files if you want to
change or add custom views.
Chapter 2, The PtGen Development-cycle 9
6. Compile your program.
This development cycle will become clearer after you have worked
with PtGen and read the chapters Sample Apps and Creating an
Executable.
Ptgen single dialog box creating mode
───────────────────────────────────────────────────────────────────────────────
For people not wanting to create a complete application but just
use PtGen's dialog box creating capabilities there is an option
Dialog |New. You don't have to follow the previous steps and
you can just create a single dialog box. After you close the dialog
box you can save the source code of the create dialog box to a file.
You can read this file with Dialog |Open.
10 PtGen User Guide
C H A P T E R
───────────────────────────────────────────────────────────────────────────────
3
PtGen basics
In the following two sections general principles when working
with PtGen are covered. PtGen is designed to be very consistent.
You will find the same basic set of operations throughout PtGen.
Learn them once, and you know it for ever. First the basics for
mouse users are covered, than for keyboard users.
Mouse operation
───────────────────────────────────────────────────────────────────────────────
PtGen differentiates the left and mouse buttons. Their meanings
are:
Table 3.1
Mouse button assignments Press this button... To accomplish this...
Left button Clicked on backgrounds pop-ups the local
menu
Right button When the mouse is on an object/item, pressing
the right mouse button pops-up a menu with
actions you can apply to that object/item or it
starts editing the current object/item
Keyboard operation
───────────────────────────────────────────────────────────────────────────────
Keyboard users can
OK, enough explanation. Let's create some sample applications
with PtGen.
Chapter 3, PtGen basics 11
Table 3.2
Keyboard assignments Press this key... To accomplish this...
F1 Display context-sensitive help about the
currently selected view.
Ctrl+F1Display context-sensitive help about the actions
you currently can undertake.
Alt+F5 Pop-up local position menu for positioning the
current object
Ctrl+F5 Move/resize the current dialog box or pop-up
menu.
Shift+F5 Move/resize the current subview (inputline,
button, etc.)
Ctrl+F7 Delete current object/item
Ctrl+F8 Edit current object/item
Ctrl+F9 Link other objects to your object
Alt+F10 Pop-up local menu
Ins Insert an item
Del Delete an item (same as Ctrl+F7)
12 PtGen User Guide
C H A P T E R
───────────────────────────────────────────────────────────────────────────────
4
Sample applications
We'll build three different sample applications. The first two are
covered by the build-in tutorial although the written version has
more explanation and references other and advanced features.
The first application lears you to create menus and a statusbar. The
next learns you to create dialog boxes.
Detailed information about the above mentioned
subjects/objects(!) can be found in the reference manual.
For every application:
1. Create a separate directory
2. Copy PREAPP.PAS and PREAPP.INC from your PtGen
directory to this directory. The application object PtGen creates,
is a descendent of the application object defines in this file.
3. Start PtGen from this directory so all files created by PtGen will
be placed in this directory.
Creating a menubar and a statusline
───────────────────────────────────────────────────────────────────────────────
To create a new application, just start up PtGen.
1. Select New from the File menu.
Now you're asked to specify some information about the new
application you're creating.
2. Fill in the application name, in our case SampleApp.
Your application will be saved in a source file you specify and the
name will be: TSampleApp. PtGen automatically adds a T or P to
the name of every object it creates, so don't specify T's or P's.
PtGen supports helptext creating. To enable this option you have
to mark Help in the Options menu and you have to specify a
filename.
Chapter 4, Sample applications 13
3. Enable the Help option
4. Specify as helpfile: sample.txt.
The other options are explained more fully in the reference
manual. We will not use this feature in our sample application.
5. Press Enter or click OK to close this dialog box.
You are now ready to edit your application.
6. Select Edit from the menubar or press Ctrl+F8 to edit your
application.
Next, you'll see an almost empty menubar and an empty
statusline. Let's add the familiar F1 and F10 to the statusline.
7. Popup the local menu by pressing Alt+F10 or, for mouse users,
press the left button.
A popup menu appears.
8. Choose Statusline.
Go to the StatusKeys listviewer by pressing Tab. Now press the
down arrow once (the lightbar should now be on kbF10). And add
your first item.
9. Press Ins or click on New.
A dialog box appears in which you can specify the same
parameters as the NewStatusKey function.
10. Enter after Text:
~F2~ Save
Enter after Keycode
kbF2
Enter after Command
cmSave
11. And press Enter or click OK to close this dialog box.
When you look at the statusline, you'll see that F1 has appeared.
Do the same for F10.
12. Press Ins, enter after Text
~F3~ Open
Enter after Keycode
kbF3
Enter after Command
14 PtGen User Guide
cmOpen
And press Enter to close the dialog box.
And for Alt+X.
13. Press Ins. Leave the Text inputline empty, enter after Keycode
kbAltF3
After Command
cmClose
and press Enter to close the dialog box.
You see that in the Statusline dialog box entries are differentiated
by their keys. If no key is specified (type kbNoKey), the first part
of the text is shown.
To close the statusline dialog box, press Enter again.
14. Press Enter to close the statusline dialog box.
OK, now the menubar.
15. Press F10 (Menu).
You'll see that a lightbar appears on menu =, but when you look at
the statusline, you see that it hasn't changed. But in the IDE of
Turbo Pascal the statusline changed to ``F1 Help |System
commands''.
It isn't there, but soon it will be. We have to add some helptext to
the = menuitem.
16. Press Ctrl+F8 (Edit).
The edit dialog box for a menu item appears. You can add all
options you could when handcoding menu's for Turbo Vision and
more. You can specify a statusline helptext and a normal helptext
which the user accesses by pressing F1.
REMARK A: helptexts for F1 will only be stored in a file when you
had set helpfile on and had specified a helpfile name in the
application edit dialog box, the one you where you specified the
application's name.
REMARK B: Only after TVHC has been run to compile a helpfile
(.HLP) from the saved text, will helpfiles be shown on the screen.
Instead of running TVHC you could also select HelpText from the
Desktop Local menu. Next press the Compile button.
17. Add a helptext by entering
system commands
Chapter 4, Sample applications 15
after help text and press Enter to close the dialog box.
You will now see that the statusline has changed and now shows
the desired text. For more information about the menuitem dialog
box, see the reference manual.
Adding a menuitem is equally simple. We will add a submenu, the
first part the File submenu as found in the Turbo IDE.
18. Move the lightbar on the ysymbol, the end symbol. Now press
Ins to insert a menuitem.
The menuitem dialog box will appear.
19. Enter after Name
~F~ ile
20. Enter after Help text
File management commands (Open, New, Save, etc.)
Leave the other fields empty.
21. Select OK to close this dialog box.
The lightbar automatically moves right so you can quickly enter
more menuitems, but let's first edit the created menu. Because you
didn't specify a command, this will be a submenu.
22. Move the lightbar to File and press Enter.
An empty submenu will appear with only the Endmark symbol
ypresent. You can add more menuitems by pressing Ins.
23. Add a new menuitem by pressing Ins. Enter after Name
~O~ pen...
After Command
cmOpen
After Keycode
kbF3
After Param
F3
We will not use hcConstant in this example, so leave it empty. See
the reference manual for details and meaning of hcConstants.
Generally speaking: hcConstants are used to refer to helptexts
which you will use on more than one place your application. This
saves you typing time and promotes consistency.
24. Enter after Help text
16 PtGen User Guide
Locate and open a file in an Edit window
25. Select the OK button to close the dialog box.
So, that's it for now. You learned how to create statuslines and
menubars.
26. Press Alt+X (Exit) to exit your created application.
You return now to PtGen.
27. Press F10 (Menu) and select Save from the File menu. You will
be prompted for a filename. Enter
Sample
and select OK to save your application.
PtGen will now save your application in Pascal source code
format. It's a advised to look at the code PtGen's created to get a
feeling for what it does. This is not necessary, but I think you will
use PtGen frequently to quickly prototype a screen and than copy
code fragments to your application and edit it further as already
explained. See chapter DEMO for more information.
Creating a dialog box
───────────────────────────────────────────────────────────────────────────────
We'll use the application you created in the previous example. It's
assumed that you are at the Dos prompt.
1. Load Sample into PtGen by typing
ptgen sample
and presssing Enter.
PtGen will now load the code in SAMPLE.PAS.
2. Select Edit from the menubar or press Ctrl+F8 (Edit) to edit your
application.
We will add an about dialog box to this sample application.
3. Press F10 (Menu), position the lightbar on = and press Enter.
Position the lightbar on the About menuitem.
We wish that as we select About from the System menu an about
dialog box pops up. We can do this by linking a dialog box to this
menuitem. Take a look at the About menuitem by pressing Ctrl+F8
(Edit). You see that after Command is specified "cmAbout". Press
Esc to close this dialog box.
Chapter 4, Sample applications 17
We now link a dialog box to this About menuitem, that means:
any time that the cmAbout command is encountered, this dialog
box will pop up. You can link code by pressing Ctrl+F9 (Link).
4. Press Ctrl+F9 (Link). There is no mouse equivalent for this
operation.
A pop-up menu will appear from which you can choose between
Predefined code, or self-defined code. Under the Predefined
option you will for example find a complete calculator. See the
Links chapter in the reference manual for more information about
Links and predefined objects. A dialog box is code you
interactively define.
5. Select Define and then select Dialog box.
First you have to specify some general information about this
dialog box. You can specify its name, its title and its helptext.
More information about the last item can be found in the reference
manual. We will only specify its Name and its Title.
6. Specify its Name as
AboutDlg
And enter after Title
About
and press Enter to close the Define a dialog box dialog box.
Now you see the dialog box with the Title you specified. You can
always edit the dialog box name and the Title by popping up the
local menu and selecting Settings.
At this moment you can resize/move the dialog box just by
pressing Ctrl+F5 (Resize). Mouse users can do it their way (clicking
on the upper frame, or lower-right corner).
A dialog box is an object which can contain other objects. You can
pop-up a local menu with the objects you can place in this dialog
box by pressing Alt+F10 (Local Menu). Mouse users can place the
mouse anywhere on the dialog box and press the Left
mousebutton to popup the local menu. Objects that mouse users
select from the local menu will be placed on the dialog box with
their upperleft corner at the current mouse position.
7. Since we are making an About dialog box, pop-up the local
menu and select Static Text.
You're prompted to specify the text.
8. Enter the following text just as it appears. So enter for ÇC first a
"Ç" than a "C":
18 PtGen User Guide
ÇCTurbo PascalÇMÇMÇCVersion 7.0
and select OK.
The ÇC means center this text, ÇM means go the next line.
You will see the text centered and a blank line between Turbo
Pascal and Version 7.0. If you are a keyboard users, you can move
and resize the text by pressing Shift+F5 (Local Move/Resize). If you
are a mouse user you can do so by placing the mouse on this view
and pressing the right mousebutton, holding it down and selecting
Move or Resize from the popup menu.
9. Press Local Move/Resize (Shift+F5) to spread the whole text
from the left to the right of the dialog box.
If you are a mouse user you can do so placing the mouse on the
StaticText view and pressing the right mouse button. Select first
Move to move the view to the left edge. Then do the same and
select Resize to resize the right edge of the StaticText view to the
right edge of the dialog box.
You will now insert an OK button.
10. If you are a keyboard user: pop-up again the local menu by
pressing Local Menu (Alt+F10), select Button and next select OK.
If you are a mouse user: place your mouse in the middle of the
second half part of the dialog box. Press the left mouse button and
hold it down. The local menu appears: select Button, then select
OK.
The OK buton will appear in the upperleft corner if you used the
keyboard equivalent, or in the place your mouse was before
pressing the left mousebutton.
You can now move or resize the button.
There are some four actions you can do with the objects you place
on a dialog box. Keyboard users have to press the appropriate key
while mouse users can select the actions from the popup menu
which appears if you press the right mousebutton while your
mouse is on an object.
1. Move: press Shift+F5 (Local Move/Resize) if you are a keyboard
users.
2. Resize: press Shift+F5 (Local Move/Resize).
3. Edit: press Ctrl+F8 (Edit). You can edit an object parameters.
For example you can edit the static text view to add or change
some text. All objects can be editted.
4. Delete: press Ctrl+F7 (Delete). Delete the object.
Chapter 4, Sample applications 19
You can select an object with the common Tab/Shift+Tab keys or
by selecting them with the mouse.
We are now going to end the dialog box creating. There are many
more objects you can place on a dialog box as you saw when you
popped up the local menu. They are all listed in the Reference
Manual.
11. Press Enter to close this dialog box, then press Alt+X to quit to
PtGen.
You are back in PtGen and you can save the application you
created.
12. Press Alt+X to exit PtGen. A dialog box asks you if you want to
save your application. Just press Enter and your application is
saved before PtGen returns to the dos prompt.
PtGen did save your application in Turbo Pascal source code
format. It saved it as a unit. To turn the application you created to
an executable, see the next chapter.
20 PtGen User Guide
C H A P T E R
───────────────────────────────────────────────────────────────────────────────
5
Turning your code into an executable
The code PtGen creates is saved as a unit. As units can't be run,
you need to write a main program. Sometimes this is very simple,
most of the times, your program contains the real flesh and PtGen
provides only the skin. Two examples are given: one very simple,
the most basic one. And one more complex and realistically.
PtGen has also the ability to create automatically a main. This is
treated in the third section.
An example of a simple main
───────────────────────────────────────────────────────────────────────────────
The most basic Main is the following program. Assumed is that
you saved your application in file SAMPLE.PAS and that you
named your application object SampleApp.
program Main;
uses Objects, {* contains RStringList *}
HelpFile, {* the helpfile unit from
bp/examples/dos/tvdemo *}
Sample, {* which contains the Application
object *}
BBStrRes; {* PtGen resource string unit *}
var
TMyApp : TSampleApp;
begin
{* register helpfile *}
RegisterHelpFile;
{* initialize string resources *}
RegisterType(RStringList);
LoadStrings;
TMyApp.Init;
TMyApp.Run;
Chapter 5, Turning your code into an executable 21
TMyApp.Done;
end.
The BBUtil, BBDlg, BBStrRes and BBFile units, the PREAPP.INC
include file as well as PREAPP.PAS (which should be in your
directory) should be available for the compiler as the unit that
PtGen creates needs them.
A more elaborated main
───────────────────────────────────────────────────────────────────────────────
program Main;
uses Objects, {* contains RStringList *}
Sample, {* which contains the Application
object *}
BBStrRes, {* PtGen resource string unit *}
HelpFile,
BBError; {* the errorhandling unit *}
var
TMyApp : TSampleApp;
begin
{* initialize string resources *}
RegisterType(RStringList);
LoadStrings;
{* register helpfile *}
RegisterHelpFile;
{* initialize errorhandling unit *}
InitBBError('MYAPP.LOG');
TMyApp.Init;
TMyApp.Run;
TMyApp.Done;
end.
The InstallExitHandler call will install an exit handler which gives
you a stack dump when your program is aborted. This stack
dump (and other information) is written to MYAPP.LOG.
See the file SQL2XPL.PAS for a complete working example. It
should be in the SAMPLE subdirectory or else in the SAMPLE.ARJ
file.
22 PtGen User Guide
Let PtGen create a main for you
───────────────────────────────────────────────────────────────────────────────
PtGen has also a menu option which automatically creates an
advanced main for you. Now you can prototype really fast!
Choose from the main menubar File |Main file. This option only
works if you have created and saved an application or if you have
loaded an existing application.
Next you are prompted to specify the filename for your main
program. That's all.
Chapter 5, Turning your code into an executable 23
24 PtGen User Guide
C H A P T E R
───────────────────────────────────────────────────────────────────────────────
6
More advanced topics
This chapter discusses some more advanced topics in PtGen like
string resource files and adding units to the uses clause so you can
import your own views.
Using string resource files
───────────────────────────────────────────────────────────────────────────────
Still to be written...
See Chapter 7 of the Borland Pascal Resource Workshop User's
Guide which provides essentially the same information as should
be presented here. PtGen's string resource handling is modeled
after the Windows string resource handling.
Adding units
───────────────────────────────────────────────────────────────────────────────
For some views (for example the inputline) you can press a code
button to change the pointer to the objecttype (for an inputline this
is PInputLine) or to add parameters.
In order to use your own views you can enhance the uses clause in
the implememtion section. To do so popup the Desktop Local
Menu by pressing Alt+F10 (Local Menu) and choose Units. You can
now add, edit or delete unitnames.
The units will be added at the end of the uses clause.
Using resources
───────────────────────────────────────────────────────────────────────────────
PtGen has the ability to turn the unit it has created into a
TurboVision style resource file. It works as follows: first create the
objects you want in the resource file just as you normally do. Next
save your application as you always do.
Chapter 6, More advanced topics 25
To create a resource file you need a resource file creating program.
This program should import the unit PtGen created and write each
of the objects to a resource file. You can write such a resource file
creating program yourself, or let PtGen create automatically one.
Choose File |Resource file from the menubar to create a resource
file called MAKERES.PAS in the current directory. PtGen asks you
for the main program filename. You can enter some name or leave
it empty. It's only used to let identify MAKERES itself when it
starts up and writes a string including the name of the program
this resource file is for.
MakeRes includes PTGRES.INC, an include file PtGen always
writes when it saves an application. This file consists of one
procedure PutPtGenObjects which puts all objects in the unit into
a supplied resource file.
You can extend MakeRes in anyway you want, although it's fully
functional for all objects you created with PtGen. If you run
MakeRes it creates a resource file called test .tvr.
Using TVToys
───────────────────────────────────────────────────────────────────────────────
You turn on TVToys support if you click on TVToys item in
Options on the Application configuration dialog box. Your
application will now inherited (via TPReApp) from TToyApp,
TVToys' application object.
If you want previous help screen support, create a new status def
in the range 11111..11111 and add Alt+F1 (and if you wish F1
and Shift+F1) as status line items. Commands should be
cmPreviousTopic, cmHelp, cmHelpOnHelp or cmHelpContents.
These commands are only available with the correct values if you
have turned on TVToys support.
26 PtGen User Guide
A P P E N D I X
───────────────────────────────────────────────────────────────────────────────
A
Command-line options
PtGen recognizes the following command-line options:
Table A.1
Command-line options Option Description
/h show all recognized command-line options and their
meanings
/BW black and white palette for monochrome monitors
/25 25 lines
/50 VGA 50 or EGA 43 lines
/NGM don't use the graphics mouse
/GM use the graphics mouse
Command-line options always override options specified in the
PTGEN environment variable, see the next appendix.
Appendix A, Command-line options 27
28 PtGen User Guide
A P P E N D I X
───────────────────────────────────────────────────────────────────────────────
B
Environment variables
PtGen recognizes the following environment variables:
Table B.1
Environment variables Environment variable Description
PTGEN standard command-line options can be set
in this variable. The command-line always
overrides the specifications in the PTGEN
variable.
PTGINPUT The directory where the files are located
that PtGen needs to create an application.
Most of the time this will be the directory
where the executable resides.
Such files are DEFAULT.TVR,
ENGLISH.TVR, DUTCH.TVR,
PREAPP.INC and other.