home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource4
/
281_01
/
lib_demo.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-10-07
|
26KB
|
852 lines
/* lib_demo.c
*
* UCLIB 5.00 Demo program
*
*/
#include <stdio.h>
#include "uc_defs.h"
#include "uc_glob.h"
#include "uc_proto.h"
#include "uc_key.h"
#include "wn_defs.h"
#include "wn_glob.h" /* used for declaration of sound_on */
/*
* There are not many comments in this program since the comments
* for each function are effect located in the reference guide.
* Please refer to that file as you go through this code. It
* should provide you with a complete overview of each function
* and how it may be called and used. Sorry but no complete
* manual exists for this version. Registered users will receive
* a disk containing the test programs used by the author in
* developing the library. If you feel a full manual would be
* of help drop a line to the author. If enough such requests
* are received a complete manual will be considered for future
* versions of the library.
*
*/
char test_str[] = " This is a test string ";
char tmp_str[ 100 ];
void main( int argc, char argv[] )
{
int i;
long il;
char in_str[ 81 ];
int cstart;
int cstop;
char *str_mon();
int back;
int fore;
uc_init(); /* Inititalize various system variables */
if ( mouse_exist )
m_flagdec();
if ( argc > 2 )
sound_on = 0;
cls_clr( mk_att( BLUE, WHITE + BRIGHT ) );
c_printf( mk_att( BLUE, BROWN + BRIGHT ),
"\n\n ┌──────────────────────┐\n" );
c_printf( mk_att( BLUE, BROWN + BRIGHT ),
" │ Unicorn Software │\n" );
c_printf( mk_att( BLUE, BROWN + BRIGHT ),
" │ P.O. Box 3214 │\n" );
c_printf( mk_att( BLUE, BROWN + BRIGHT ),
" │ Kirkland Wa │\n" );
c_printf( mk_att( BLUE, BROWN + BRIGHT ),
" │ 98083-3214 │\n" );
c_printf( mk_att( BLUE, BROWN + BRIGHT ),
" │ (206) 823-4656 │\n" );
c_printf( mk_att( BLUE, BROWN + BRIGHT ),
" └──────────────────────┘\n\n" );
c_printf( mk_att( BLUE, MAGENTA + BRIGHT ),
" ════════════════════════════════════════════════════\n\n" );
c_printf( mk_att( BLUE, RED ),
" Welcome to version 5.00 of the Unicorn Library\n\n" );
c_printf( mk_att( BLUE, WHITE + BRIGHT ),
"\t\t This demo program will illustrate " );
c_printf( mk_att( BLUE, BROWN + BRIGHT ),
"some " );
c_printf( mk_att( BLUE, WHITE + BRIGHT ),
"of the new library's\n" );
c_printf( mk_att( BLUE, WHITE + BRIGHT ),
"\t\t capabilities. It is impossible to show everyone of the " );
c_printf( mk_att( BLUE, BROWN + BRIGHT ),
"over\n\t\t 300 functions " );
c_printf( mk_att( BLUE, WHITE + BRIGHT ),
"contained in the library. You might also try\n" );
c_printf( mk_att( BLUE, WHITE + BRIGHT ),
"\t\t the programs `" );
c_printf( mk_att( BLUE, GREEN ),
"WINDOW.EXE" );
c_printf( mk_att( BLUE, WHITE + BRIGHT ),
"' and `" );
c_printf( mk_att( BLUE, GREEN ),
"TDATA.EXE" );
c_printf( mk_att( BLUE, WHITE + BRIGHT ),
"' which demonstrate\n" );
c_printf( mk_att( BLUE, WHITE + BRIGHT ),
"\t\t the windowing and data entry portions of the library. \n" );
c_printf( mk_att( BLUE, WHITE + BRIGHT ),
"\t\t At several points during the demo the program will stop and\n" );
c_printf( mk_att( BLUE, WHITE + BRIGHT ),
"\t\t wait. Whenever this occurs simply press a key to continue.\n" );
uc_key();
c_printf( mk_att( BLUE, BROWN + BRIGHT ),
"\n\t\t There now that wasn't so hard! Just remember to press a\n" );
c_printf( mk_att( BLUE, BROWN + BRIGHT ),
"\t\t key whenever the program has stopped.\n" );
uc_key();
cls_clr( mk_att( RED, WHITE + BRIGHT ) );
c_printf( mk_att( RED, MAGENTA + BRIGHT ),
"\n\t\tFirst we will look at the three primary screen control functions.\n\n" );
c_printf( mk_att( RED, BROWN + BRIGHT ),
"\t1. " );
c_printf( mk_att( RED, WHITE + BRIGHT ),
"A full color version of the standard printf function. This\n" );
c_printf( mk_att( RED, WHITE + BRIGHT ),
"\t\thas been used to provide all the screen output you have seen up\n" );
c_printf( mk_att( RED, WHITE + BRIGHT ),
"\t\ttill now. It works the same as the normal printf, accepting all\n" );
c_printf( mk_att( RED, WHITE + BRIGHT ),
"\t\tthe usual printf formatting parameters with two exceptions. It\n" );
c_printf( mk_att( RED, WHITE + BRIGHT ),
"\t\trequires a first parameter that is the attribute desired and\n" );
c_printf( mk_att( RED, WHITE + BRIGHT ),
"\t\tsecondly will not scroll the screen when the bottom line is\n" );
c_printf( mk_att( RED, WHITE + BRIGHT ),
"\t\treached. Other than this it works the same including a variable\n" );
c_printf( mk_att( RED, WHITE + BRIGHT ),
"\t\tnumber of arguments. \n" );
c_printf( mk_att( RED, BROWN + BRIGHT ),
"\n\t2. " );
c_printf( mk_att( RED, WHITE + BRIGHT ),
"A Clear screen function that allows clearing the screen to a\n" );
c_printf( mk_att( RED, WHITE + BRIGHT ),
"\t\tparticular attribute. It has been used to clear the screen in this\n" );
c_printf( mk_att( RED, WHITE + BRIGHT ),
"\t\tdemo. \n" );
c_printf( mk_att( RED, BROWN + BRIGHT ),
"\n\t3. " );
c_printf( mk_att( RED, WHITE + BRIGHT ),
"A full color version of gets which allows the use of user input\n" );
c_printf( mk_att( RED, WHITE + BRIGHT ),
"\t\tusing a desired attribute or at least not destroying the current\n" );
c_printf( mk_att( RED, WHITE + BRIGHT ),
"\t\tscreen attibute. \n" );
uc_key();
cls_clr( mk_att( CYAN, BROWN + BRIGHT ) );
c_printf( mk_att( CYAN, BROWN + BRIGHT ),
"\n\n\t\tNow try typing in a string with the c_gets function.\n\n" );
i = c_gets( mk_att( CYAN, BLACK ), in_str );
c_printf( mk_att( CYAN, BROWN + BRIGHT ),
"\n\n\tThe string you typed had " );
c_printf( mk_att( CYAN, RED + BRIGHT ),
"%d", i );
c_printf( mk_att( CYAN, BROWN + BRIGHT ),
" characters and was\n\t" );
c_printf( mk_att( CYAN, BLUE + BRIGHT ),
"<%s>", in_str );
c_printf( mk_att( CYAN, BROWN + BRIGHT ), "\n\n" );
c_printf( mk_att( CYAN, BROWN + BRIGHT ),
"\n\n\tDid you try to edit your string? If not why not try again.\n\n" );
i = c_gets( mk_att( CYAN, BLACK ), in_str );
c_printf( mk_att( CYAN, BROWN + BRIGHT ),
"\n\n\tThe string you typed had " );
c_printf( mk_att( CYAN, RED + BRIGHT ),
"%d", i );
c_printf( mk_att( CYAN, BROWN + BRIGHT ),
" characters and was\n\t" );
c_printf( mk_att( CYAN, BLUE + BRIGHT ),
"<%s>", in_str );
c_printf( mk_att( CYAN, BROWN + BRIGHT ), "\n\n" );
uc_key();
if ( sound_on )
uc_error();
cls_clr( mk_att( GREEN, BLUE + BRIGHT ) );
c_printf( mk_att( GREEN, BLUE + BRIGHT ),
"\n\n\n\t\tAs you can see these three functions provide considerable\n" );
c_printf( mk_att( GREEN, BLUE + BRIGHT ),
"\t\tcontrol over how the screen appears and this degree of\n" );
c_printf( mk_att( GREEN, BLUE + BRIGHT ),
"\t\tcontrol is easy to achieve as you will see when you\n" );
c_printf( mk_att( GREEN, BLUE + BRIGHT ),
"\t\tlook at the source code for this demo.\n" );
uc_key();
if ( sound_on )
uc_ok();
c_printf( mk_att( GREEN, WHITE + BRIGHT ),
"\n\n\t\tNext we will look at some of the functions designed\n" );
c_printf( mk_att( GREEN, WHITE + BRIGHT ),
"\t\tfor general string handling and manipulation.\n" );
c_printf( mk_att( GREEN, WHITE + BRIGHT ),
"\t\tThe source code for all of the demo programs is provided\n" );
c_printf( mk_att( GREEN, WHITE + BRIGHT ),
"\t\t