void build_menu() { Preparat p; system("color 02"); menustart: system("cls"); printf("Alegeti optiunea:\n\n"); printf("1. Adauga element la inceputul listei.\n"); printf("2. Adauga element la sfarsitul listei.\n"); printf("3. Afiseaza lista din memorie.\n"); printf("4. Afiseaza lista din fisier.\n"); printf("5. Sterge un element din lista.\n"); printf("6. Incarca lista din fisier in memorie.\n"); printf("7. Sterge toate elementele listei din memorie.\n"); printf("8. Sorteaza elementele in fisier dupa metoda Shell.\n"); printf("9. Salveaza lista in fisier.\n"); printf("10. Modifica un element din lista.\n"); printf("11. Iesire din program.\n\n"); int option; scanf("%d", &option); system("cls"); switch (option) { case 1: printf("Nume preparat:"); scanf("%s", &p.nume); printf("Pret:"); scanf("%d", &p.pret); printf("Este nevoie de prescriptie medicala? (Da/Nu):"); scanf("%s", &p.pr_med); printf("Tip Preperat:"); scanf("%s", &p.tip); add_first(p); goto menustart; break; case 2: printf("Nume preparat:"); scanf("%s", &p.nume); printf("Pret:"); scanf("%d", &p.pret); printf("Este nevoie de prescriptie medicala? (Da/Nu):"); scanf("%s", &p.pr_med); printf("Tip Preperat:"); scanf("%s", &p.tip); add_last(p); goto menustart; break; case 3: display(0); getch(); goto menustart; break; case 4: display(1); getch(); goto menustart; break; case 5: printf("Indicati indexul elementului pentru a fi sters:"); int index; scanf("%d", &index); delete_at(index); getch(); goto menustart; break; case 6: read_from_file(); goto menustart; break; case 7: clear_list(); printf("Sters cu success!!"); getch(); goto menustart; break; case 8: file_shell_sort(); getch(); goto menustart; break; case 9: save_to_file(); goto menustart; break; case 10: printf("\nDati indexul elementului ce necesita modificare:"); int ind; scanf("%d", &ind); edit_at(ind); goto menustart; case 11: exit(0); break; default: printf("Optiune indicata gresit."); break; } }
void options_screen() { /* options are */ /* 17 Lines -7 -1025 0 New Progs ON OFF SAME 1 New Accs ON OFF SAME 2 Auto Window PAGING SCROLLING 3 Accs Window PAGING SCROLLING 4 Sets Window PAGING SCROLLING 5 Other Window PAGING SCROLLING 6 Auto Path -------------------------------------- 7 Accs Path -------------------------------------- 8 <Set Keys> 9 <Resolution Info> 10 [ OK ] 11[ CANCEL ] 12[ SAVE ] */ #define MAX_OPTIONS 12 int options_y, options_x, curr_option, old_option, exit_options; long key; int upk,lowk; /*char temp[60]; */ /* local defaults */ int lnew_progs_flag; /* 1 = ON, 2 = OFF, 3 = SAME */ int lnew_accs_flag; int lauto_paging; /* 1 = paging, 2 = scrolling */ int laccs_paging; int lsets_paging; int lother_paging; char lauto_path[FILENAME_MAX]; char laccs_path[FILENAME_MAX]; curr_option=0; old_option=11; lnew_progs_flag=prog_defaults.new_progs_flag; lnew_accs_flag=prog_defaults.new_accs_flag; lauto_paging=prog_defaults.auto_paging; laccs_paging=prog_defaults.accs_paging; lsets_paging=prog_defaults.sets_paging; lother_paging=prog_defaults.other_paging; strcpy(lauto_path,prog_defaults.auto_path); strcpy(laccs_path,prog_defaults.accs_path); options_y=prog_defaults.rows-3-17+1; if(options_y>0) options_y=options_y/2; else options_y=1; options_x=prog_defaults.columns-40; if(options_x>0) options_x=options_x/2; else options_x=0; CLEAR_SCREEN centre_text("OPTIONS",line_buffer,prog_defaults.columns,' '); DISCARD_EOL AT(title_row,0) REVERSE_VIDEO printf("%s",line_buffer); NORMAL_VIDEO options_bottom_title(); AT(options_y,options_x+1) printf("New Progs"); print_on_off_same(options_y,options_x+1,lnew_progs_flag); AT(options_y+1,options_x+1) printf("New Accs"); print_on_off_same(options_y+1,options_x+1,lnew_accs_flag); AT(options_y+3,options_x+1) printf("Auto Window"); print_paging_scrolling(options_y+3,options_x+1,lauto_paging); AT(options_y+4,options_x+1) printf("Accs Window"); print_paging_scrolling(options_y+4,options_x+1,laccs_paging); AT(options_y+5,options_x+1) printf("Sets Window"); print_paging_scrolling(options_y+5,options_x+1,lsets_paging); AT(options_y+6,options_x+1) printf("Other Window"); print_paging_scrolling(options_y+6,options_x+1,lother_paging); remove_extension(lauto_path); AT(options_y+8,options_x+1) printf("Auto Path"); /* AT(options_y+9,options_x+1) printf("--------------------------------------"); */ AT(options_y+9,options_x+1) printf("%s",lauto_path); remove_extension(laccs_path); AT(options_y+11,options_x+1) printf("Accs Path"); /* AT(options_y+12,options_x+1) printf("--------------------------------------"); */ AT(options_y+12,options_x+1) printf("%s",laccs_path); AT(options_y+14,options_x+1) printf("<Set Keys>"); AT(options_y+14,options_x+22) printf("<Resolution Info>"); AT(options_y+16,options_x+3) printf("[ OK ]"); AT(options_y+16,options_x+15) printf("[ CANCEL ]"); AT(options_y+16,options_x+27) printf("[ SAVE ]"); upk=0;lowk=0;exit_options=0; print_option(options_y,options_x,old_option, curr_option); while(exit_options==0) { while(!Bconstat(2)) ; key=Bconin(2); upk=(int)(key>>16); lowk=(int)(key%256); if(upk==0x48 ) /* up arrow */ { old_option=curr_option; switch(curr_option) { case 11: case 10: curr_option=8; break; case 12: curr_option=9; break; case 9: curr_option=7; break; default: curr_option=curr_option-1; break; } if(curr_option<0) curr_option=MAX_OPTIONS; print_option(options_y,options_x,old_option, curr_option); } else { if(upk==0x50) /* down arrow */ { old_option=curr_option; switch(curr_option) { case 8: curr_option=10; break; case 9: curr_option =12; break; case 10: case 11: case 12: curr_option=0; break; default: curr_option=curr_option+1; break; } if(curr_option>MAX_OPTIONS) curr_option=0; print_option(options_y,options_x,old_option, curr_option); } else { if(upk==0x4D) /* right arrow */ { old_option=curr_option; switch(curr_option) { case 0: lnew_progs_flag++; if(lnew_progs_flag>3) lnew_progs_flag=1; print_on_off_same(options_y,options_x+1,lnew_progs_flag); break; case 1: lnew_accs_flag++; if(lnew_accs_flag>3) lnew_accs_flag=1; print_on_off_same(options_y+1,options_x+1,lnew_accs_flag); break; case 2: lauto_paging++; if(lauto_paging>SCROLLING) lauto_paging=PAGING; print_paging_scrolling(options_y+3,options_x+1,lauto_paging); break; case 3: laccs_paging++; if(laccs_paging>SCROLLING) laccs_paging=PAGING; print_paging_scrolling(options_y+4,options_x+1,laccs_paging); break; case 4: lsets_paging++; if(lsets_paging>SCROLLING) lsets_paging=PAGING; print_paging_scrolling(options_y+5,options_x+1,lsets_paging); break; case 5: lother_paging++; if(lother_paging>SCROLLING) lother_paging=PAGING; print_paging_scrolling(options_y+6,options_x+1,lother_paging); break; case 8: case 10: case 11: curr_option++; break; } if(curr_option>MAX_OPTIONS) curr_option=0; print_option(options_y,options_x,old_option, curr_option); } else { if(upk==0x4B) /* left arrow */ { old_option=curr_option; switch(curr_option) { case 0: lnew_progs_flag--; if(lnew_progs_flag<1) lnew_progs_flag=3; print_on_off_same(options_y,options_x+1,lnew_progs_flag); break; case 1: lnew_accs_flag--; if(lnew_accs_flag<1) lnew_accs_flag=3; print_on_off_same(options_y+1,options_x+1,lnew_accs_flag); break; case 2: lauto_paging--; if(lauto_paging<PAGING) lauto_paging=SCROLLING; print_paging_scrolling(options_y+3,options_x+1,lauto_paging); break; case 3: laccs_paging--; if(laccs_paging<PAGING) laccs_paging=SCROLLING; print_paging_scrolling(options_y+4,options_x+1,laccs_paging); break; case 4: lsets_paging--; if(lsets_paging<PAGING) lsets_paging=SCROLLING; print_paging_scrolling(options_y+5,options_x+1,lsets_paging); break; case 5: lother_paging--; if(lother_paging<PAGING) lother_paging=SCROLLING; print_paging_scrolling(options_y+6,options_x+1,lother_paging); break; case 9: case 11: case 12: curr_option--; break; } if(curr_option<0) curr_option=MAX_OPTIONS; print_option(options_y,options_x,old_option, curr_option); } else { if(upk==0x1C) /* return */ { switch(curr_option) { case 6: edit_at(options_y+9,options_x+1,FILENAME_MAX,37,lauto_path,'-',0,valid_filename_char,1); options_bottom_title(); break; case 7: edit_at(options_y+12,options_x+1,FILENAME_MAX,37,laccs_path,'-',0,valid_filename_char,1); options_bottom_title(); break; case 8: /* set keys */ break; case 9: /* set res stuff */ break; case 10: /* set defaults */ prog_defaults.new_progs_flag=lnew_progs_flag; prog_defaults.new_accs_flag=lnew_accs_flag; prog_defaults.auto_paging=lauto_paging; prog_defaults.accs_paging=laccs_paging; prog_defaults.sets_paging=lsets_paging; prog_defaults.other_paging=lother_paging; strcpy(prog_defaults.auto_path,lauto_path); strcpy(prog_defaults.accs_path,laccs_path); exit_options=1; break; case 11: exit_options=1; break; case 12: /* save defaults */ break; } } else { if(upk==prog_defaults.toggle_key_high) { switch(curr_option) { case 0: lnew_progs_flag++; if(lnew_progs_flag>3) lnew_progs_flag=1; print_on_off_same(options_y,options_x+1,lnew_progs_flag); break; case 1: lnew_accs_flag++; if(lnew_accs_flag>3) lnew_accs_flag=1; print_on_off_same(options_y+1,options_x+1,lnew_accs_flag); break; case 2: lauto_paging++; if(lauto_paging>SCROLLING) lauto_paging=PAGING; print_paging_scrolling(options_y+3,options_x+1,lauto_paging); break; case 3: laccs_paging++; if(laccs_paging>SCROLLING) laccs_paging=PAGING; print_paging_scrolling(options_y+4,options_x+1,laccs_paging); break; case 4: lsets_paging++; if(lsets_paging>SCROLLING) lsets_paging=PAGING; print_paging_scrolling(options_y+5,options_x+1,lsets_paging); break; case 5: lother_paging++; if(lother_paging>SCROLLING) lother_paging=PAGING; print_paging_scrolling(options_y+6,options_x+1,lother_paging); break; } } } } } } } } }