void listar(){ char op; clrscr(); linha(1); linha(3); center("Listagem",2); fcliente = fopen("clientes.dat","r"); rewind(fcliente); do{ fread(&cliente, sizeof(cliente),1,fcliente); gotoxy(3,6); clreol(); cout<<"Cliente: "<<cliente.nome; gotoxy(3,7); clreol(); cout<<"Endere‡o: "<<cliente.endereco; gotoxy(3,8); clreol(); cout<<"Idade: "<<cliente.idade; linha(22); linha(24); center("<P> para Ver o Pr¢ximo Cadastro :: <M> para Voltar ao Menu Principal",23); op = getch(); op = toupper(op);} while(!feof(fcliente) || (op == 'M')); fclose(fcliente); linha(22); linha(24); gotoxy(1,23); clreol(); center("Pressione Alguma Tecla para Voltar ao Menu Principal",23); getch(); menu();}
/* * Erase to end of page. */ tteeop() { #ifdef TCCONIO ttflush(); clreol(); { register int line; for (line = ttrow + 1; line <= nrow; ++line) { gotoxy(1,line+1); clreol(); } ttrow = ttcol = HUGE; } #else if(CD) putpad(CD, nrow - ttrow); else { tteeol(); if (insdel) ttdell(ttrow + 1, LI, LI - ttrow - 1); else /* do it by hand */ { register int line; for (line = ttrow + 1; line <= LI; ++line) { ttmove(line, 0); tteeol(); } } ttrow = ttcol = HUGE; } #endif }
void _pascal import(LINE * l) { char line[TEXTLEN]; FILE *fp; static char fn[PATHLEN]; LINE *n; memset(line, 0, sizeof(line)); gotoxy(9, 1); clreol(); set_color(colors.info); bputs("File to import? "); bgets(fn, PATHLEN,PATHLEN); set_color(colors.normal); if ((fp = fopen(fn, "rt")) != NULL) { while (fgets(line, TEXTLEN, fp) != NULL) { if (l->text != NULL) { if ((n = (LINE *) calloc(1, sizeof(LINE))) == NULL) { gotoxy(9, 1); clreol(); bputs("Not enough memory, press any key"); getkey(); showheader(message); return; } n->next = l->next; if (n->next != NULL) n->next->prev = n; n->prev = l; l->next = n; l = n; } else n = l; n->text = strdup(line); if (strlen(n->text) > (size_t) rm) { l = n->next; wrap(n,maxx,maxy); if (l == NULL) while (n->next) n = n->next; else n = l->prev; l = n; } memset(line, 0, sizeof(line)); } fclose(fp); } showheader(message); }
void clear_to_eol(void) { #if defined(__TS_LINUX__) clrtoeol(); #elif defined(__TS_DOS__) clreol(); #elif defined(__WINDOWS__) clreol(); #else # error Please define 'clear_to_eol' for your target system. #endif }
void con_ce( int attr ) { if (attr != -1) { int ta = __ta; textattr( attr ); clreol(); textattr( ta ); } else clreol(); }
void food :: delete_item(void) { clrscr() ; char t_code[5], ch ; int t, tcode ; gotoxy(3,25) ; cout <<"Press <ENTER> to see the list" ; gotoxy(5,3) ; cout <<"Enter Item Code of the item to be deleted : " ; gets(t_code) ; t = atoi(t_code) ; tcode = t ; if (t_code[0] == '0') return ; if (tcode == 0) { list_of_item() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"Press <ENTER> to Exit" ; gotoxy(5,24) ; cout <<"Enter Item Code of the item to be deleted : " ; gets(t_code) ; t = atoi(t_code) ; tcode = t ; if (tcode == 0) return ; } clrscr() ; if (!item_found(tcode)) { gotoxy(5,5) ; cout <<"\7Record not found" ; getch() ; return ; } display_record(tcode) ; do { gotoxy(1,8) ; clreol() ; gotoxy(5,8) ; cout <<"Do you want to delete this record (y/n) : " ; ch = getche() ; ch = toupper(ch) ; } while (ch != 'N' && ch != 'Y') ; if (ch == 'N') return ; delete_record(tcode) ; gotoxy(5,15) ; cout <<"\7Record Deleted" ; getch() ; }
void warning( // show warning BOOL fullscreen, // fullscreen mode int result // return code ) { char *s; if (fullscreen) gotoxy(1, 20); printfw(err2msg(result)); clreol(); s = strdup(pclGetErrorString()); if (s[0] != '\0') s[strlen(s) - 1] = '\0'; printfw("\n%s", s); clreol(); free(s); }
void msg_print(char* str_buff){ register int old_len; char in_char; if(msg_flag){ old_len=strlen(old_msg[last_msg])+1; if (old_len>MSG_LEN) old_len=MSG_LEN; put_buffer("-more-",MSG_LINE, old_len); wait_for_more=1; do{ in_char=inkey(); }while((in_char!=' ')&&(in_char!=ESCAPE)&&(in_char!='\n')&& (in_char!='\r')); wait_for_more=0; } gotoxy(1,MSG_LINE+1); clreol(); if(str_buff){ put_buffer(str_buff,MSG_LINE,0); command_count=0; if(++last_msg>=MAX_SAVE_MSG) last_msg=0; strncpy(old_msg[last_msg],str_buff,VTYPESIZ); old_msg[last_msg][VTYPESIZ-1]='\0'; msg_flag=TRUE; }else msg_flag=FALSE; }
void ler(){ gotoxy(5,23); clreol(); printf("Entre com N1: "); scanf("%f",&n1); gotoxy(40,23); printf("Entre com N2: "); scanf("%f",&n2); menu();}
void somar(){ gotoxy(15,23); clreol(); res = n1 + n2; textcolor(15); printf("A soma dos valores n1= %2.2f e n2= %2.2f eh: %2.2f", n1, n2, res); getch(); menu();}
void Item :: createFile() { ofstream outFile; char ch; outFile.open("ITEM.DAT",ios::binary); do { clrBox(34,8,70,23); whiteColor(); drawBoxTwo(34,11,70,23); gotoxy(46,9); headingColor(); cprintf("STOCK CREATION"); lightcyanColor(); a.getRecord(); outFile.write( (char*)&a,sizeof(a) ); whiteColor(); drawBox(35,20,69,22); gotoxy(37,21); textcolor(YELLOW+BLINK); cprintf("Record is successfully inserted"); gotoxy(37,24); yellowColor(); cprintf("Do you want to continue (Y/N) ? "); cin >>ch; ch=toupper(ch); gotoxy(37,24); clreol(); } while ( ch=='Y'); outFile.close(); }
void show_note(char * prp) { gotoxy(17+ALT, y1); cputs(prp); clreol(); flag[NTS]++; }
/* ewb and y correct */ void show_scr(int fr,int to) { char *s=ewb; int len=sww-1, i=fr; unsigned xl=xtru-x; /* calculate s */ for(; i<y; i++) while(*--s != EOL) ; for(; i>y; i--) while(*++s != EOL) ; /* first line */ s++; do { gotoxy(1, fr+y2); if(s<ae && strlen(s) > xl) show_rest(len, s+xl); else clreol(); while(*s++) ; } while(++fr <= to); }
void prt(char* str_buff,int row, int col){ if (row==MSG_LINE&&msg_flag) msg_print(NULL); gotoxy(col+1,row+1); clreol(); put_buffer(str_buff,row,col); }
void mprintf( char *format, ... ) { static linecount = 1; char buffer[ 512 ]; char *s, *p, pchar; va_list *argptr; va_start( argptr, format ); vsprintf( s = buffer, format, argptr ); va_end( argptr ); do { if ( (p = strchr( s, '\n' )) != NULL ) { pchar = *(++p); *p = 0; } fputs( s , stdout ); if ( (s = p) != NULL ) { *s = pchar; if (++linecount == 24 ) { fputs( "<press any key to continue>", stdout); getch(); fputs("\r\r", stdout); clreol(); linecount = 1; } } } while ( s ); }
static inline void D_Titlebar(char *title1, char *title2) { // SRB2 banner clrscr(); textattr((BLUE<<4)+WHITE); clreol(); cputs(title1); // standard srb2 banner textattr((RED<<4)+WHITE); clreol(); gotoxy((80-strlen(title2))/2, 2); cputs(title2); normvideo(); gotoxy(1,3); }
void cadastrar(){ char op; int tamanho; clrscr(); linha(1); linha(3); center("Cadastro",2); fcliente = fopen("clientes.dat","r+"); rewind (fcliente);// rewind aponta para a primeira posi‡Æo do{ fread(& cliente, sizeof(cliente),1,fcliente); tamanho++;} while (!feof(fcliente)); fseek(fcliente,sizeof(cliente), tamanho); // fseek aponta para a posi‡Æo tamanho do arquivo cliente do { gotoxy(3,5); clreol(); cout<<"Nome do Cliente: "; cin>>cliente.nome; /* gets lˆ apenas string que ‚ um conjunto de char getch lˆ apenas um caractere ambos nƒo mostram no v¡deo o que foi digitado, getche grava um caracter e mostra no v¡deo */ gotoxy(3,6); clreol(); cout<<"Endere‡o do Cliente: "; cin>>cliente.endereco; gotoxy(3,7); clreol(); cout<<"Idade do Cliente: "; cin>>cliente.idade; // comandos de entrada em c++ sÆo substitu¡dos por cin<< // comandos de sa¡da sÆo substitu¡dos por cout<< tamanho = tamanho + fwrite(& cliente, sizeof(cliente),1,fcliente); linha(22); linha(24); center("Deseja Cadastrar Novamente <S/N>", 23); cin>>"op"; op = toupper(op);} while (op == 'N'); fclose(fcliente); linha(22); linha(24); center("Pressione Alguma Tecla para Voltar ao Menu Principal",23); getch(); menu();}
void CASSETTE :: DELETION(void) { MENU menu ; char t1[10], ch, filename[13] ; int t2, cascode, valid ; strcpy(filename,menu.CHOICE_MENU()) ; if (!strcmpi(filename,"FAILED")) return ; do { valid = 1 ; do { clrscr() ; gotoxy(72,2) ; cout <<"<0>=EXIT" ; gotoxy(5,5) ; cout <<"Enter code of the Cassette or <ENTER> for help " ; gets(t1) ; t2 = atoi(t1) ; cascode = t2 ; if (cascode == 0 && strlen(t1) != 0) return ; if (strlen(t1) == 0) DISPLAY_LIST(filename) ; } while (strlen(t1) == 0) ; if (!FOUND_CODE(filename,cascode)) { valid = 0 ; gotoxy(5,20) ; cout <<"\7Cassette code not found." ; getch() ; } } while (!valid) ; clrscr() ; gotoxy(72,1) ; cout <<"<0>=EXIT" ; DISPLAY_RECORD(filename,cascode) ; do { gotoxy(5,12) ; clreol() ; cout <<"Delete this Cassette Record (y/n) " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ; } while (ch != 'Y' && ch != 'N') ; if (ch == 'N') return ; DELETE_RECORD(filename,cascode) ; gotoxy(5,20) ; cout <<"\7Record Deleted" ; gotoxy(5,25) ; cout <<"Press any key to continue..." ; getch() ; }
void Add(void){ char opt; fa=fopen("acc.dat","ab"); clrscr(); Temp1(); gotoxy(19,8); scanf(" "); gets(rec.rno); gotoxy(19,10); scanf(" "); gets(rec.nm); gotoxy(19,12); scanf(" "); gets(rec.snm); gotoxy(19,14); rec.mi=getche(); rec.mi=toupper(record.mi); gotoxy(19,16); rec.ccode=getche(); rec.ccode=toupper(rec.ccode); gotoxy(5,22); clreol(); printxy(79,22,"º"); fprintf(fp,"%s %s %s %c%c",rec.snum,rec.fname,rec.sname,rec.mi,rec.ccode); gotoxy(5,21); clreol(); center(21,"Record successfully added!"); printxy(79,21,"º"); gotoxy(53,22); delay(1000); center(22,"Press any key to go to main menu..."); getch(); fclose(fa); }
static JSBool js_conio_clreol(JSContext *cx, uintN argc, jsval *arglist) { jsrefcount rc; rc=JS_SUSPENDREQUEST(cx); clreol(); JS_SET_RVAL(cx, arglist, JSVAL_TRUE); JS_RESUMEREQUEST(cx, rc); return(JS_TRUE); }
int mprint(int x, int y, char *format, ...) { int n; WaitSem(dos, 1); gotoxy(x, y); n = vprintf(format, ...); clreol(); SignalSem(dos, 1); return n; }
trace_stack (struct print_param *p) { int l, i; char buf[10]; return 0; gotoxy (1, 1); print_strint (p, "%d levels", sp); clreol (); print_string (p, "\n"); clreol (); for (l=((sp<=4)?0:(sp-4)); l<sp; l++) /* for (l=0; (sp<=5)?(l<sp):(l<5); l++) */ { print_strint (p, "\nLevel %d : ", l); print_string (p, stack[l].fnc); for (i=0; i<3; i++) { clreol (); if (stack[l].arg[i] != NULL) { print_strint (p, "\n\targ%d = ", i); print_dem (p, stack[l].arg[i]); } clreol (); } print_string (p, "\n"); clreol (); } print_string (p, "*******\n"); clreol (); /* gets (buf); */ }
/* * Erase to end of line. */ tteeol() { #ifdef TCCONIO ttflush(); clreol(); #else if(CE) putpad(CE, 1); else { register int i=ncol-ttcol; while(i--) ttputc(' '); ttrow = ttcol = HUGE; } #endif }
char *newFile(void) { static char fname[FNSIZE]; int c; gotoxy(1,25); textcolor(mcolor); textbackground(mbgrd); clreol(); fname[0] = FNSIZE; cprintf("Enter file: "); return cgets(fname); }
void message(char mess[80]) { int l,d; l=strlen(mess); d=l/2; gotoxy(2,24); textcolor(WHITE+BLINK); textbackground(BLACK); cprintf(" "); gotoxy(40-d,24); clreol(); cprintf("%s",mess); textcolor(BLACK); textbackground(WHITE); }
/*------------------------------------------------------------------------*/ int choosekey(char *title,int oldval) { char msg[80]; int lastkey; int newval; int bad; clrscr(); sprintf(msg,"Press key for %s",title); gotoxy((78-strlen(msg))/2,8); cputs(msg); gotoxy(34,9); cputs("(ESC=none)"); sprintf(msg,"Current setting: %s",keynames[oldval]); gotoxy((78-strlen(msg))/2,11); cputs(msg); while (kbhit()); key_init(); do{ while (hi==lo); lastkey=buffer[lo++]; if (lo==100) lo=0; /*do not allow F1-F12, Pause, PrintScreen or Scrollock */ bad=(lastkey>=59 && lastkey<=68) || lastkey==87 || lastkey==88 || lastkey==167 || lastkey==183 || lastkey==70 || lastkey==197; }while ((lastkey&0xff00) || *keynames[lastkey&0xff]=='?' || *keynames[lastkey&0xff]=='#' || bad); newval=lastkey&0xff; if (newval==1) newval=255; sprintf(msg,"Current setting: %s",keynames[newval]); gotoxy(1,11); clreol(); gotoxy((78-strlen(msg))/2,11); cputs(msg); /*wait until key is depressed*/ do{ while (hi==lo); lastkey=buffer[lo++]; if (lo==100) lo=0; }while(!(lastkey&0xff00)); key_done(); return newval; }
void game() { textbackground(GREEN); textcolor(WHITE); clrscr(); sum=0; cout<<endl<<"\t\t\t ~'~'~'~'~'~'~'~'~`~'~'~'~"<<endl; cout<<"\t\t\t | TIC TAC TOE |"<<endl; cout<<"\t\t\t ~'~'~'~'~'~'~'~'~`~'~'~'~"<<endl; textcolor(RED); clreol(); cout<<"\t\t\t enter -1 to go to menu"<<endl; // cout<<"\t\t\t --------------------------"; cout<<endl<<endl; for(i=0;i<3;++i) for(j=0;j<3;++j) tic[i][j]=' '; //assigning space' 'to all elements of the matrix display(); //display function call cout<<endl<<endl; user(); }
int screen(void) { char scrn[80*25*2]; static char *mess="V.9.t.9. .ù. ."; int count; char *ptr,*eptr; static char *footer="Arrows: Move <Space>: Tag/Untag <F1>: Default <Enter>: Save <Esc>: Abort"; for (count=1; count<strlen(mess); count+=2) mess[count]=BLUE*16+LIGHTBLUE; ptr=mess; eptr=mess+strlen(mess); for (count=0; count<80*25*2; count++) { scrn[count]=*ptr++; if (ptr>=eptr) ptr=mess; } textmode(C80); window(1,1,80,25); textbackground(LIGHTGRAY); textcolor(WHITE); puttext(1,1,80,25,scrn); textbackground(LIGHTGRAY); textcolor(BLACK); gotoxy(1,25); for (count=0; count<40-strlen(footer)/2; count++) cprintf(" "); cprintf(footer); clreol(); return 1; }
/*Function for modifying a customer record*/ void account::modify() { char ch; long input_no; int flag=0; fstream fptr1,fptr2; fptr1.open("db.dat",ios::in); if(fptr1.fail()) { cout<<"Cannot open the db.dat file!"; getch(); return; } fptr2.open("dbtemp.dat",ios::out); if(fptr2.fail()) { cout<<"Cannot open the dbtemp.dat file!"; getch(); return; } clrscr(); gotoxy(20,3); cout<<"Enter the phone no whose record is to be modified:"; cin>>input_no; while(fptr1.read((char*)this,sizeof(obj))) { if(input_no==phone_no) { flag=1; gotoxy(20,5); cout<<"Name:"<<name; gotoxy(20,6); cout<<"Address:"<<address; gotoxy(20,7); cout<<"Account no:"<<acc_no; gotoxy(20,10); cout<<"Modify this customer's record(Y/N)"; ch=getch(); ch=toupper(ch); if(ch=='Y') { gotoxy(20,14); cout<<"Enter the customer's modified details.."; while(1) { gotoxy(20,16); cout<<"Name:"; gets(name); if(strlen(name)==0) { gotoxy(30,24); clreol(); cout<<"Name cannot be left blank!"; } else { gotoxy(30,24); clreol(); break; } } while(1) { gotoxy(20,18); cout<<"Address:"; gets(address); if(strlen(address)==0) { gotoxy(30,24); clreol(); cout<<"Address cannot be left blank!"; } else { gotoxy(30,24); clreol(); break; } } while(1) { gotoxy(20,20); cout<<"Phone no.:"; cin>>phone_no; if((numdigits(phone_no))!=7) { gotoxy(44,20); clreol(); gotoxy(30,24); clreol(); cout<<"Phone no. should be of seven digits!"; } else { gotoxy(30,24); clreol(); break; } } while(1) { gotoxy(20,22); cout<<"Account no.:"; cin>>acc_no; if((numdigits(acc_no))!=5) { gotoxy(44,22); clreol(); gotoxy(30,24); clreol(); cout<<"Account no. should be of five digits!"; } else { gotoxy(30,24); clreol(); break; } } } }
/*Function adding a customer*/ void account::add() { char ch1; fstream fptr; fptr.open("db.dat",ios::app); if(fptr.fail()) { cout<<"Cannot open file db.bat file!"; getch(); return; } clrscr(); gotoxy(30,5); cout<<"Enter new customer's details.."; while(1) { gotoxy(30,8); cout<<"Name:"; gets(name); if(strlen(name)==0) { gotoxy(30,24); clreol(); cout<<"Name cannot be left blank!"; } else { gotoxy(30,30); clreol(); break; } } while(1) { gotoxy(30,10); cout<<"Address:"; gets(address); if(strlen(address)==0) { gotoxy(30,24); clreol(); cout<<"Address cannot be left blank!"; } else { gotoxy(30,24); clreol(); break; } } while(1) { gotoxy(30,12); cout<<"Phone no.:"; cin>>phone_no; if((numdigits(phone_no))!=7) { gotoxy(54,12); clreol(); gotoxy(30,24); clreol(); cout<<"Phone no. should be of seven digits!"; } else { gotoxy(30,24); clreol(); break; } } while(1) { gotoxy(30,14); cout<<"Account no.:"; cin>>acc_no; if((numdigits(acc_no))!=5) { gotoxy(54,14); clreol(); gotoxy(30,24); clreol(); cout<<"Account no. should be of five digits!"; } else { gotoxy(30,24); clreol(); break; } } gotoxy(30,24); cout<<"`S'ave and exit"; gotoxy(30,25); cout<<"`E'xit without saving"; ch1=getch(); ch1=toupper(ch1); switch(ch1) { case('S'): fptr.write((char*)this,sizeof(obj)); fptr.close(); return; case('E'): fptr.close(); return; } getch(); }//End of add()