Category : C Source Code
Archive   : FASTFORM.ZIP
Filename : FORM.DOC

 
Output of file : FORM.DOC contained in archive : FASTFORM.ZIP
x1






FastForm
Release version 2.0

by Tomas Gasper
Produced by ProBYTE Software







Copyright (c) 1989 by Tomas Gasper























































Instructions for using the Pascal Form include file

Form is a collections of library functions that give
Turbo Pascal 5.0 features ranging from multi screen buffers
to direct numeric to string conversion.































































Instructions for using the C include file

For most of you, the Pascal source will look like an old
friend. In case it doesn't, I will go over the only
differences and how to use this file for Turbo C.

The := is the most obvious difference. In Pascal, this
means the exact same thing as = does in C.

When assigning strings to values, you can just have
DESTINATION:=SOURCE in Pascal. However, for C, you will need
to change this format to STRCPY(&DESTINATION,SOURCE).

That's all there is to it! If you have any problems
using this for C, drop me a letter or E-Mail through
CompuServe.





















































Form was written specifically for use with code
generated by FastForm! (Copyright (c) 1989 Tomas Gasper).
However, it is a very effective tool by itself that will
speed the coding process. The basic idea behind the Form-
FastForm! group is to allow the programmer to concentrate on
the core and mechanical working of the program rather than
things like screen routines and conversion routines.

Form may be used with any program you wish without any
fees. I do ask that you place a notice on the opening screen
and in the documentation that is somewhat similar to this
"PORTIONS OF THIS PROGRAM WERE TAKEN FROM 'FORM' COPYRIGHT
(C) 1989 TOMAS GASPER".

BOTH FORM AND FASTFORM! ARE SHAREWARE PRODUCTS. THIS
MEANS THAT YOU MAY COPY AND DISTRIBUTE BOTH PROGRAMS AS MUCH
AS YOU LIKE SO LONG AS THE FOLLOWING CONDITIONS ARE MET: NO
FEE WILL BE CHARGED (OTHER THAN SHIPPING AND HANDLING) FOR
THIS PROGRAM, THIS PROGRAM WILL NOT BE DISTRIBUTED IN AN
ALTERED FORM, THIS PROGRAM WILL NOT BE INCLUDED WITH ANOTHER
PRODUCT THAT IS SOLD WITHOUT PERMISSION FROM TOMAS GASPER.

If you like this program, I ask that you send a CHECK
for $15 to the address below. If you already have spent the
$30 for FastForm! you have already been registered for Form.
The benefits that you receive for this investment are as
follows: update notices, the current version, your assurance
of a virus free program, ability to sleep at night knowing
that you have supported the shareware community.


DISCLAIMER

I, TOMAS GASPER, DO NOT ACCEPT ANY RESPONSIBILITY FOR
ANY DAMAGE TO ANYTHING AS A RESULT OF THE USE OF THIS
PROGRAM. IF YOU HAVE ENCOUNTERED OR EVEN JUST SUSPECT THAT
THIS PROGRAM HAS BEEN TAMPERED WITH ANY WAY (ESPECIALLY
VIRUSES) I ASK THAT YOU REPORT YOUR MISFORTUNE TO ME AT THE
BELOW ADDRESS OR VIA COMPUSERVE. IF YOUR CLAIM TURNS OUT TO
BE TRUE, I WILL MAIL YOU A PURE COPY OF FORM FREE. OTHERWISE,
BETTER LUCK NEXT TIME.



Tomas Gasper
712 Knipp Ave.
Mascoutah IL 62258
CompuServe ID: 72137,2743



















Table of contents


CURSORON . . . . . . . . . . . . . . . . . . . . . . . . 8

CURSOROFF . . . . . . . . . . . . . . . . . . . . . . . 9

FASTWRITE . . . . . . . . . . . . . . . . . . . . . . . 9

DISPLAY . . . . . . . . . . . . . . . . . . . . . . . . 9

FASTCENTER . . . . . . . . . . . . . . . . . . . . . . . 9

FASTBOX . . . . . . . . . . . . . . . . . . . . . . . . 9

FASTLINE . . . . . . . . . . . . . . . . . . . . . . . . 10

GETDATA . . . . . . . . . . . . . . . . . . . . . . . . 10

GETREAL . . . . . . . . . . . . . . . . . . . . . . . . 11

GETINT . . . . . . . . . . . . . . . . . . . . . . . . . 12

GETSTRING . . . . . . . . . . . . . . . . . . . . . . . 12

