/*------------------------- DEMOFORM.C -------------------------*/ /* */ /* This file contains the VISIONS FORM LIBRARY DEMO software. */ /* */ /* Copyright 1990 Dan Vogel & David Bernazzani */ /* */ /* Date Initials Comments */ /* */ /* 03/07/90 DCV Initial Release 0.00 */ /*--------------------------------------------------------------*/ #include #include #include #include #include "USERFORM.H" #include "USERWIND.H" #include "DEMOPROT.H" LOCAL TEXT *cnotice="VISIONS Copyright 1990 Dan Vogel & David Bernazzani"; /*--------------------------------------------------------------*/ /*----------------------------------------------*/ /* Run_Form */ /* This is the form library demonstration code. */ /*----------------------------------------------*/ WORD Run_Form() { FORM_HEAD *entry_form; FORM_FIELD *field_ptr; TEXT name[35]; TEXT id_num[8]; TEXT addr1[35], addr2[35]; TEXT sex[2]; WORD result; /*-------------------------------------------------------------------*/ /* Define the basic form: location, border style, colors, and title. */ /*-------------------------------------------------------------------*/ Form_Define(&entry_form, (UBYTE)5, (UBYTE)5, (UBYTE)12, (UBYTE)70, TEXT_BLUE, TEXT_WHITE, "VISIONS Address Form", (BITS)(DOUBLE_BORDER_BIT | MOUSE_ENABLE_BIT)); /*------------------------------*/ /* Add a form record (field). */ /* This field allows any input. */ /*------------------------------*/ Form_Add(entry_form, NULL, &field_ptr); /*-------------------------------*/ /* Now fill in the record with a */ /* prompt and a text entry area. */ /* Both prompt and text areas */ /* have their own color specs. */ /*-------------------------------*/ Form_PromptAdd(field_ptr, (UBYTE)5, (UBYTE)8, (UBYTE)5, TEXT_BLUE,TEXT_WHITE,TEXT_WHITE,TEXT_BLUE,"Name:"); strcpy(name,""); /* Set the default value to NULL. */ Form_TextAdd(field_ptr, (UBYTE)5, (UBYTE)17, (UBYTE)34, TEXT_WHITE,TEXT_BLACK,TEXT_BLACK,TEXT_WHITE,name); /*------------------------------------*/ /* And create the rest of the fields. */ /*------------------------------------*/ Form_Add(entry_form, *IntOnly, &field_ptr); Form_PromptAdd(field_ptr, (UBYTE)6, (UBYTE)8, (UBYTE)7, TEXT_BLUE,TEXT_WHITE,TEXT_WHITE,TEXT_BLUE,"ID num:"); strcpy(id_num,""); Form_TextAdd(field_ptr, (UBYTE)6, (UBYTE)17, (UBYTE)7, TEXT_WHITE,TEXT_BLACK,TEXT_BLACK,TEXT_WHITE,id_num); Form_Add(entry_form, *MFOnly, &field_ptr); Form_PromptAdd(field_ptr, (UBYTE)7, (UBYTE)8, (UBYTE)4, TEXT_BLUE,TEXT_WHITE,TEXT_WHITE,TEXT_BLUE,"Sex:"); strcpy(sex,""); Form_TextAdd(field_ptr, (UBYTE)7, (UBYTE)17, (UBYTE)1, TEXT_WHITE,TEXT_BLACK,TEXT_BLACK,TEXT_WHITE,sex); Form_Add(entry_form, NULL, &field_ptr); Form_PromptAdd(field_ptr, (UBYTE)8, (UBYTE)8, (UBYTE)8, TEXT_BLUE,TEXT_WHITE,TEXT_WHITE,TEXT_BLUE,"Address:"); strcpy(addr1,""); /* Set the default value to NULL. */ Form_TextAdd(field_ptr, (UBYTE)8, (UBYTE)17, (UBYTE)34, TEXT_WHITE,TEXT_BLACK,TEXT_BLACK,TEXT_WHITE,addr1); /*------------------------------------------------------*/ /* Note that we could also add a field without either a */ /* prompt, by not calling Form_PromptAdd, or a prompt */ /* without an entry by not calling Form_TextAdd after */ /* the call to Form_Add! */ /*------------------------------------------------------*/ Form_Add(entry_form, NULL, &field_ptr); strcpy(addr2,""); /* Set the default value to NULL. */ Form_TextAdd(field_ptr, (UBYTE)9, (UBYTE)17, (UBYTE)34, TEXT_WHITE,TEXT_BLACK,TEXT_BLACK,TEXT_WHITE,addr2); Form_Add(entry_form, NULL, &field_ptr); Form_PromptAdd(field_ptr, (UBYTE)11, (UBYTE)3, (UBYTE)66, TEXT_BLUE,TEXT_WHITE,TEXT_WHITE,TEXT_BLUE, "Move between fields with arrows, ESC to abort, or Enter to finish."); /*----------------------------------------*/ /* Now execute each form, but allow the */ /* user to abort with an ESC at any time. */ /*----------------------------------------*/ result = Form_Entry(entry_form); Form_Delete(entry_form); /*Destroy the forms that were used. */ return(0); } /*-----------------------------------------------------------*/ /* IntOnly */ /* This is a field input validation routine. This routine */ /* requires that all input for its string field be integers. */ /* Leadings spaces are allowed. */ /*-----------------------------------------------------------*/ FLAG IntOnly(string) TEXT *string; { WORD leading_space = -1; /* Have not seen first digit. */ WORD i; for (i=0; i