|
Post by Cam Dickerson on Apr 10, 2008 20:44:33 GMT
ok so here is my program
read date1$,day1,city1$,fmr1,amr1,min1 read date2$,day2,city2$,fmr2,amr2,min2 read date3$,day3,city3$,fmr3,amr3,min3 read date4$,day4,city4$,fmr4,amr4,min4 ' rem calculation total1=fmr1+(amr1*(min1-1)) total2=fmr2+(amr2*(min2-1)) total3=fmr3+(amr3*(min3-1)) total4=fmr4+(amr4*(min4-1)) sum1=total1+total2+total3+total4 ' rem output color 30,12 cls print ,,"Phone Bill" print "date";tab(9);"to";Tab(20);"first min. rate";tab(36);"addl. min. rate";tab(52);"total min.";tab(63);"Amount" print using "\ ### \ #.#### ##.#### ### $##.####";date1$;day1;city1$;fmr1;amr1;min1;total1 ' read data data june, 16, boston, .4698,.3740,17 data july,23,san fran.,.5330,.4158,5 data aug,9,denver,.7896,.3290,20 data dec, 25, orlando, .2354, .2243, 130 end
What did i do wrong? Why do i get a mismatch error when i try to run the program?
|
|
|
Post by Ildûrest on Apr 10, 2008 22:42:01 GMT
A type mismatch usually indicates that you supplied a string where a number was expected, or a number where a string was expected.
It looks to me like you're trying to use \ to display an entire string. If you check the help page for PRINT USING you will note that \s have to come in pairs, with spaces between them. Either use & instead, or follow each \ with another one.
|
|
|
Post by buff2 on Apr 10, 2008 22:51:28 GMT
Never cared for those using strings. How about this
DIM date1$(4), day1(4), city1$(4), fmr1(4), amr1(4), min1(4), total1(4)
FOR k& = 1 TO 4 READ date1$(k&), day1(k&), city1$(k&), fmr1(k&), amr1(k&), min1(k&) 'READ date2$, day2, city2$, fmr2, amr2, min2 'READ date3$, day3, city3$, fmr3, amr3, min3 'READ date4$, day4, city4$, fmr4, amr4, min4 NEXT k& ' REM calculation FOR k& = 1 TO 4 total1(k&) = fmr1(k&) + (amr1(k&) * (min1(k&) - 1)) 'total1 = fmr1 + (amr1 * (min1 - 1)) 'total2 = fmr2 + (amr2 * (min2 - 1)) 'total3 = fmr3 + (amr3 * (min3 - 1)) 'total4 = fmr4 + (amr4 * (min4 - 1)) NEXT k& 'sum1 = total1 + total2 + total3 + total4 sum1 = total1(1) + total1(2) + total1(3) + total1(4) ' REM output COLOR 30, 12 CLS PRINT , , "Phone Bill" PRINT "date"; TAB(9); "to"; TAB(20); "first.min.rate"; TAB(36); "addl.min.rate"; TAB(52); "total min."; TAB(63); "Amount" 'PRINT USING "\ ### \ #.#### ##.#### ### $##.####"; date1$; day1; city1$; fmr1; amr1; min1; total1 'PRINT USING "\ \ \ \ #.#### ##.#### ### $##.####"; date1$ + STR$(day1); city1$; fmr1; amr1; min1; total1 FOR k& = 1 TO 4 PRINT date1$(k&) + STR$(day1(k&)); TAB(9); city1$(k&); TAB(20); PRINT USING "#.####"; fmr1(k&); PRINT TAB(36); PRINT USING "##.####"; amr1(k&); PRINT TAB(52); PRINT USING "###"; min1(k&); PRINT TAB(63); PRINT USING "$##.####"; total1(k&) NEXT k& PRINT PRINT TAB(63); PRINT USING "$##.####"; sum1
END 'read data DATA june, 16, boston, .4698, .374, 17 DATA july,23,san fran.,.5330,.4158,5 DATA aug,9,denver,.7896,.3290,20 DATA dec, 25, orlando, .2354, .2243, 130
|
|
clippy
Junior Member
Posts: 32
|
Post by clippy on Apr 15, 2008 4:49:07 GMT
Tmp$ = "\ \ " 'allows a 3 length string, everything else is cut off PRINT USING Tmp$; month$
Numbers use # for each digit place. For dollars use $$ instead of just $. That keeps the dollar sign with the leading digit.
For commas use #######,.## That allows the commas without specifically placing them like #,###, ###.##
Remember that any number can also be rounded by PRINT USING too, but the original value is still the same for later calculations.
Ted
|
|