ENTERKEY . . . . . . . . . . . . . . . . . . . . . . . . 12

GETKEY . . . . . . . . . . . . . . . . . . . . . . . . . 12

COPYSCREEN . . . . . . . . . . . . . . . . . . . . . . . 12

SAVESCREEN . . . . . . . . . . . . . . . . . . . . . . . 13

FASTCLEAR . . . . . . . . . . . . . . . . . . . . . . . 13

ASC . . . . . . . . . . . . . . . . . . . . . . . . . . 13

ROUNDUP . . . . . . . . . . . . . . . . . . . . . . . . 13

CHAREPEAT . . . . . . . . . . . . . . . . . . . . . . . 14

BARSELECT . . . . . . . . . . . . . . . . . . . . . . . 14

INTGR . . . . . . . . . . . . . . . . . . . . . . . . . 15

HELP . . . . . . . . . . . . . . . . . . . . . . . . . . 15

FIND_COLOR . . . . . . . . . . . . . . . . . . . . . . . 15

VALUE . . . . . . . . . . . . . . . . . . . . . . . . . 16

STRG . . . . . . . . . . . . . . . . . . . . . . . . . . 16

STREAL . . . . . . . . . . . . . . . . . . . . . . . . . 16


















































































Overview

The first thing you should do is tell Turbo that you
will be using the FORM.TPU file in your program. For each
file that you will be using FORM routines, you must insert a
USES statement (see manual for details) at the beginning of
the program.

Make sure that you have copied FORM.TPU onto the
disk/directory that you want it to be on. When adding FORM to
your uses statement, DO NOT ADD THE ENDING .TPU after FORM.

Before we get into the real workings of FORM I would
like to get you acquainted with the codes and
functions/procedures used by FORM.

Below is a list of the codes that the procedure GETKEY
will return when called (no parms). The value is returned to
the integer type variable named RETURNCODE. You may do
anything with it that you want, the value will remain the
same until GETKEY is called again or the value is changed.

RETURN KEY PRESSED

0.........[ENTER]
1.........[Up arrow]
2.........[Left arrow]
3.........[Right arrow]
4.........[Down arrow]
5-31......[CNTRL A-Z]
32........[PgUp]
33........[PgDn]
34........[Home]
35........[End]
36........[Ins]
37........[CNTRL-Left]
38........[CNTRL-Right]
39........[Del]
40........[CNTRL-PgUp]
41........[CNTRL-PgDn]
42........[CNTRL-Home]
43........[CNTRL-End]
44........[ALT-Ins]
45........[ALT-Del]
46........[ALT-End]
47........[ALT-Down arrow]
48........[ALT-PgDn]
49........[ALT-Left arrow]
50........[ALT-Right arrow]
51........[ALT-Home]
52........[ALT-Up arrow]
53........[ALT-PgUp]
54..63....[CNTRL-(0-9)]
64........[ALT-Minus]














65........[ALT-=]
66........[CNTRL-Up arrow]
67........[CNTRL-Down arrow]
68........[ALT-Tab]
69........[CNTRL-Tab]
70........[CNTRL-Ins]
80........[CNTRL-Del]
81-90.....[ALT-(0-9)]
91-100....[CNTRL-(0-9)]
101.......[CNTRL-minus]
102.......[CNTRL-=]
103.......[CNTRL-Tab]
104.......[ALT-Tab]
108-133...[ALT-(A-Z)]
144-153...[F1-F10]
155-164...[CNTRL-([F1]-[F10])]
166-175...[Shift-([F1]-[F10])]
177-186...[ALT-([F1]-[F10])]
188.......[Tab]
189.......[Shift-Tab]
190.......[Backspace]
191.......[Esc]


Before a definition of every procedure is given, you
need to know what a few general pre-defined public variables
are.

COLOR[1] & COLOR[2] are the variables to hold what the colors
will be on the next text printed to the screen ONLY through
Form procedures. You can enter the names of the colors you
want the same way you assign a value to an array variable.
For example, if you wanted to print the next text as
lightcyan on a blue background, you would enter the
following:

COLOR[1]:=LIGHTCYAN;
COLOR[2]:=BLUE;

Below is a list of all of the procedures/functions that
you can use in your programs that are accessed just like any
other procedure/function.

INITIALIZE is the procedure that will initialize all
variables and clear the screen buffers. It is required that
this be accessed before using any other operation from FORM.

***********************************************************

CURSORON is the procedure that will turn on the cursor. (both
CURSORON and CURSOROFF may have adverse effects on the
cursors with some video boards)

