Jump to content



Photo
- - - - -

Convert String To Number


  • Please log in to reply
2 replies to this topic

#1 serverone

serverone

    Newbie

  • Members
  • Pip
  • 2 posts

  • Calculators:
    ClassPad 300 PLUS

Posted 16 September 2009 - 08:58 PM

Hello,

First, I'm new in programming ClassPad BASIC. 

For a project I implemented a code into an AVR which emulates the ClassPad communication protocol. After that and some adc-code, the microcontroller puts out the voltage as an UART string every two seconds. The ClassPad receives this string without any problems but of course it's not possible to calculate with a string.

Is there a possibility to convert a string into a number to calculate with?

In C there exists atoi to do this.

I will go on trying some other ways (e.g. all calculations could be done by the AVR) but I think it's better if the calculations are done by ClassPad.

Maybe I have to switch to C++ to build a ClassPad Add-In but this should be the last way ;).




Thanks for answers

serverone

#2 DrCoyote

DrCoyote

    Casio Freak

  • Members
  • PipPipPipPip
  • 156 posts
  • Gender:Male
  • Location:Cleveland, Ohio USA

  • Calculators:
    CFX-9850GB PLUS, FX-9860G, TI 92+, TI89 Titanium, TI-Nspire, TI-Nspire CAS, TI 84+ SE, HP 50G, HP 35S, Elektronika MK-90, Elektronika MK-52, Elektronika MK-61, Elektronika B3-21, Elektronika MK-152, Elektronika MK-161, Sharp EL-9900

Posted 24 September 2009 - 07:55 PM

strToExp(

#3 serverone

serverone

    Newbie

  • Members
  • Pip
  • 2 posts

  • Calculators:
    ClassPad 300 PLUS

Posted 28 September 2009 - 06:59 AM

Thanks DrCoyote,

I solved it another way:

StrLen adc, l
	   1 => i
	   0 => z
	   While i < l+1
	   ChrToNum adc, b, i
	   10*z+(b-48) => z
	   i+1 => i
	   WhileEnd

"adc" contains the string to convert (only numbers); z ist the numerical order of "adc".

I wasn't sure, if "strToExp(" could handle this type but I'll try this command.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users