program LPVOT(input,output); { Program to examine and modify a file in Database format} {Brian Gilmore May 1987} {October - amended for new database format} TYPE {$I lptype.pas} VAR x_now, x_party: integer; chng: boolean; {$i lpexti.pas} PROCEDURE set_at_spec; VAR k, n, attr: integer; BEGIN cursor(0,0); write('Set ONE attribute ONLY'); clear_from_line(1); show_attributes; attr := get_option(ord('a'), ord('m'), 1); cursor(0, 40); write('Setting [',attrn[attr],']'); Disp_Form; REPEAT clearline(23); cursor(23, 0); write('Enter first voter number (or EXIT to finish)'); n := getint(23, 45); if n > 0 then begin REPEAT seek(dbfile, n); disp_Voter(n); clearline(23); cursor(23, 0); write('[+] or [-] to set or not, or EXIT to finish'); REPEAT k := ord(get); UNTIL (k=22) or (k=28) or (k=27); if k = 22 then begin dbfile^.attr := dbfile^.attr + [attr]; put(dbfile); end; n := n+1; UNTIL k=27; end; UNTIL n < 0; clear_from_line(1); end; PROCEDURE set_attributes; VAR i,j, n: integer; BEGIN show_attributes; REPEAT n := get_option(ord('a'), ord('m'), 1); if (n=-1) and (final=13) then n := 0; if n > 0 then begin if dbfile^.attr * [n] <> [] then dbfile^.attr := dbfile^.attr - [n] else dbfile^.attr := dbfile^.attr + [n]; chng := true; end; clearline(23); if chng then print_attributes(17); UNTIL n <= 0; END; PROCEDURE Print_Party_options; VAR i,j: integer; s : string[15]; BEGIN cursor(0,67); if x_now = 0 then write('Current Vote') else write('Previous Vote'); FOR i := 0 to 8 do begin cursor(8+i,60); write(i:3,' ',party[i],' '); END; for i := 9 to 15 do begin cursor(8+i, 60); write(' '); end; END; PROCEDURE Get_Party; VAR i,j,n: integer; BEGIN REPEAT print_party_options; clearline(23); i := get_option(0, 8, 1); UNTIL i<9; {return gives -1 -> take no action} x_party := i; clearline(23); END; PROCEDURE Set_General(entry_type: integer); LABEL 1; VAR i,j,n, prev: integer; BEGIN n := 0; clear_from_line(1); cursor(0,0); writeln('Add Canvas Returns'); cursor(0,40); write('Press EXIT to finish'); Disp_Form; REPEAT prev := n; cursor(23,0); write('First Voter Number (EXIT to finish)?'); n := getint(23,36); if (n = -1) and (final=13) then n := 1; if final = 27 then n := 0; if n <= 0 then goto 1; REPEAT if n >= max_val then n := max_val-1; seek(dbfile,n); disp_Voter(n); chng := false; if entry_type <= 0 then begin get_party; if final = 27 then goto 1; if x_party >= 0 then begin write(scr_inv); if x_now = 0 then begin cvote := x_party; cursor(13, 19); end else begin pvote := x_party; cursor(14, 19); end; write(party[x_party], scr_nor); dbfile^.xvote := pvote*16+cvote; chng := true; end; end; if entry_type >= 0 then begin set_attributes; if final = 27 then goto 1; end; if chng then put(dbfile); n := n+1; UNTIL n = 0; 1:; UNTIL n <= 0; clear_from_line(1); END; PROCEDURE Set_Specific_Vote; VAR i,j,n, prev: integer; BEGIN cursor(0,0); writeln('Set Specific Party'); clear_from_line(1); get_party; n := 0; cursor(0, 20); write('Party:', party[x_party]); Disp_form; REPEAT clearline(23); prev := n; cursor(23,0); write('Give Voter Number (EXIT to finish)?'); n := getint(23,35); if (n=-1) and (final=13) then n := prev+1; if n > 0 then begin if n >= max_val then n := max_val-1; seek(dbfile, n); if x_now = 0 then cvote := x_party else pvote := x_party; dbfile^.xvote := pvote*16+cvote; disp_Voter(n); put(dbfile); end; UNTIL (n = 0) or (final=27); clearscreen; END; PROCEDURE this_or_previous; VAR i: integer; BEGIN mess[1].s := 'Set Current voting intentions '; mess[2].s := 'Set Previous voting intentions '; x_now := get_option(1, 2, 0)-1; END; PROCEDURE Add_Canvas; VAR i,j : integer; BEGIN REPEAT mess[0].s := 'Return to Main Menu '; mess[1].s := 'Set Voter intention & attributes '; mess[2].s := 'Set Voter intention '; mess[3].s := 'Set Attributes only '; mess[4].s := 'Set a series of one party only '; mess[5].s := 'Set a series of one attribute only '; i := get_option(0, 5, 0); CASE i of 0: ; 1: begin; this_or_previous; Set_General(0); end; 2: begin; this_or_previous; Set_General(-1); end; 3: Set_General(1); 4: begin; this_or_previous; Set_Specific_Vote; end; 5: set_at_spec; END; UNTIL i = 0; clear_from_line(1); END; PROCEDURE Dsp_Voter; VAR i, prev: integer; BEGIN clear_from_line(1); i := 0; Disp_Form; repeat clearline(23); prev := i; cursor(23,0); write('Voter number (EXIT to finish):'); i := getint(23, 30); if (i=-1) then begin if (final=13) or (final=30) then i:=prev+1 else if final = 31 then i := prev-1; end; if final = 27 then i:=0; if i > 0 then begin if i >= max_val then i := max_val-1; seek(dbfile, i); disp_Voter(i); end; until i = 0; END; PROCEDURE Main_menu; VAR i,j: integer; BEGIN set_viewport(1); REPEAT mess[0].s := 'Exit Program '; mess[1].s := 'Display Voter details '; mess[2].s := 'Add Canvas Returns '; mess[3].s := 'Select New Register '; j := get_option(0, 3, 0); CASE j of 0:; 1: Dsp_Voter; 2: Add_Canvas; 3: begin; Close_Register; Request_Register; end; end; clearscreen; UNTIL j = 0; END; BEGIN set_party; Ready_Keyboard; Request_Register; main_menu; reset_viewport; clearscreen; back_to_menu; END.