***********************************************************














CURSOROFF is the procedure that will turn off the cursor.
(both CURSORON and CURSOROFF may have adverse effects on the
cursors with some video boards)

***********************************************************

FASTWRITE will write the data in one of the formal parameters
directly to one of the display buffers. A display buffer is
one of the 5 buffers (0..4) that have been set aside so that
you can have multiple screens in memory and then just move
them onto the video buffer (area that is displayed on the
screen). The formal parameters for this procedure are as
follows: DISPLAY BUFFER NUMBER,X POSITION,Y POSITION,MESSAGE.
Message is what is placed in a display buffer. Take this
example
FASTWRITE(0,38,12,'Hello');
The message "Hello" would be placed in display buffer number
0 at position 38 x 12.

***********************************************************

DISPLAY is used to move one of the display buffer onto the
video buffer. This may cause snow on some CGA boards when
this is done. The single formal parameter is an integer that
represents the display buffer to be displayed. Example
DISPLAY(0);
Display buffer 0 would be moved onto the video buffer.

***********************************************************

FASTCENTER is basically identical to FASTWRITE with the
exception that there is no X position entered in the formal
parameters. This is because MESSAGE will be centered in a
buffer at the specified Y position.

***********************************************************

FASTBOX is a procedure that allows for boxes to be drawn on
the screen relatively easy. This is an extremely powerful
tool for any programmer that has ever wished for an easy way
to draw boxes on the screen from within the program.

FASTBOX has two types of boxes preprogrammed, single and
double bar. They are numbered from 1 respectively. Before
calling this procedure, you need to know what the upper left
hand corner coordinates are, the lower right hand
coordinates, the fill color of the box (if you do not want
any fill in, use -1 as the box fill color), and the type of
box you want to draw. The parameters are as follows: THE BOX
NUMBER, SCREEN BUFFER NUMBER, UPPER LEFT COORDINATES, LOWER
RIGHT COORDINATES, AND THE FILL COLOR. The color of the
actual box colors is determined from the present colors in
COLOR[1] & COLOR[2].















For example: You want to draw a double bar box using
yellow on cyan in buffer 0, from 10,5 to 70,20 and you want
to have a blue filling. The necessary statements are shown
below:
COLOR[1]:=YELLOW;
COLOR[2]:=CYAN;
FASTBOX(2,0,10,5,70,20,BLUE);

***********************************************************

FASTLINE is a procedure that will repeat any character from X
to Z number of times, one after another. It is useful when
you may just want to print a line across the screen.

The format is as follows: SCREEN BUFFER NUMBER,BEGINNING
X VALUE, ENDING X VALUE, Y VALUE, THE CHARACTER TO BE
PRINTED.

For example: Getting back to my suggestion above, let's
say you are writing the main menu in buffer 0, and you have
the title and credits shown on top and now you want a
straight line on 4 from 1 to 80 to separate it from the rest
of the screen. The character will be #196 which is the
extended ASCII character that is a single line extending from
both edges of the character box. The necessary command is
shown below. NOTE: You may have the character in the form of
'C' or #x.

