Dec 062017
 
Turbo C code generator that makes simple menu systems.
File $2MENU18.ZIP from The Programmer’s Corner in
Category C Source Code
Turbo C code generator that makes simple menu systems.
File Name File Size Zip Size Zip Type
$2MAKE.BAT 538 188 deflated
$2MENU.C 10175 3086 deflated
$2MENU.DOC 16500 5573 deflated
$2MENU.MAK 305 211 deflated
$2MENUB.COM 2888 1638 deflated
$2MENUX.COM 3280 1884 deflated
BIOSKEY.C 143 102 deflated
CLRWIN.C 533 276 deflated
DOSVER.C 410 268 deflated
DRAWBOX.C 1361 433 deflated
EXEC.C 1915 812 deflated
EXIT.C 212 143 deflated
FASTWRIT.C 600 309 deflated
FPUTSH.ASM 1839 832 deflated
GOTOXY.C 215 117 deflated
INITSCRN.C 708 314 deflated
LIBMAKE.BAT 21 21 stored
MEMRLS.C 1040 558 deflated
MENUDATB.C 3891 1233 deflated
MENUDATX.C 3472 1033 deflated
MYMENU.BAT 105 83 deflated
SETATT.C 584 284 deflated
STRLEN.ASM 1354 631 deflated
TEENY.ASM 875 490 deflated
TEENY.OBJ 275 248 deflated
TEENYLIB.LIB 5541 2243 deflated
TEENYLIB.MAK 782 367 deflated

Download File $2MENU18.ZIP Here

Contents of the $2MENU.DOC file




$2 $2 $2 $2 $2 $2 $2 $2 $2 $2 $2 $2 $2 $2 $2 $2 $2 $2 $2
$2 $2 $2 $2 $2 $2 $2 $2 $2 * DONATION * $2 $2 $2 $2 $2 $2 $2 $2 $2 $2
$2 $2 $2 $2 $2 $2 $2 $2 $2 $2 $2 $2 $2 $2 $2 $2 $2 $2 $2



Place two one-dollar bills (or one two-dollar bill if you still can
find one) in an envelope and mail it to the program author.

Please also send any suggestions or comments you may have.

PROGRAM AUTHOR: David Gwillim
159 Woodbury Road
Hicksville, NY 11801-3030
Voice: (516) 942-8697

Saturday 23 June 1990

This software package may not be sold for profit by any other
individual or organization without my explicit written permission.
Companies wishing to include this software in their shareware/freeware
libraries may do so, but I require that they send me a letter
informing me that they have, and the package must remain complete and
unmodified, including this DOC file.


The $2MENU software package is Copyright (C) 1990 by David Gwillim





THE $2 MENU SYSTEM VERSION 1.80


This is a simple, configurable menu system that takes up minimal
disk space and yet is fast, efficient and looks smart. Multiple
menu windows can be easily coded. It is an attempt to return to the
days of yore when menu shells did not require large amounts of
one's hard disk.

It is the ideal tool for a computer consultant who knows a little C
programming (very little), to use when setting up a client's system
which contains a number of disrelated programs. It is faster and
cleaner than the usual batch file solution, and will work correctly
on a color or monochrome system without changes once configured.
(The menu data file MENUDAT_.C contains separate information for
color and monochrome).

Starting with version 1.8, $2MENU now has two possible forms of the
main program to choose between. One form uses a batch file for
execing programs selected from the menu and the other executes the
program directly using a DOS function call. The default is the exec
version. To compile $2MENU.C for batch file use you must include
the line #define BATCH 1 in the source file, or use the command line
compiler switch -DBATCH. When compiling for batch file the compiler
will #include MENUDATB.C and for exec it will #include MENUDATX.C.

Both forms of $2MENU have their advantages and disadvantages. On a
fast hard disk system the batch version works great and doesn't
incur any memory penalty. On a floppy system the direct exec
version might be preferable. You can compile either way, so take
your pick.

