how do i convert a VAR string to an Array? NOW a MATH problem
How can i convert a string that is a long into a array. I wish to convert a number 2263 into 22.63? so I was thinking that i convert 2263 into an array then manuplate the array so that i have 22.63.
Post Edited (grasshopper) : 6/18/2008 10:13:19 PM GMT
Post Edited (grasshopper) : 6/18/2008 10:13:19 PM GMT

Comments
Have a look at the format object in the object exchange, I think you'll find some routines in there that will do what you want.
obex.parallax.com/objects/230/
Regards,
Coley
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PropGFX Forums - The home of the Hybrid Development System and PropGFX Lite
But when I replace M with the value of
My math is all incorrect.
Please help me i have tryed several varations of the
i.e.
Mike my life saver:
I did as you asked but no luck. I got a negative [noparse][[/noparse] -264. ] when the number should be around 23.62.
Any thing else? Please help
I think it works fine the lm135 is not floating point, so i assume that i can just subtract the two. Please let me know your concerns. And thanks a million for the help.
It works as you requested and again i thank you for the wisdom that you reflect upon me. For the record, perhaps others will benefit the final code is below.
** as a side note the 2x20 display i am using does not like the F.S.Floattostring(slope) statement. It displays 5-6 characters after the number is shown. The characters are not any thing i have ever seen but i fix this by clearing the letters with more code after the F.F.Floattostring(slope) statement **
You didn't show how you positioned the output string on the LCD display. The "writestr" just puts out what's in the string and anything left on the display from before is left unchanged. You at least need to erase the rest of the current line. When I've done similar things, I save the pointer in a local variable and do STRSIZE on it to get the number of characters. I then output enough spaces to clear the rest of the current display line.
Post Edited (Mike Green) : 6/19/2008 2:21:56 AM GMT
_clkmode = xtal1 + pll16x _xinfreq = 6_000_000 CON AD_CS = 9 'AD Chip Select AD_Din = 10 'AD Data IN AD_Dout = 11 'AD Data out AD_Dclk = 8 'AD clock Chan0 = %10010111 'board temp Chan1 = %11010111 'lm135 Chan2 = %10100111 'l Chan3 = %11100111 'e eos = $ff cr = $0D var long counter long Lm135 long setpoint long slope long temp_data OBJ BASIC : "BS2_Functions" lcd : "LcdDriver" G : "Floatmath" fs : "floatString" pub start | X init repeat repeat x from 0 to 25 AtoD Calc_Slope Display_it Pub Init ' G.start 'Start math obj lcd.init 'Init display lcd.cls 'Clear display Pub AtoD | Temp, X ' Read A to D temp := 0 lm135 := 0 repeat X from 0 to 24 outa[noparse][[/noparse]AD_CS]~ 'Chip Select active low "ON" Basic.SHIFTOUT(AD_Din,AD_DClk,Chan1,BASIC#MSBFIRST,8) 'Chan 1 is Lm134 Temp := BASIC.SHIFTIN(AD_Dout,AD_DCLK,BASIC#MSBPOST,16) 'Shift in 16 bit outa[noparse][[/noparse]AD_CS]~~ 'Turn it OFF" lm135 := Temp + lm135 lm135 := lm135 / 25 Pub Calc_Slope | B, M, subtracted M := 135.51 B := 35693 subtracted := lm135 - B 'Y - B slope := G.FDiv(G.ffloat(subtracted),M) 'Y - B / M Pub Display_it lcd.cls lcd.home lcd.pos(1,1) lcd.writestr(@screen1) lcd.writestr(fs.Floattostring(slope)) lcd.pos(1,15) lcd.writestr(@screen3) dat screen1 byte "Holder = ",eos screen2 byte "Target = ",eos screen3 byte " ",$DF,"C",eosThen i fixed it in the LCD object and now works great. Thanks again Mike. I owe you a few...
Post Edited (grasshopper) : 6/19/2008 3:44:26 AM GMT
lcd reads 20.3 instead of 20.30 i want it to look uniform throughout the numbers
Any ideas ?
Again Thanks