home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1994 December
/
1994-12b.d64
/
listmaker
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
2KB
|
37 lines
10 printchr$(147)
20 dimi$(100),a(100):rem change this if more than 100 items
30 l$="xmaslist":rem name of list for disk saving and loading
40 print" get existing list from disk?
50 [161]a$:[139]a$[179][177]"n"[167][139]a$[179][177]"y"[167]50
60 [139]a$[178]"y"[167][141]170:[143] goes to disk-loading subroutine at 170-230
70 [153]" press only return to stop"
80 c[178]c[170]1:[143] c is the item counter which increments for each loop
90 [153]" item no."c;:[143] semicolon ensures input ? immediately follows
100 i$(c)[178]"":[133]i$(c):[143] set item name to nothing, then get item name
110 [139]i$(c)[178]""[167]c[178]c[171]1:[141]280:[128]:[143] user pressed only return. program
120 [143] exits loop and goes to save subroutine at lines 280-360
130 [153]" amount for item no."c;
140 [133]a(c):[143] get item cost
150 t[178]t[170]a(c):[143] keeps track of total $ spent so far
160 [137]80:[143] puts program into a loop. line 110 is only loop exit.
170 [153]" loading christmas list. . .
180 open1,8,0,l$:rem 1=file no., 8=disk drive, 0=load, l$=list name
190 input#1,c:ifc=0thenend:rem gets item count c from file & ends if c=0
200 input#1,t:rem gets total dollars spent so far from disk file 1
210 forx=1toc:input#1,i$(x):input#1,a(x):next:rem uses a for-next loop to get
220 rem item names and costs from file 1 on disk and store them in ram
230 close1:rem always close file after a load or save
240 print"[147]":rem clear screen and move cursor down one line
250 forx=1toc:print" "i$(x),a(x):next:rem print items and costs from ram
260 print" total so far: $"t
270 return:rem end of loading and screen printing subroutine
280 print" total so far: $"t:rem this line begins disk-saving subroutine
290 print" saving christmas list. . .
300 [159]15,8,15:[152]15,"s0:"l$:[143] erases old xmaslist if it exists
310 [159]1,8,1,l$:[143] 1=file no., 8=disk drive, 1=save, l$=list name
320 [152]1,c:[143] item count is put in file no. 1 on disk
330 [152]1,t:[143] likewise total dollars spent so far
340 [129]x[178]1[164]c:[152]1,i$(x):[152]1,a(x):[130]:[143] using another for-next loop
350 [143] to put item names and costs in file 1 on disk
360 [160]1:[142]:[143] closes file 1 and ends subroutine