Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 09:23am 21 Sep 2018
Copy link to clipboard
Print this post
I'm trying to split my indoor and outdoor temperature readings because the decimal point is too big and it makes the display look "not as good as it could"
My two lines of code are [code]Text 170,155, STR$(val(temp1$),2,1)+"`C" , LB,4, 2,rgb(223,159,54) , RGB(128,128,128) 'Outdoor Temp
Text 170,215, STR$(tempr(11),2,1)+"`C", LB,4, 2, RGB(203,168,24) , RGB(128,128,128) 'Indoor Temp[/code]
I thought it would be
[quote]Text 170,155, LEFT$(val(temp1$),2,1,2))+"`C" , LB,4, 2,rgb(223,159,54) , RGB(128,128,128) ' LEFT DIGITS Text 170,155, RIGHT$(val(temp1$),2,1,1))+"`C" , LB,4, 2,rgb(223,159,54) , RGB(128,128,128) ' Decimal digit and Text 170,215, LEFT$(val(tempr(11),2,1,1))+"`C", LB,4, 2, RGB(203,168,24) , RGB(128,128,128) 'LEFT DIGITS Text 170,215, RIGHT$(val(tempr(11),2,1,1))+"`C", LB,4, 2, RGB(203,168,24) , RGB(128,128,128) 'DECIMAL digit[/quote]
but no matter what combinations I try I always get an error and it doesn't work Edited by lew247 2018-09-22
PicFan Senior Member Joined: 18/03/2014 Location: AustriaPosts: 133
This is not a good solution (neg. numbers etc.), I'll keep trying !!!Edited by PicFan 2018-09-22
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 11:30am 21 Sep 2018
Copy link to clipboard
Print this post
I still have a problem
While print val(left$(temp1$,2)) works
It doesn't make certain that temp1$ will always have 2 places before the decimal point If the temp was 13.23° it would print 13 which is correct but if the temp was 2.35° it would print 2. which is wrong
I also need it to print the zero if the temp is 0° which this won't do
Also the DS1820B
print mid$(tempr(11),4,1) WHile this works IF there are 2 numbers before the decimal point it won't work if there is only 1 or the first digit is zero
Hope that made sense
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572
Posted: 12:07pm 21 Sep 2018
Copy link to clipboard
Print this post
temp10%=CINT(temp*10) print str$(temp10%\10,2) print temp10% mod 10
Edited by matherp 2018-09-22
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 01:52pm 21 Sep 2018
Copy link to clipboard
Print this post
Thanks Peter I had considered that and yes it would be a lot simpler and easier but I'd like to keep the decimal place (1 place)
PicFan Senior Member Joined: 18/03/2014 Location: AustriaPosts: 133
Posted: 04:19pm 21 Sep 2018
Copy link to clipboard
Print this post
Try this, i hope, i have you understand ?
Do
Input temp x$ = str$(temp,2,2) if (temp < 0) then vz$="-" else vz$="+" endif nk$ = mid$(x$,instr(1,x$,".")+1,1) 'xx.7 vk$ = vz$ + str$(abs(fix(temp),1,0) print vk$" C "nk$ nk$ = mid$(x$,instr(1,x$,".")+1,2) 'xx.75 print vk$" C "nk$