home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Run Magazine ReRun: Productivity Pak 1
/
rerun-productivity-pak-i.d64
/
dfcalc
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
17KB
|
563 lines
3000 rem dfcalc 1.2 program for datafile by mike konshak (c)1985
3004 poke53281,11:poke53280,2:print"[158]":open4,4: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" press c[146]ont r[146]edo s[146]tart j[146]ump e[146]xit"
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" press any key[146] to continue"
3040 gosub3018:close5:close15:return
3042 rem----starting menu
3044 print"[147] calculated reports program "
3046 print" use p[146]redefined format"
3048 print" or d[146]efine new format"
3050 print" $[146] disk directory"
3052 print" q[146]uit program"
3054 print" press the appropriate key [146]"
3056 gosub3018:ifa$="q"thenclose4:print"[147]":end
3058 ifa$="d"thenk=1:goto3068
3060 ifa$="p"thenk=2:fl=0:goto3068
3062 ifa$="$"thendir=0:goto3940
3064 goto3056
3066 rem----open datafile, read file structure
3068 print" insert disk with the datafile to be"
3070 print" used for calculated reports."
3072 print" enter the name of the datafile:"
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"[147] define report header format [146]"
3098 print" enter width of report (136 max)"
3100 print" ? 0[157][157]"pw:input"[145] ";pw:ifpw>136thenprint"[145][145][145][145][145][145][145]":goto3098
3102 print" enter number of title lines in the"
3104 print" report header (4 lines max)"
3106 print" "nl:input"[145] ";nl:ifnl>4thenprint"[145][145][145][145][145][145][145]":goto3102
3108 ifnl=0thentt$(1)="no titles":goto3118
3110 print:forj=1tonl:print" title #"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" field name(length) data for "+nf$+"[158]"
3130 oe=1:if(f/2)=int(f/2)thenoe=0:goto3132
3132 of=int(f/2):fori=1toof+oe
3134 print" "i"[146]"f$(i)l%(i);
3136 ifoe=1then3140
3138 printtab(19)""i+of"[146]"f$(i+of)l%(i+of):goto3142
3140 ifi+of<fthenprinttab(19)""i+of+1"[146]"f$(i+of+1)l%(i+of+1)
3142 nexti
3144 rem----enter columnar data
3146 print" define report columnar format [146]"
3148 gosub3030
3150 print" 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" ? 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" enter position of column "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" enter heading of column "i
3198 print" heading is ";:ifi=ncthenprintpw-pc(i);:goto3202
3200 printpc(i+1)-2-pc(i);
3202 print"[146] characters wide"
3204 print" ? >[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" format input routines for column"i
3220 gosub3030:print" enter contents of column "i
3222 print" choose f[146]ield data"
3224 print" e[146]quation"
3225 print" r[146]unning total"
3226 print" #[146] record number"
3228 print" ? 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]":goto3228
3238 print" which field # will be in column "i:goto3241
3239 print" which column # is to have a running"
3240 print" total in column "i"[146][157]? enter 1[146] thru "i-1:goto3245
3241 print" enter 1[146] thru "f
3242 print" ? "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" ? "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" enter equation "op"[146]for column "i
3266 ifop>1thengosub3308
3268 print" res[146]="rs$(op-1)
3270 print" operand x? .[157]"c$(i,eq)
3272 print" operator ? .[157]"c$(i,eq+1)
3274 print" operand y? .[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] expand equation? y[146] or n[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" set end-of-column operation"
3330 print" options: t[146]otal sum of column"
3332 print" a[146]verage contents of column"
3334 print" n[146]o operation to column"
3336 print" ? n[157]"c$(i,13):input"[145] ";c$(i,13)
3338 if(c$(i,13)="t")or(c$(i,13)="a")or(c$(i,13)="n")then3344
3340 print"[145][145]":goto3336
3342 rem----set justifications
3344 gosub3030:print" set column justification
3346 [153]" options: lwaiteft"
3348 [153]" rwaitight"
3350 [153]" cwaiturrency ($.00)"
3352 [153]" pwaitercent (%)"
3354 [153]" dwaitecimals to right"
3356 [153]" ? lcmd"[200](c$(i,0),1):[133]"on ";c$:c$(i,0)[178]c$[170][202](c$(i,0),2)
3358 [139](c$[178]"l")[176](c$[178]"r")[176](c$[178]"c")[167]3370
3360 [139](c$[178]"p")[176](c$[178]"d")[167]3364
3362 [153]"onon":[137]3356
3364 [153]" # of places to the right of decimal:"
3366 [153]" ? 1cmd"[202](c$(i,0),2,1):[133]"on ";c$
3368 c$(i,0)[178][200](c$(i,0),1)[170]c$
3370 [141]3024:[139]a$[178]"e"[167]3044
3372 [139]a$[178]"j"[167]3386
3374 [139]a$[178]"r"[167]3220
3376 [139]a$[178]"s"[167]3096
3378 [129]j[178]0[164]14:[139]c$(i,j)[178]""[167]c$(i,j)[178]"."
3380 [130]j:[130]i
3382 fl[178]1
3384 [143]----operations menu
3386 [153]"load calculated reports operations menu wait"
3388 [153]" current datafile: "nf$"sys"
3390 [139]fl[178]1[167][153]" swaitave report format"
3392 [153]" lwaitoad report format"
3394 [139]fl[178]1[167][153]"