home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Run Magazine ReRun: Productivity Pak 2
/
rerun-productivity-pak-ii.d64
/
dfcalc
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
18KB
|
575 lines
10 iffl=0thenfl=1:load"dp] dos5.1",8,1
11 iffl=1thenfl=2:sys52224:rem (c) by commodore
600 fore=0to24:poke54272+e,0:next:poke54296,15:goto3000
602 poke54277,58:poke54278,16:poke54273,35:poke54272,134
604 poke54276,33:fore=1to100:next:poke54276,16:return
3000 rem dfcalc 1.5a program for datafile by mike konshak (c)1986
3004 poke53281,0:poke53280,0:print"[158]":open4,4:open3,3:gosub4000
3006 rem----dim arrays
3008 b$=chr$(32):pi=3.14159265:cr$=chr$(13)
3010 fori=1to100:s$=s$+chr$(32):nexti
3012 dim f$(31),t%(31),l%(31),rec$(31),sum(17),buf(17)
3014 dim f(17),c$(17,15),pc(18),tt$(5),hc$(17):goto3044
3016 rem----get
3018 geta$:ifa$=""then3018
3020 return
3022 rem----prompt
3024 print"[153] press c[153][146]ont r[153][146]edo s[153][146]tart j[153][146]ump e[153][146]xit[158]"
3026 gosub3018:return
3028 rem----clear top 13 rows of screen
3030 forz=1to13:poke781,z:sys59903:nextz:return
3032 rem----disk error
3034 input#15,en,em$,et,es:if(en<20)or(en=62)thenet=0:return
3036 print" [150]disk error[146]"en"[157], "em$","et"[157],"es"[158]":et=8
3038 print" [153]press any key[153][146] to continue[158]"
3040 gosub3018:close5:close15:return
3042 rem----starting menu
3044 print"[158][147] calculated reports program rev 1.5a "
3045 print" [158] copyright (c)1986 by mike konshak "
3046 print"[153] use o[153][146]ld predefined format"
3047 print" or n[153][146]ew format"
3048 print" $[153][146] disk directory 4[153][146]"
3049 print" q[153][146]uit program"
3050 print" transfer to:"
3051 print" d[153][146] datafile dbms"
3052 print" p[153][146] dfprint reports-lists-labels"
3054 print" [158] press the appropriate key [146]"
3056 gosub3018:ifa$="q"thenclose3:close4:print"[147]":end
3058 ifa$="n"thenk=1:goto3068
3059 ifa$="d"thenprint"[147][144]load"chr$(34)"datafile"chr$(34)",8":goto3064
3060 ifa$="o"thenk=2:fl=0:goto3068
3061 ifa$="p"thenprint"[147][144]load"chr$(34)"dfprint"chr$(34)",8":goto3064
3062 ifa$="$"ora$="4"thengosub3940:goto3044
3063 gosub602:goto3056
3064 print:print:print:print:print"run[158]"
3065 poke631,19:poke632,13:poke633,13:poke634,13:poke635,13:poke636,13
3066 poke198,6:new:end
3067 rem----open datafile, read file structure
3068 print"[153][147] available datafile record files are:[158]":@"$0:df]*"
3072 print"[153] name of datafile record file?[158]"
3074 print" ? "nf$:input"[145] ";a$:ifa$=""then3044
3076 ifa$=nf$then3096
3078 nf$=a$
3080 open15,8,15:open5,8,5,"0:df] "+nf$+",s,r":gosub3034:ifet=8then3044
3082 ifen=62thengosub3036:goto3044
3084 input#5,r,f,x:gosub3034:ifet=8then3044
3088 forn=1tof:input#5,f$(n),l%(n):nextn:gosub3034:ifet=8then3044
3090 close5:close15
3092 ifk=2then3386
3094 rem----define new format
3096 ck=1:print"[158][147] define report header format [146]"
3098 print"[153] enter width of report (136 max)"
3100 print"[158] ? 0[157][157]"pw:input"[145] ";pw:ifpw>136thenprint"[145][145][145][145][145][145][145]":goto3098
3102 print"[153] enter number of title lines in the"
3104 print" report header (4 lines max)"
3106 print"[158] "nl:input"[145] ";nl:ifnl>4thenprint"[145][145][145][145][145][145][145]":goto3102
3108 ifnl=0thentt$(1)="[153]no titles":goto3118
3110 print:forj=1tonl:print"[153] title #[158]"j:print" ? >[157]"tt$(j)
3112 iflen(tt$(j))>37thenprint"[145]";
3114 input"[145] ";tt$(j):iftt$(j)=""thentt$(j)=">"
3116 nextj
3118 gosub3024:ifa$="e"then3044
3120 ifa$="j"then3386
3122 ifa$="r"ora$="s"then3096
3124 rem----print field info for reference
3126 print"[147]":fori=1to(22-int(f/2)):printchr$(17);:nexti
3128 print"[153] field name(length) data for [158]"nf$
3130 oe=1:if(f/2)=int(f/2)thenoe=0:goto3132
3132 of=int(f/2):fori=1toof+oe
3134 print" "i"[146][153]"f$(i)l%(i);
3136 ifoe=1then3140
3138 printtab(19)""i+of"[146][153]"f$(i+of)l%(i+of):goto3142
3140 ifi+of<fthenprinttab(19)""i+of+1"[146][153]"f$(i+of+1)l%(i+of+1)
3142 nexti
3144 rem----enter columnar data
3146 print"[158] define report columnar format [146]"
3148 gosub3030
3150 print"[153] calculate the total length of all"
3152 print" fields to be included in the report."
3154 print" allowing 2 spaces between each"
3156 print" column."
3158 print" enter the number of columns in report."
3160 print" (16 columns max)"
3162 print"[158] ? 0[157][157]"nc:input"[145] ";nc:ifnc>16then3148
3164 gosub3024:ifa$="e"then3044
3166 ifa$="j"then3386
3168 ifa$="r"then3148
3170 ifa$="s"then3096
3172 rem----column position
3174 fori=1tonc:gosub3030
3176 print"[153] enter position of column [158]"i""
3178 print" ? 0[157][157]"pc(i):input"[145] ";pc(i):ifpc(i)=0then3174
3180 ifpc(i)>pwthenprint"[145][145]":goto3178
3182 nexti
3184 gosub3024:ifa$="e"then3044
3186 ifa$="j"then3386
3188 ifa$="r"then3174
3190 ifa$="s"then3096
3192 fori=1tonc:gosub3030
3194 rem----column heading
3196 print"[153] enter heading of column [158]"i
3198 print"[153] heading is [158]";:ifi=ncthenprintpw-pc(i);:goto3202
3200 printpc(i+1)-2-pc(i);
3202 print"[146] [153]characters wide"
3204 print"[158] ? >[157]"hc$(i):input"[145] ";hc$(i):ifhc$(i)="r"then3192
3206 nexti
3208 gosub3024:ifa$="e"then3044
3210 ifa$="j"then3386
3212 ifa$="r"then3192
3214 ifa$="s"then3096
3216 rem----column contents data
3218 fori=1tonc:print" [158] format input routines for column"i
3220 gosub3030:print"[153] enter contents of column [158]"i
3222 print"[153] choose f[153][146]ield data in records"
3224 print" e[153][146]quation"
3225 print" r[153][146]unning total (balance)"
3226 print" #[153][146] record number"
3228 print"[158] ? f[157]"left$(c$(i,1),1):input"[145] ";c$:c$(i,1)=c$+mid$(c$(i,1),2)
3230 ifc$="#"thenc$(i,1)="#":c$(i,13)="n":goto3344
3232 ifc$="f"then3238
3234 ifc$="e"then3260
3235 ifc$="r"then3239
3236 print"[145][145]":gosub602:goto3228
3238 print"[153] which field # will be in column [158]"i:goto3241
3239 print"[153] which column # is to have a running"
3240 print" total in column [158]"i"[146][157]? [153]enter 1[153][146] thru "i-1:goto3245
3241 print"[153] enter 1[153][146] thru "f
3242 print"[158] ? "mid$(c$(i,1),2,2):input"[145] ";c$
3243 if(val(c$)>f)or(val(c$)<=0)thenprint"[145][145]":goto3242
3244 goto3247
3245 print"[158] ? "mid$(c$(i,1),2,2):input"[145] ";c$
3246 if(val(c$)>i-1)or(val(c$)<=0)thenprint"[145][145]":goto3245
3247 c$(i,1)=left$(c$(i,1),1)+c$
3248 goto3328
3250 gosub3024:ifa$="e"then3044
3252 ifa$="j"then3386
3254 ifa$="r"then3220
3256 ifa$="s"then3096
3258 rem----column contents calculation
3260 eq=2:op=1:forj=0to3:rs$(j)="":nextj:goto3264
3262 eq=eq+4:op=op+1
3264 gosub3030:print"[153] enter equation [158]"op"[153][146]for column [158]"i
3266 ifop>1thengosub3308
3268 print" res[158][146]="rs$(op-1)
3270 print"[153] operand x[158]? .[157]"c$(i,eq)
3272 print"[153] operator [158]? .[157]"c$(i,eq+1)
3274 print"[153] operand y[158]? .[157]"c$(i,eq+2)
3276 print""tab(10):inputc$(i,eq)
3278 printtab(10):inputc$(i,eq+1)
3280 printtab(10):inputc$(i,eq+2)
3282 gosub3308:print" res="rs$(op)"[158]":c$(i,14)=rs$(op)
3284 gosub3024:ifa$="e"then3044
3286 ifa$="j"then3386
3288 ifa$="r"then3220
3290 ifa$="s"then3096
3292 ifeq=10then3328
3294 print"[145][153] expand equation? y[153][146] or n[158][146] "
3296 print" ? n[157]"c$(i,eq+3):input"[145] ";c$(i,eq+3)
3298 ifc$(i,eq+3)="y"then3262
3300 :
3302 ifc$(i,eq+3)="n"thenforj=eq+4to12:c$(i,j)=".":nextj:goto3328
3304 print"[145][145]":goto3294
3306 rem----combine operations
3308 onopgoto3310,3312,3318
3310 rs$(1)=c$(i,2)+c$(i,3)+c$(i,4):goto3324
3312 ifc$(i,6)="res"then3316
3314 rs$(2)=c$(i,6)+c$(i,7)+"("+rs$(1)+")":goto3324
3316 rs$(2)="("+rs$(1)+")"+c$(i,7)+c$(i,8):goto3324
3318 ifc$(i,10)="res"then3322
3320 rs$(3)=c$(i,10)+c$(i,11)+"("+rs$(2)+")":goto3324
3322 rs$(3)="("+rs$(2)+")"+c$(i,11)+c$(i,12)
3324 return
3326 rem----field totals
3328 gosub3030:print"[153] set end-of-column operation"
3330 print" options: t[153][146]otal sum of column"
3332 print" a[153][146]verage contents of column"
3334 print" n[153][146]o operation to column"
3336 print"[158] ? n[157]"c$(i,13):input"[145] ";c$(i,13)
3338 if(c