Am re writing a check register program. I need to be able to turn strings to numbers because all my inputs are strings. Int function in the manual shows it converts a float value to an integer. How can I change a string to an integer?
Need to turn String to Number
BlitzPlus Forums/BlitzPlus Beginners Area/Need to turn String to Number Like this, I think:
A$="123" C%=A$
I put a stupid-proof string2float converter in the code archives some days ago..
It accepts crap like :"- - .-.3.- 9-.46.3" and creates a nice float out of it.. in this case: -3946.3
It accepts crap like :"- - .-.3.- 9-.46.3" and creates a nice float out of it.. in this case: -3946.3
Tiger-will try your suggestion(Maybe it works only on Comodore computers?
CS_TBL-Need String to Integer not string to float!
TwoEyedPete What was your point?
CS_TBL-Need String to Integer not string to float!
TwoEyedPete What was your point?
You can covert a float to an int anyway by using Int(Thefloat#).
TwoEyedPete appears to have answered your question already (before) in his link.
Tiger is right too of course. You can only do that assignment because it is a BASIC language otherwise you would have to convert or typecast it. For example trying that (A% = B$) in C would not work, you would need to program it or use a library function. In Delpi you use StrToInt, BUT if raises an exception if the string is not a valid number. Blitz just sets the int to 0.
try this in blitzPLus
TwoEyedPete appears to have answered your question already (before) in his link.
Tiger is right too of course. You can only do that assignment because it is a BASIC language otherwise you would have to convert or typecast it. For example trying that (A% = B$) in C would not work, you would need to program it or use a library function. In Delpi you use StrToInt, BUT if raises an exception if the string is not a valid number. Blitz just sets the int to 0.
try this in blitzPLus
f# = 0.55 a% = Int(f#) Notify (a) b$ = "51" a% = b$ Notify (a)
zook: yeah I know.. I just mentioned it.. in case you ever need a string to float function: it's CatWalksOnTheKeyboard-Proof!
TwoEyedPete- My apologies. I never noticed the Link.Hmmm learn somethin everyday. Thanks to all you people. Sorry to take this much of your time up.! ! !