Chavak

String to Real

9 posts in this topic

Hi,

 

I am receiving the following string from a serial port - +0153.8 +026.81 +0000.6 +0000.9     Air$R    .

I use 'Mid' instruction to separate the bold digits out of the string. Now I need to convert the separated value to Real format. How should I go about doing it?

Thank You

Regards

Share this post


Link to post
Share on other sites

I just discovered this awesome instruction. I tried converting the DWORD to REAL but it did not handle the Minus (-) value properly.

MrPLC_STRINGtoREAL.thumb.jpg.5aa931638dc

Share this post


Link to post
Share on other sites

There are commands in the CPU to convert a string to REAL or LREAL.  

STRING_TO_REAL

STRING_TO_LREAL

Share this post


Link to post
Share on other sites
Just now, Crossbow said:

STRING_TO_REAL

Wow... much easier! I overlooked the Data Type Conversion menu in the Toolbox.

I seem to have this knack for doing things the hard way.

Share this post


Link to post
Share on other sites

Thank you both of you, I'll try it out.

 

Regards

Share this post


Link to post
Share on other sites

BTW, how to know the various functions available in the CPU. It doesn't reflect in the toolbox, right?

I did look for available instructions in the toolbox

Share this post


Link to post
Share on other sites

It does. I was looking in the "Conversion" menu. The STRING_TO_REAL is in the "Data Type Conversion" menu. Also, sometimes I'll take a guess at an instruction name and begin typing it. You will get a drop down box with suggestions. Of course, some get overlooked just as I did.

No one can be expected to know them all. This is why we browse these forums and share our experiences.

Share this post


Link to post
Share on other sites

Found a search box right below of the toolbox, - very handy to search for Functions, keyed in String and all the string related functions appeared:-)

Share this post


Link to post
Share on other sites

All commands are in the toolbox.  No exceptions.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now