FASTLINE(0,1,80,4,#196);

***********************************************************

GETDATA is a procedure that is used as a replacement for
READLN(). It is superior to READLN() because of its ability
to accept such things as backspacing by words, and giving you
the capability to abort editing of text by the press of
either a single key, or by any number of single key presses.
NOTE: There are functions that make it easier for you to get
data in a more conventional method. This is the core of the
other input routines, and was not designed for use as an
independent procedure unless your needs call for the use of
this procedure. You will not need to use this procedure
unless you need the following capabilities: Ability to reject
certain characters, Restrict aborting a text entering to just
a few keypresses, or you just want to make a lot of work for
yourself.

If you still want to use this procedure, you will need
to manually handle four variables: INSTRING, REJECT_CRITERIA,
BREAKLOOP_CRITERIA, and RETURNCODE.

The format for this procedure is as follows: SCREEN
BUFFER NUMBER, X POSITION, Y POSITION, MAXIMUM LENGTH FOR
INPUT DATA.















INSTRING is the data that will be sent to the procedure for
editing and will be returned in the edited form.

REJECT_CRITERIA is a set of characters that will not be
accpeted. If you wanted to input a numeric value, you will
restrict entering to just numbers or mathematical symbols.

BREAKLOOP_CRITERIA is a set of RETURNCODE values (see the
first page--you did read it, didn't you?) that will NOT cause
exiting from the procedure. I know this is not appropriately
named.

RETURNCODE is described on the first page of this manual.

The process for using this procedure is fairly simple.
The first thing to do is to assign a value to INSTRING. It
will usually be a null value (''), but there may be times
when you will want to edit specific data that has previously
been entered. In that case, you would assign that value to
INSTRING. Next, you will need to set the REJECT_CRITERIA
data. This should be entered in the form of a set and will
usually be null. Now set the BREAKLOOP_CRITERIA. Again, this
will be in the set format and is normally as follows:
34,36..39,2,3,190,200.

For example: You want to enter the filename for saving.
You will not accept numbers, extended ASCII, symbols, or
control characters. All printing will be done in buffer 0 at
position 10,10. The maximum length will be 12 characters. You
will not take any other keypress other than [ENTER] and
[ESC]. The following lines show how this example would be
done.

INSTRING:='';
REJECT_CRITERIA:=[0..45,47..64,91..96,97..122];
BREAKLOOP_CRITERIA:=[1..190,192..200];
GETDATA(0,10,10,5);
FILENAME:=INSTRING;

************************************************************

GETREAL is a specialized function that replaces the READLN()
statement and uses the GETDATA procedure in a specialized
fashion. It is designed for use with general purpose real
number entry. The entry is returned as a real and,
consequently, must be assigned to a real type variable.

The format for this function is as follows: SCREEN
BUFFER NUMBER, X POSITION, Y POSITION, MAXIMUM LENGTH OF
NUMBER FOR INPUT (length is in maximum characters, not
maximum number), ORIGINAL VARIABLE. Please note, this is a
function and returns a value to a variable of the real type
format.















GETREAL will only allow the entry of standard math
symbols and numerical characters.

For example: You are writing a bank account program and
you are ready for the user to enter the amount deposited in
buffer 0 at position 10,10. The following command will do the
above stated requirements.

DEPOSIT:=GETREAL(0,10,10,15,DEPOSIT);

************************************************************

GETINT is exactly the same as GETREAL except that it requires
integer variables. For information on using this function,
read the GETREAL instructions.

************************************************************

GETSTRING is exactly the same as GETREAL except that it
requires string variables. For information on using this
function, read the GETREAL instructions.

************************************************************

ENTERKEY is the equivalent to READKEY of TP 4 & 5. It offers
only one advantage over READKEY which is that ENTERKEY will
interpret the leading [ESC] in a special key such as [PgUp]
as #27 instead of #0 as READKEY does. The keypress is
returned in the variable INPT.

************************************************************

GETKEY sets RETURNCODE with the proper number the corresponds
with a key press. It automatically calls ENTERKEY and returns
the keypress in INPT and the code in RETURNKEY. NOTE: If a

special key was pressed such as [PgUp], INPT will only
contain the last ASCII code, not the #27.

************************************************************

COPYSCREEN is a procedure that will make an exact duplicate
of any screen buffer into another. It takes advantage of the
MOV opcode in the 8086 instruction set, thereby making this
transfer very fast. This makes it an excellent tools for text
animation such as scrolling bars. Remember that you must use
DISPLAY to update the screen with any buffer data.

The format is as follows: ORIGINAL BUFFER, DUPLICATE
BUFFER.

For example: We want to copy buffer 1 to 0. The
following code will do this:















COPYSCREEN(1,0);

************************************************************

SAVESCREEN will copy the current text screen to any screen
buffer. This may be useful if you want to write a majority of
the screen via fastwrite, and then write a few little things
with WRITELN, but then you also want to keep an exact copy of
the visual screen in a screen buffer. This will use the MOV
opcode in the 8086 instruction set to make this copy as fast
as possible.

The format is as follows: SCREEN BUFFER.

For example: You are writing a main menu with FASTWRITE.
You will then by writing the default option number with
WRITELN. Because you will be writing the screen buffer to the
visual buffer, you want to keep an exact copy of the visual
buffer in screen buffer 0. The following code will do this:

SAVESCREEN(0);

************************************************************

FASTCLEAR is the equivalent to CLRSCR for a screen buffer. It
simply erases a screen buffer.

The format is as follows: SCREEN BUFFER.

For example: You want to erase screen buffer 0.

FASTCLEAR(0);

************************************************************

ASC is the equivalent of ORD for a string. ASC will look at
the first character in a string and return the ASCII value in
an integer type.

The format is: STRING type

For example: You have a character, 'f', in string format
and you want to know the ASCII value.

VARIABLE:=ASC('f');

************************************************************

ROUNDUP will take a REAL value (or variable) and return it
rounded up the nearest integer in an integer format. It is
the exact opposite of INT. If you are not sure whether the
variable will be an integer or not (but will be a real type
variable), you can still call ROUNDUP, if the value is















The format is: REAL type.

For example: You are writing a program that will
calculate the sales tax into the subtotal of a cashier's
program. Of course, you want to round up so you use the
following statement.

TOTAL:=ROUNDUP(SUBTOTAL*(1+TAX));

************************************************************

CHAREPEAT is a simple function that allows you to send it a
single character with the repeat number. The function will
then return, in string format, the character repeated X
number of times.

The format is: CHARACTER to be repeated, number of times
for the character to be repeated.

For example: You want to use a string of 25 astrict in a
text file produced by your program. You simply would type in
the following line.

STRING:=CHAREPEAT('*',25);

************************************************************

BARSELECT is an extremely powerful procedure that will allow
you to write screens with barselects. If you are wondering
what a barselect is, I will enlighten you: A barselect is a
process of printing a list of options and then selecting the
options be means of the arrow keys and [ENTER] to select. The
actual option is shown to the user as being selected by means
of a change in fore and/or background.

In order to use this, you will need to enter all of your
options in a pre-declared array appropriately named OPTION in
a string format. Each option may be no longer than 50
characters with a maximum of 20 options. You must also make
note of how many options you have put in the array. The
resulting option that was selected is placed in an integer
variable called OPT that corresponds with the option in the
array list.

The format is: The SCREEN BUFFER you want to use, the
first X coordinate, first Y coordinate, NUMBER OF OPTIONS,
FOREGROUND COLOR of each option in its natural state,
BACKGROUND of each option in its natural state, HELP number;
See procedure HELP below.

For example: You are writing a main menu with the
options of ADD A PERSON, DELETE A PERSON, or QUIT. You want
the text to be written in yellow on blue in its natural state
and light red on black in its selected state. All text should














be in buffer 0 with no help. If the user selected 3, the quit
option, you want to quit the program. The following
statements will do this:

OPTION[1]:='ADD A PERSON';
OPTION[2]:='DELETE A PERSON';
OPTION[3]:='QUIT';
BARSELECT(0,10,5,3,yellow,blue,lightred,black,-1);

************************************************************

INTGR is a simple function that takes a real value and uses
the STR & INT procedure that is standard in the Turbo Pascal
conversion library. It is, therefore, restricted to the same
limitations of INT. It is simply an easy way to convert from
a real type to an integer type.

The format is: REAL VALUE

For example: You have a value for X in a graph program.
You have arrived at the value of X through complex
calculations. Because of this, X is in a real form and the
graph procedure requires an integer. The following line will
do just that:

INTX:=INTGR(X);

************************************************************

HELP is not yet ready for use by the general public. Check
for version 2.1 on your favorite BBS on or about 6/17/89. I
am very sorry for any inconvenience that this may cause, but
a few design quirks with DOS and Turbo Pascal have forced
this delay.

************************************************************

FIND_COLOR is a simple way for you to do such things as print
the name of a color on the screen by only knowing the color
number. There are essentially two pallets of colors that are
dependent upon which mode of display you are using. For
backgrounds, use pallet 0 and pallet 1 for foregrounds.

The format is as follows: COLOR VALUE, PALLET.

For example. A user has entered the number of the
foreground and background colors that he or she wants to use.
You are now printing the names of the colors out of the
goodness of your heart. You have the background color
assigned the value FCOLOR and the background color assigned
to BCOLOR. The following code will return the names in the
strings FSTRING and BSTRING.

BSTRING:=FIND_COLOR(BCOLOR,0);














FSTRING:=FIND_COLOR(FCOLOR,1);

************************************************************

VALUE is the equivalent of INT in a function form. You should
find it of considerable use if you hate having to use several
statements and a dummy value when all you want is the integer
form of the string.

The format is as follows: STRING value

For example: You want to convert the string '123' to the
integer value and store it in LOTUS.

LOTUS:=VALUE('123');

************************************************************

STRG is the exact opposite of VALUE; it converts a numeric
value into a string.

The format is: INTEGER value

For example: You want to convert 123 into a string and
store it in string LOTUS.

LOTUS:=STRG(123);

************************************************************

STREAL does the same as STRG except that it will take real
values instead of integers.































  3 Responses to “Category : C Source Code
Archive   : FASTFORM.ZIP
Filename : FORM.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/