home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1994 December / 1994-12b.d64 / listmaker (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  2KB  |  37 lines

  1. 10 printchr$(147)
  2. 20 dimi$(100),a(100):rem change this if more than 100 items
  3. 30 l$="xmaslist":rem name of list for disk saving and loading
  4. 40 print" get existing list from disk?
  5. 50 [161]a$:[139]a$[179][177]"n"[167][139]a$[179][177]"y"[167]50
  6. 60 [139]a$[178]"y"[167][141]170:[143] goes to disk-loading subroutine at 170-230
  7. 70 [153]" press only return to stop"
  8. 80 c[178]c[170]1:[143] c is the item counter which increments for each loop
  9. 90 [153]" item no."c;:[143] semicolon ensures input ? immediately follows
  10. 100 i$(c)[178]"":[133]i$(c):[143] set item name to nothing, then get item name
  11. 110 [139]i$(c)[178]""[167]c[178]c[171]1:[141]280:[128]:[143] user pressed only return.  program
  12. 120 [143] exits loop and goes to save subroutine at lines 280-360
  13. 130 [153]" amount for item no."c;
  14. 140 [133]a(c):[143] get item cost
  15. 150 t[178]t[170]a(c):[143] keeps track of total $ spent so far
  16. 160 [137]80:[143] puts program into a loop. line 110 is only loop exit.
  17. 170 [153]" loading christmas list. . .
  18. 180 open1,8,0,l$:rem 1=file no., 8=disk drive, 0=load, l$=list name
  19. 190 input#1,c:ifc=0thenend:rem gets item count c from file & ends if c=0
  20. 200 input#1,t:rem gets total dollars spent so far from disk file 1
  21. 210 forx=1toc:input#1,i$(x):input#1,a(x):next:rem uses a for-next loop to get
  22. 220 rem item names and costs from file 1 on disk and store them in ram
  23. 230 close1:rem always close file after a load or save
  24. 240 print"[147]":rem clear screen and move cursor down one line
  25. 250 forx=1toc:print" "i$(x),a(x):next:rem print items and costs from ram
  26. 260 print" total so far: $"t
  27. 270 return:rem end of loading and screen printing subroutine
  28. 280 print" total so far: $"t:rem this line begins disk-saving subroutine
  29. 290 print" saving christmas list. . .
  30. 300 [159]15,8,15:[152]15,"s0:"l$:[143] erases old xmaslist if it exists
  31. 310 [159]1,8,1,l$:[143] 1=file no., 8=disk drive, 1=save, l$=list name
  32. 320 [152]1,c:[143] item count is put in file no. 1 on disk
  33. 330 [152]1,t:[143] likewise total dollars spent so far
  34. 340 [129]x[178]1[164]c:[152]1,i$(x):[152]1,a(x):[130]:[143] using another for-next loop
  35. 350 [143] to put item names and costs in file 1 on disk
  36. 360 [160]1:[142]:[143] closes file 1 and ends subroutine
  37.