home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 48 / 048side1.d81 / election (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  4KB  |  122 lines

  1. 100 gosub60100:print"[147]":rem  title screen
  2. 110 rem save"0:elections",8
  3. 130 rem trap 700 :rem +4,c16,b128,c128
  4. 135 rem---main program
  5. 140 np=20:m=9:rem max positions,candidates/office
  6. 150 dim r$(np),mx(np),tc(np),n$(np,m),t2(np,m)
  7. 160 gosub 540:rem read in data
  8. 170 nv=1
  9. 180 print"[147]             [154]voter #"nv:ef=0:print"":gosub 610:if ef goto 210
  10. 190 v=-1:gosub 230:rem voting
  11. 200 nv=nv+1:goto 180
  12. 210 v=0:gosub 230::rem print results
  13. 220 goto2000
  14. 225 rem---voting screen or results
  15. 226 rem   if you have 'print using' you can make this nicer
  16. 230 for i=1 to np
  17. 233 ifnotvthenprint"[147]results[159]":goto238
  18. 235 print"[147]voting[159]"
  19. 238 printr$(i)
  20. 240 if v then print"[159]vote for"mx(i)
  21. 250 print
  22. 260 for j=1 to tc(i):print ""right$("  "+str$(j),2)" [154]"n$(i,j);
  23. 270 if not v then print t2(i,j)"votes";
  24. 280 print
  25. 285 next j
  26. 290 if v then gosub 360:if ef then return
  27. 300 if not v then gosub 320
  28. 310 next i:return
  29. 315 rem---any key; if you have 'get key' you can use this here
  30. 320 print:print"press any key";
  31. 330 poke198,.:rem empty keyboard queue
  32. 340 get i$:if i$=""goto 340:rem now wait for key to continue
  33. 350 return
  34. 355 rem---add point if legal vote
  35. 360 v$="":p=0
  36. 370 print"enter a number and return or push *"
  37. 380 print"for no vote.  you can change your mind"
  38. 390 print"before pushing return.":rem message fits in 40columns
  39. 395 print"[158]press f7 to return to loadstar[145][145][145][145][145]"
  40. 400 ok=1:for k=1 to mx(i):rem get vote
  41. 410 if mx(i)>1 then print"[154]#"k;
  42. 420 print"[154]your vote: ";
  43. 430 ifok=1thenv$=v$+chr$(p+48)
  44. 440 get i$:if i$=""goto 440
  45. 445 ifi$="[136]"then2000
  46. 450 av=asc(i$):if av=42 then return
  47. 460 if av=13 then gosub1000:goto490
  48. 470 av=av-48:if av<1 or av>tc(i)goto 440
  49. 480 print i$" ";:p=av:goto 440
  50. 490 next k:return
  51. 495 rem---one vote only, check legal number
  52. 500 ok=-1:rem can't vote twice check
  53. 510 if v$=""then return
  54. 520 ok=1:for l=1 to len(v$)
  55. 525 if p=asc(mid$(v$,l,1))-48 then ok=0:print"error!"
  56. 530 next l:return
  57. 535 rem---build tables from data lines
  58. 540 np=0
  59. 550 read v$:if v$="*"then return:rem all data read in
  60. 560 np=np+1:r$(np)=v$:read mx(np)
  61. 570 m=0
  62. 580 read v$:ifv$="*"then tc(np)=m:goto 600:rem subgroup read in
  63. 590 m=m+1:n$(np,m)=v$:t2(np,m)=0:goto 580:rem loop for more in subgroup
  64. 600 goto 550:rem always loop till final *
  65. 605 rem---vote enable check, end voting day
  66. 610 z$="":q$="vote":rem enable voting by 4-letter code
  67. 615 print"[158]enter $ if the voting is over[145][145][145][145][145][145][145][145][145]"
  68. 620 print"[154]enter code to enable voting:   [157][157][157]";:le=4:nu=1:al=1:gosub60500
  69. 640 ifc$="$"then ef=1:return:rem $quits all voting - you can change this
  70. 650 rem print c$;:rem enable for testing by removing 'rem'
  71. 655 if c$=q$ then print"[147]":return
  72. 660 print"[145]";:goto620
  73. 695 rem---stop disable ... you can do your own thing here
  74. 700 rem if er=30 then resume:rem stop key disable +4,c16,b128,c128
  75. 701 rem print"error" er,err$(er)" in line"el:end:rem +4,c16,b128,c128
  76. 709 rem---structure of data you can fill in
  77. 710 rem who,vote for how many,list of names,star,star at the end
  78. 720 data president,1
  79. 730 data pres1,pres2,pres3,"pres4, md",*
  80. 740 data vice president,1
  81. 750 data vp1,vp2,vp3,vp4,*
  82. 760 data secretary,1
  83. 770 data sec1,sec2,sec3,*
  84. 780 data treasurer,1
  85. 790 data treas1,treas2,treas3,treas4,treas5,*
  86. 800 data blackboard cleaner,3
  87. 810 data bc1,bc2,bc3,bc4,bc5,bc6,*
  88. 820 data *
  89. 830 rem----------------------------
  90. 1000 gosub 500:if ok then t2(i,p)=t2(i,p)+1:print"..."p:return
  91. 1010 k=k-1:return
  92. 2000 print:print:print"[158]      return to loadstar? (y/n)"
  93. 2002 geta$:ifa$<>"y"anda$<>"n"then2002
  94. 2004 ifa$="n"thenrun
  95. 2010 open15,8,15,"r0:hello connect=hello connect":input#15,er%:close15
  96. 2020 ifer%<>63thenend
  97. 2040 load"hello connect",8
  98. 60100 poke53280,14:poke53281, 0:print"[147][142]";
  99. 60110 print"[153]loadstarpresents:"
  100. 60120 print"[150]                      "
  101. 60130 print"       election       "
  102. 60140 print"                      "
  103. 60150 print"     by  liz deal     "
  104. 60160 print"                      "
  105. 60170 print"    copyright 1988    "
  106. 60180 print"                      "
  107. 60190 print"[153]pressspacetocontinue"
  108. 60200 ifpeek(203)<>60then60200
  109. 60210 return
  110. 60500 c$="":poke198,.:print"[164]";
  111. 60510 fora=1tole+1
  112. 60520 geta$:ifa$=""then60520
  113. 60525 ifa$="$"then60595
  114. 60530 ifa$=chr$(13)thenprint"[157] ":return
  115. 60540 ifa$=chr$(20)anda>1thenprint"[157][157]  [157][157][164]";:a=a-1:c$=left$(c$,a-1):goto60520
  116. 60550 if(a=le+1)then60520
  117. 60560 if(nu)and((a$>="0")and(a$<="9"))then60595
  118. 60570 if(al)and((a$>=" "anda$<="/")or(a$>=":"anda$<="z"))then60595
  119. 60580 if(al)thenif(a$>="[193]"anda$<="[218]")then60595
  120. 60590 goto60520
  121. 60595 print"[157]"a$;:poke212,.:print"[164]";:c$=c$+a$:next
  122.