View Full Version : FloatString Question
04-08-2012, 12:05 PM
I am attempting to use the StringToFloat method of FloatString. FloatString does not appear to need to be started and I have F32 running for other things and I am calling that for the maths in FloatString. It has been started in another object - but not in FloatString.
This very trivial test example fails despite trying various combinations with @.
debug.str(tmp) 'works fine
speed_dec := FS.StringToFloat(tmp) 'this line fails with tmp and @tmp
debug.str(string(" = ")) 'this never prints suggesting the line above causes a hang
04-08-2012, 12:46 PM
Using the right version of FloatString (1.2) this works for me (using tmp). Note that the method returns a float which means that printing it as decimal isn't giving you the expected(?) result.
04-08-2012, 12:57 PM
Thanks Kuroneko. I am using v1.2. I note the point about the float but mine never gets to that statement. Very odd.
04-08-2012, 01:03 PM
Can you attach the whole archive (PropTool: File->Archive) so I can (possibly) reproduce it here?
04-08-2012, 01:15 PM
The test snippet is just before the main loop (line 254).
04-08-2012, 01:32 PM
The difference is that my version used FloatMath yours is using F32. The latter requires initialisation (PASM cog) and therefore hangs during its first call (FFloat) while doing the conversion. Note that while you start the other copy of F32 this doesn't affect the version included by FloatString. I'd suggest you reinstate FloatMath given that string ops are slow'ish anyway and use F32 for the real stuff.
04-08-2012, 01:48 PM
I start F32 on line 142 of the main part of the program but as you say, that's not enough.I also tried an additional F32.Start at the first statement inside FloatString StringToFloat but it still failed.
04-08-2012, 01:59 PM
Works for me. I added an extra long on to the VAR section and these two lines at the beginning of the function:
Note that I cut down the example to just having the debug serial object and FloatString around. From the looks of it you're not running out of cogs either. Can you verify the result of the start method call?
04-08-2012, 02:43 PM
Hooray! All working now. That was a bit strange. Looks like I was on the right track for a while but my fix failed. Thanks again!
04-08-2012, 03:47 PM
Some really useful progress today. Many odd things I have noted are starting to become much clearer.
More beer needed.