EXAMPLE CODE GENERATED FROM GENSCREEN. . . USE YOUR BROWSER BACK BUTTON TO RETURN. -------------------------------------------------------- /* custscreen.C - INSERT COMMENT LINE */ #include #include #include #include #include "deffile.h" /* Contains all commonly used #defines and extern variable * references. And #includes moncls.h */ #include "funcdecl.h" /* Contains all common one-time declarations */ /* Declare custscreen() function generateded from custscreen. */ int custscreen(); /* Variables and types declared in main.C are: */ int PROG, linlbl; /* Variables and types declared on screen testscn are: */ int empnum; char name[20]; char dest[20]; int DATEFLD; int mm, dd, yy; float f; money t; int code; void breakout(int); main() { /* Set up and activate the breakout function if Inturupt occurs. */ { struct sigaction newaction; newaction.sa_handler = breakout; newaction.sa_flags = 0; sigaction(SIGINT, &newaction, 0); } initscr(); cbreak(); keypad(stdscr,TRUE); nonl(); noecho(); clear(); refresh(); custscreen(); endit(); } /* Function to end and get out gracefully. */ /* May be called from other functions to exit at once. */ void endit() { clear(); endwin(); signal(SIGINT,SIG_DFL); signal(SIGQUIT,SIG_DFL); printf("Program terminated normally.\n"); exit(0); } /* Occurs only on Quit or Interupt, calls endwin and quits program. */ void breakout(int sig) { clear(); refresh(); endwin(); printf("Program terminated through CTL-C breakout.\n"); printf("Any entries made but not saved will be lost.\n"); exit(1); } int custscreen() { ISCHARFLD = NO; ISFLOAT = NO; ISMONY = NO; ENDINPUT = NO; /* START PROMPTING SECTION */ row = 1; col = 10; mvprintw(row,col,"Employee Travel Exp Authorization"); row = 4; col = 8; mvprintw(row,col,"Employee Num. "); row = 5; col = 8; mvprintw(row,col,"Employee Name "); row = 6; col = 8; mvprintw(row,col,"Destination "); row = 7; col = 8; mvprintw(row,col,"Travel Date "); row = 8; col = 8; mvprintw(row,col,"Travel Time "); row = 9; col = 8; mvprintw(row,col,"Ticket Cost "); row = 10; col = 8; mvprintw(row,col,"Authoiaztion Code "); row = 12; col = 8; mvprintw(row,col,"Instructions: Enter the data for the"); row = 13; col = 8; mvprintw(row,col,"employee and press to end and"); row = 14; col = 8; mvprintw(row,col,"return to the main menu."); /* START FIELDS SECTION */ /* FIELDNAME = empnum */ /* VARTYPE = int */ row = 4; col = 23; IFLDLEN = 6; DFLDLEN = 0; BEGFLD = 23; ENDFLD = 28; standout(); mvprintw(row,BEGFLD," "); standend(); getfields(); if(ENDINPUT == YES) endit(); if(intnos[0] != '\0') empnum = intnum; mvprintw(row,BEGFLD," "); mvprintw(row,BEGFLD,"%d",empnum); refresh(); /* END FIELD */ /* FIELDNAME = name[20] */ /* VARTYPE = char */ ISCHARFLD = YES; row = 5; col = 23; IFLDLEN = 20; DFLDLEN = 0; BEGFLD = 23; ENDFLD = 42; standout(); mvprintw(row,BEGFLD," "); standend(); getfields(); if(ENDINPUT == YES) endit(); if(intnos[0] != '\0') strcpy(name,intnos); mvprintw(row,BEGFLD," "); mvprintw(row,BEGFLD,"%s",name); refresh(); ISCHARFLD = NO; /* END FIELD */ /* FIELDNAME = dest[20] */ /* VARTYPE = char */ ISCHARFLD = YES; row = 6; col = 23; IFLDLEN = 20; DFLDLEN = 0; BEGFLD = 23; ENDFLD = 42; standout(); mvprintw(row,BEGFLD," "); standend(); getfields(); if(ENDINPUT == YES) endit(); if(intnos[0] != '\0') strcpy(dest,intnos); mvprintw(row,BEGFLD," "); mvprintw(row,BEGFLD,"%s",dest); refresh(); ISCHARFLD = NO; /* END FIELD */ /* FIELDNAME = DATEFLD */ /* VARTYPE = int */ /* Routine to get date fields */ getdate: while(ENDINPUT == NO) { /* FIELDNAME = mm */ /* VARTYPE = int */ getmm: row = 7; col = 23; IFLDLEN = 2; DFLDLEN = 0; BEGFLD = 23; ENDFLD = BEGFLD + 1; mvprintw(row,BEGFLD,"DATE "); BEGFLD += 5; standout(); mvprintw(row,BEGFLD,"MM"); mvprintw(row,BEGFLD+3,"DD"); mvprintw(row,BEGFLD+6,"YY"); standend(); mvprintw(row,BEGFLD+2,"-"); mvprintw(row,BEGFLD+5,"-"); col = BEGFLD; getfields(); if (ENDINPUT == YES) break; if (intnos[0] != '\0') mm = intnum; if (mm == 0 || mm>12 || mm<1) { beep(); col = BEGFLD; // (void) rangerr(); goto getmm; } // (void) rmerr(); mvprintw(row,BEGFLD,"%02d-",mm); refresh(); /* END FIELD */ /* FIELDNAME = dd */ /* VARTYPE = int */ getdd: IFLDLEN = 2; DFLDLEN = 0; BEGFLD += 3; col = BEGFLD; ENDFLD = BEGFLD + 1; getfields(); if (ENDINPUT == YES) break; if (intnos[0] != '\0') dd = intnum; if (dd == 0 || dd>31 || dd<1) { beep(); BEGFLD -= 3; // (void) rangerr(); goto getdd; } // (void) rmerr(); mvprintw(row,BEGFLD,"%02d-",dd); refresh(); /* END FIELD */ /* FIELDNAME = yy */ /* VARTYPE = int */ IFLDLEN = 2; DFLDLEN = 0; BEGFLD += 3; col = BEGFLD; ENDFLD = BEGFLD + 1; getfields(); if (ENDINPUT == YES) break; if (intnos[0] != '\0') yy = intnum; mvprintw(row,BEGFLD,"%02d",yy); refresh(); break; /* END FIELD */ } refresh(); /* END FIELD */ /* FIELDNAME = f */ /* VARTYPE = float */ ISFLOAT = YES; row = 8; col = 23; IFLDLEN = 7; DFLDLEN = 0; BEGFLD = 23; ENDFLD = 29; standout(); mvprintw(row,BEGFLD," "); standend(); getfields(); if(ENDINPUT == YES) endit(); if(intnos[0] != '\0') f = fnumb; mvprintw(row,BEGFLD," "); mvprintw(row,BEGFLD,"%f",f); refresh(); ISFLOAT = NO; /* END FIELD */ /* FIELDNAME = t */ /* VARTYPE = money */ ISMONY = YES; row = 9; col = 23; IFLDLEN = 10; DFLDLEN = 0; BEGFLD = 23; ENDFLD = 32; standout(); mvprintw(row,BEGFLD," "); standend(); IFLDLEN = 7; DFLDLEN = 2; DCOL = 31; mvprintw(row,(DCOL-1),"."); getfields(); if(ENDINPUT == YES) endit(); if(monamt != 0) t = monamt; mvprintw(row,BEGFLD," "); if(t != 0) mvprintw(row,BEGFLD,"%7d.%02d" ,idlr(t),icnt(t)); refresh(); ISMONY = NO; /* END FIELD */ /* FIELDNAME = code */ /* VARTYPE = int */ row = 10; col = 28; IFLDLEN = 9; DFLDLEN = 0; BEGFLD = 28; ENDFLD = 36; standout(); mvprintw(row,BEGFLD," "); standend(); getfields(); if(ENDINPUT == YES) endit(); if(intnos[0] != '\0') code = intnum; mvprintw(row,BEGFLD," "); mvprintw(row,BEGFLD,"%d",code); refresh(); /* END FIELD */ return(0); }