The way $2MENU is coded it generates a very small size .COM file
(less than 2K bytes for a small menu) and $2MENU.COM when compiled
for batch file mode (#define BATCH 1), uses no memory while it
execs menu selections. It is written using the undocumented TEENY
memory model and the start-up source code for this is included.

The bulk of the program is written in C with a couple of external
assembly language routines. $2MENU.C uses NO Turbo C run-time
library functions whatsoever, all the code is contained in the
source files in this ZIP file.

In order to use this software package you need to have a copy of
Turbo Assembler and Turbo C v 2.0 (or Turbo C++). I am sure you
could modify the source to fit other assemblers/C compilers, I just
haven't tested it with anything else.

$2MENU.C is an example of the use of TEENY.ASM as the startup code
for Turbo C programs, and how to create really small executable
files without having to resort to hand coding the whole program in
assembler. This gives a much more maintainable piece of software. I
am sure the code can be further optimized and cleaned up, but right
now with a small menu compiled for batch file mode it makes a .COM
file of only 2K which isn't too shabby.

STRLEN.ASM contains a replacement for the standard run-time library
function strlen.

FPUTSH.ASM contains a replacement for the standard run-time library
function fputs, called fputsh, that works with file handles (for
simplicity's sake) instead of streams. Note that fputsh() does NOT
translate \n into a CR LF on output so you will have to explicitly
use \r\n. This is done for flexibility.

MENUDAT_.C contains the constants for your particular menu system
that will be hard-coded into $2MENU_.COM when everything is compiled
and linked.

The menu is automatically sized to fit the largest entry and the
number of items. It is centered on the screen horizontally and
vertically, obtaining its data for screen width and number of rows
from the BIOS data area. The colors used are presettable for color
and monochrome systems. Any BIOS display mode not 7 is assumed to
be a color display. The box styles and screen fill character may
also be defined separately for color and monochrome systems.

A menu command string that has a 'c' as the first character will
clear the screen before the program is loaded. If a 'p' appears
there the batch file version will generate a @PAUSE command in
M.BAT after the command itself, and the exec version will give a
screen prompt to press a key. This is for use with programs that
write to the screen and then terminate, so you can read the output.

The batch file version is intended to be run inside an
appropriately named batch file that looks like this:

@ECHO OFF
CLS
:TOP
$2MENUB >M.BAT
IF ERRORLEVEL 1 GOTO DONE
CALL M.BAT
GOTO TOP
:DONE

If you are running under DOS 2.x then CALL and @ are unavailable and you
will have to use the less efficient:

@ECHO OFF
CLS
:TOP
$2MENUB >M.BAT
IF ERRORLEVEL 1 GOTO DONE
COMMAND /C M.BAT
GOTO TOP
:DONE

You will also have to modify the source code so that the @PAUSE
generated for commands with a leading space is PAUSE only.

When a menu item is selected inside MENU.COM its accompanying command
is written to the standard output which is redirected to the working
batch M.BAT file that gets newly created for each command. Using
redirected I/O saves considerably on code, to open, write and close
files.

A menu command tail string that has a 'c' as the first character
will clear the screen before the program is loaded. If the first
character is a 'p' $2MENU will clear the screen before running the
program and then pause for a keystroke before redrawing the menu.
This is for use with programs that write to the screen and then
terminate, so you can read the output.

The version of exec() in $2MENU does not support DOS 2.x. This is
intentional as most everyone is using DOS 3.x or better these days
and not supporting 2.x simplified the code for the exec() function.
If you want to support DOS 2.x you will have to rewrite exec() so
that ALL the registers you want to have stay intact are pushed on
the stack before calling the DOS exec function and then ALSO save
the SS and SP registers in a CS segment based variable so that the
registers can be restored. Under DOS 2.x the exec call destroys all
registers except CS and IP!



ASSEMBLY, COMPILATION & LINKING:
See TEENYLIB.MAK, $2MENUB.MAK and $2MENUX.MAK



This software package consisting of the files:

$2MENU.DOC - info on the $2MENU system

MYMENU.BAT - sample batch file used to run $2MENUB.COM
$2MENUB.COM - precompiled demo menu for batch version
$2MENUX.COM - precompiled demo menu for exec version

$2MAKE.BAT - batch file to run make utility to make $2MENU

TEENYLIB.MAK - make file for TEENYLIB.LIB
TEENYLIB.LIB - function library
TEENY.OBJ - start up code for TEENY memory model
$2MENU.MAK - make file for $2MENU.COM (batch and exec)

$2MENU.C - source for $2MENU.COM (batch and exec)
MENUDATX.C - source for sample menu data for the exec version
MENUDATB.C - source for sample menu data for the batch file version

TEENY.ASM - source for minimal Turbo C startup code
STRLEN.ASM - source for strlen()
FPUTSH.ASM - source for fputsh()

BIOSKEY.C - source for bioskey()
CLRWIN.C - source for clrwin()
DOSVER.C - source for dosversion()
DRAWBOX.C - source for drawbox()
EXEC.C - source for exec()
EXIT.C - source for exit()
FASTWRIT.C - source for fastwrite()
GOTOXY.C - source for gotoxy()
INITSCRN.C - source for initscrn()
MEMRLS.C - source for memrls()
SETATT.C - source for setatt()

is Copyright (C) 1990 by David Gwillim.

This software package may not be sold for profit by any other
individual or organization without my explicit written permission.
Companies wishing to include this software in their
shareware/freeware libraries may do so, but I require that they
send me a letter informing me that they have and the package must
remain complete and unmodified.



Please send any suggestions, comments and donations to:

David Gwillim
159 Woodbury Road
Hicksville, NY 11801-3030

Voice: (516) 942-8697

Initial version written: 9 June 1990



09 Jun 1990: Changes log for version 1.10 (not released)
added a menu title centered on any line
cleaned up the code a little

10 Jun 1990: Changes log for version 1.20
added top, bottom, left and right spacing inside menu box
added multiple menu capability to menu engine
now responds to PgDn and PgUp to change menus
moved the title for the menu inside the menu structure
separated off the general functions into separate modules
and built them into a library (TEENYLIB.LIB)
made up a MAKe file for $2MENU and TEENYLIB.LIB

14 Jun 1990: Changes log for version 1.30 (not released)
corrected the code for positioning the menu box (off by one)
cleaned up the .MAK files so they are more specific for reMAKEs,
got rid of TLIB control file, added /mx to TASM command and
made sure publics were case-correct
added hook for dynamic memory allocation to TEENY.ASM

15 Jun 1990: Changes log for version 1.40
cleaned up the code some in drawmenu()
wrote exec(), mem rls() and dosversion() to add support
for directly executing program without using a batch
file. This incurs a memory overhead as $2MENU is
present in memory at all times.
now include the batch file version as an alternate
(zero memory overhead) way of executing programs from
the menu.
MENUDATA.C for the menu definition is renamed to MENUDATB.C
for the batch file version and MENUDATX.C for the exec()
version.
added flashing attribute for selected menu item while the
program is loading.

16 Jun 1990: Changes log for version 1.40
added error trapping for menu border values

20 Jun 1990: Changes log for version 1.50
cleaned up the code in exec() and memrls() as we were setting _AX
too early and the register could be changed before INT 21h is called.
Found out the above by trying to compile $2MENU under Turbo C++
1.00 (which does not generate as efficient code as Turbo C 2.0
when it comes to register usage). $2MENU will now compile
correctly with Turbo C++ 1.0 (in C mode), and run without crashing!!!
optimized the code in clrwin(), setatt() and drawbox() to
leftshift the value of att into an int before the loops.

21 Jun 1990: Changes log for version 1.6
fixed a bug in the $2MENUB.C code that would omit the @PAUSE
from the batch file even though it was requested.
optimized loop aritmetic for leftshift of "att" in fastwrite()
by moving it outside the loop.
chopped about 60 bytes off the .COM file size by turning on
the compiler -O flag in the .MAK files to optimize jumps (gets
rid of those dumb jump-to-next-byte instructions).
added some type casting to exec() and memrls() so that the
compiler doesn't complain about "non-portable ..."
made the error message for wrong DOS version in $2MENUX a bit
shorter (Aaaggghh! I have byte-removal fever!!!)
added a %1 parameter to MAKEALL.BAT so that you can use the new
Turbo C++ MAKE.EXE flag, -B, to force build make file targets.
fixed an inconsistency in STRLEN.ASM and PUTSH.ASM in the assume
statement which was assume cs:_TEXT,ds:_DATA, should have been
assume cs:_TEXT,DS:DGROUP. No harm done, but would have caused
problems writing strings in _BSS, as the offset would have been
wrong.
updated this DOC file intro text, as there were changes in the
program coding that didn't match it now.

22 Jun 1990: Changes log for version 1.7
gained a few more bytes in compiling under TURBO C++ by explicitly
setting the standard stack frame switch to OFF (-k-) in the .MAK
files as with TURBO C++ it defaults to ON (Turbo C 2.0 it
defaulted to OFF).
changed the code in main() for $2MENUX.C around a little and added
a warning about only using exit() to return to DOS and about
not using local (auto) variables in main() as they wouldn't work
properly due to our swapping to an internal stack (the compiler
assigned BP relative offsets would be invalid). This will make
the code a little less fragile for those who want to tinker with
it: well, at least they will have been warned!!

23 Jun 1990: Changes log for version 1.8
added true nested menus, now any menu can be selected as a menu
item from any other menu.
combined $2MENUx.C and $2MENUB.C into one source file with
conditional compilation.
changed the format for the menu array structure for MENUDATB.C
so that it's layout is the same as MENUDATX.C so the same
code could draw them both. This wastes a few bytes in the
compiled batch version (sob!).
overhauled MAKEALL.BAT and $2MENU.MAK so that a parameter can be
passed to tell MAKE to create the BATCH file or EXEC version.
MAKEALL.BAT is now called $2MAKE.BAT and there is a separate
LIBMAKE.BAT to remake TEENYLIB. I also now include TEENYLIB.LIB
and TEENY.OBJ in the package, as apparently some people possess
TURBO C but not an assembler. How could ANYONE live without an
assembler???!!!

Use: $2MAKE BATCH to make the batch file version
or: $2MAKE EXEC to make the direct exec version







 December 6, 2017  Add comments

Leave a Reply