home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 48
/
048side1.d81
/
election
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
4KB
|
122 lines
100 gosub60100:print"[147]":rem title screen
110 rem save"0:elections",8
130 rem trap 700 :rem +4,c16,b128,c128
135 rem---main program
140 np=20:m=9:rem max positions,candidates/office
150 dim r$(np),mx(np),tc(np),n$(np,m),t2(np,m)
160 gosub 540:rem read in data
170 nv=1
180 print"[147] [154]voter #"nv:ef=0:print"":gosub 610:if ef goto 210
190 v=-1:gosub 230:rem voting
200 nv=nv+1:goto 180
210 v=0:gosub 230::rem print results
220 goto2000
225 rem---voting screen or results
226 rem if you have 'print using' you can make this nicer
230 for i=1 to np
233 ifnotvthenprint"[147]results[159]":goto238
235 print"[147]voting[159]"
238 printr$(i)
240 if v then print"[159]vote for"mx(i)
250 print
260 for j=1 to tc(i):print ""right$(" "+str$(j),2)" [154]"n$(i,j);
270 if not v then print t2(i,j)"votes";
280 print
285 next j
290 if v then gosub 360:if ef then return
300 if not v then gosub 320
310 next i:return
315 rem---any key; if you have 'get key' you can use this here
320 print:print"press any key";
330 poke198,.:rem empty keyboard queue
340 get i$:if i$=""goto 340:rem now wait for key to continue
350 return
355 rem---add point if legal vote
360 v$="":p=0
370 print"enter a number and return or push *"
380 print"for no vote. you can change your mind"
390 print"before pushing return.":rem message fits in 40columns
395 print"[158]press f7 to return to loadstar[145][145][145][145][145]"
400 ok=1:for k=1 to mx(i):rem get vote
410 if mx(i)>1 then print"[154]#"k;
420 print"[154]your vote: ";
430 ifok=1thenv$=v$+chr$(p+48)
440 get i$:if i$=""goto 440
445 ifi$="[136]"then2000
450 av=asc(i$):if av=42 then return
460 if av=13 then gosub1000:goto490
470 av=av-48:if av<1 or av>tc(i)goto 440
480 print i$" ";:p=av:goto 440
490 next k:return
495 rem---one vote only, check legal number
500 ok=-1:rem can't vote twice check
510 if v$=""then return
520 ok=1:for l=1 to len(v$)
525 if p=asc(mid$(v$,l,1))-48 then ok=0:print"error!"
530 next l:return
535 rem---build tables from data lines
540 np=0
550 read v$:if v$="*"then return:rem all data read in
560 np=np+1:r$(np)=v$:read mx(np)
570 m=0
580 read v$:ifv$="*"then tc(np)=m:goto 600:rem subgroup read in
590 m=m+1:n$(np,m)=v$:t2(np,m)=0:goto 580:rem loop for more in subgroup
600 goto 550:rem always loop till final *
605 rem---vote enable check, end voting day
610 z$="":q$="vote":rem enable voting by 4-letter code
615 print"[158]enter $ if the voting is over[145][145][145][145][145][145][145][145][145]"
620 print"[154]enter code to enable voting: [157][157][157]";:le=4:nu=1:al=1:gosub60500
640 ifc$="$"then ef=1:return:rem $quits all voting - you can change this
650 rem print c$;:rem enable for testing by removing 'rem'
655 if c$=q$ then print"[147]":return
660 print"[145]";:goto620
695 rem---stop disable ... you can do your own thing here
700 rem if er=30 then resume:rem stop key disable +4,c16,b128,c128
701 rem print"error" er,err$(er)" in line"el:end:rem +4,c16,b128,c128
709 rem---structure of data you can fill in
710 rem who,vote for how many,list of names,star,star at the end
720 data president,1
730 data pres1,pres2,pres3,"pres4, md",*
740 data vice president,1
750 data vp1,vp2,vp3,vp4,*
760 data secretary,1
770 data sec1,sec2,sec3,*
780 data treasurer,1
790 data treas1,treas2,treas3,treas4,treas5,*
800 data blackboard cleaner,3
810 data bc1,bc2,bc3,bc4,bc5,bc6,*
820 data *
830 rem----------------------------
1000 gosub 500:if ok then t2(i,p)=t2(i,p)+1:print"..."p:return
1010 k=k-1:return
2000 print:print:print"[158] return to loadstar? (y/n)"
2002 geta$:ifa$<>"y"anda$<>"n"then2002
2004 ifa$="n"thenrun
2010 open15,8,15,"r0:hello connect=hello connect":input#15,er%:close15
2020 ifer%<>63thenend
2040 load"hello connect",8
60100 poke53280,14:poke53281, 0:print"[147][142]";
60110 print"[153]loadstarpresents:"
60120 print"[150] "
60130 print" election "
60140 print" "
60150 print" by liz deal "
60160 print" "
60170 print" copyright 1988 "
60180 print" "
60190 print"[153]pressspacetocontinue"
60200 ifpeek(203)<>60then60200
60210 return
60500 c$="":poke198,.:print"[164]";
60510 fora=1tole+1
60520 geta$:ifa$=""then60520
60525 ifa$="$"then60595
60530 ifa$=chr$(13)thenprint"[157] ":return
60540 ifa$=chr$(20)anda>1thenprint"[157][157] [157][157][164]";:a=a-1:c$=left$(c$,a-1):goto60520
60550 if(a=le+1)then60520
60560 if(nu)and((a$>="0")and(a$<="9"))then60595
60570 if(al)and((a$>=" "anda$<="/")or(a$>=":"anda$<="z"))then60595
60580 if(al)thenif(a$>="[193]"anda$<="[218]")then60595
60590 goto60520
60595 print"[157]"a$;:poke212,.:print"[164]";:c$=c$+a$:next