Dec 142017
 
C Source Program Generator.
File CGEN.ZIP from The Programmer’s Corner in
Category C Source Code
C Source Program Generator.
File Name File Size Zip Size Zip Type
BEEP.OBJ 69 69 stored
CGEN.COM 10502 7101 deflated
CGEN.DOC 9297 3201 deflated
CGEN.H 383 211 deflated
CGEN.LIB 1024 382 deflated
CGEN.LST 189 84 deflated
CLS.OBJ 83 83 stored
LIB.DOC 1151 341 deflated
MOVE.OBJ 221 209 deflated
SCR.ASC 732 168 deflated
SCR.C 992 346 deflated

Download File CGEN.ZIP Here

Contents of the CGEN.DOC file


























C - G E N

C S o u r c e C o d e

G e n e r a t o r










(c)1988, Perception Software
Ft. Washington,Md 20744

































C-Gen C Source Code Generator




OVERVIEW

C-Gen is an attempt to alleviate a problem I had in creating quick
screens for my C Programs.

I constantly found myself spending the time writing first the
screens by hand and then testing where they appeared after I wrote
by "printf's".

C-Gen takes care of that problem. The idea behind C-Gen was taken
from two similar packages I have seen that generate Pascal source
code.

Although I have seen other C source code generators, I found they
do not allow the programmer any flexibility in using his own, or
standard C routines. One of the main goals in writing C-Gen was
not to tie either myself down to a program that could not be
modified to run with what ever C compiler I had handy. That at
least I think I have achieved.

The program is fairly complete. Hopefully every possible
situation has been thought of; if not, let me know.

If you have any questions, comments, and/or criticisms write me a
line, my address is below. But, if you like the program, and
intend to use it, A contribution of $15.00 would help to defer
some of the effort taken to pull it together.


Wesley Peace
12707 Asbury Drive
Ft. Washington, Md. 20744



C-Gen C Source Code Generator


WHAT YOU NEED


MS-DOS Personal Computer (with minimum 256K memory)
Single Drive

and the following files

cgen.com
cgen.h
cgen.lib (or cls.obj and move.obj)



HOW TO USE

C-Gen is a C function code generator. It takes as it's source any
ascii created text file and generates a C function.

Practically, the source file should be limited to 24 lines, since
that is the maximum that can be displayed on the screen; but with
C-Gen, you can experiment with your screen functions to get the
affect you desire.

To use C-Gen, first create your source file with your favorite
text editor or ascii graphics editor. Some possible choices for
editors are "The Draw", "Scredit", "WordPerfect", and "Qedit".

Use the Ascii mode to save the source. [NOTE: if you can read the
file and understand it after you have saved it, it is in the
correct format].

You are now ready to use C-Gen. Invoke C-Gen using the following
command line:

cgen [ source.asc ]

where "source.ext" is the name of the ascii text file you have
created. cgen generates a c source program from your source
file.

C-Gen uses two conventions to generate the files and function
names it creates.

(1) It takes the name of the source file as it's destination
file, appending a ".c" as a new extension. This should
be no problem unless you have a file already existing
with the same name.


C-Gen C Source Code Generator

(2) The file name is also used to create the function name
prepended with "c_". For example, the function
generated from the above source file would be saved in
the file "source.c" and would be called "c_source()".


WARNING: Any existing ".c" files of the same name will be
overwritten using this DEFAULT method.

This is the simplest and most straight forward method of using
cgen, and probably the way you will use it the most.

CONTROLLING CODE GENERATION

C-Gen offers a number of ways to control the creation of the C
source file. If you type cgen without a filename the message
below is displayed.


Usage: cgen /ctao [destination] SOURCE
where SOURCE is an ascii text file
/c add clear screen function
/t create text file
/a append to an existing file
/o [destination] defines an output filename


Each of these command switches is described below:


/c Clear Screen

If you are creating a full screen display, it looks better if
the screen is cleared prior to calling the function. This
switch places a call to the "cls()" function included in this
package.

There is nothing special about this routine. If you don't
want to use it, you don't have to. It won't affect
anything.

/t Generate Text File

If you notice, C-Gen uses a macro "mvprintf" to write what I
like to call optimize screen code. This is HIGHLY desired
when using graphics characters that do not appear on each
line. However, if you only want to generate a help screen,
it's a waste of cycles to make a call to "mvprintf" when a
simple "printf" will do.


C-Gen C Source Code Generator

This switch tells C-Gen to use a "printf" rather than the
more complex call to "mvprintf".

Unfortunately, the use of "printf" could require more editing
on you part; but look at it this way, ...LOOK AT HOW MUCH
CODE YOU DIDN'T HAVE TO WRITE.

/a Append

As the efficient C programmer that you are, You do not want
to generate a group of little ".c" file for linking. That's
more source to keep track of!

The append switch, used in conjunction with the output
filename switch allows you to append subsequent functions to
an existing file.

/o Output file

Using this switch, you can specify a filename to save your
function in other than the default. A typical call would
appear as follows


cgen /o myfile.c source.asc

where source.asc is the ascii source file
myfile.c is the new destination


Any of these switches can be used in combination. I've found that
the switches "/ao" go extremely well together.

THE INCLUDE FILE

C-Gen requires the inclusion of the #include file "cgen.h". If
you look at this file, it has only one line in it


#define mvprintf(x, y, s) move(x, y) puts(s)


As I stated above, I had no desire to write a program that could
not be easily understood and/or modified.

This one line is the heart of the full screen use of the program.

The function "move()" is provided in object code format and in
the library file "cgen.lib". It was written prior to the release
of Turbo C v1.5. If you have that version of the Turbo C



C-Gen C Source Code Generator

compiler, you can substitute the function "gotoxy()" in the place
of "move()".

The difference between the two functions is in the call; the ROW,
COL are reversed (gotoxy uses COL, ROW).

CLEAR SCREEN FUNCTION

Sometime ago, while experimenting with assembler, I learned how
easy it was to clear the PC screen. I also have always wondered
why no compiler vendor has ever called there function "cls()".

The routine provided with this package is the assembler routine I
first learned how to write. It can be substituted with any other
clear screen routine that you want.

I have, however found this routine FAST, and the name "cls()" is
sort of easy to remember.

CGEN.LIB

Included with this package is the library file "cgen.lib". For
those of you who don't like library files, I've included the
object code.

Also is a listing of the routines in the library. This listing is
in the file "cgen.lst".

The library routines are documented in the file "lib.doc".




 December 14, 2017  Add comments

Leave a Reply