# String to Num

## Recommended Posts

Hello,

I'm a beginner in software development.

How use the box String to Num ? What is the FACTOR ?

Thank you.

##### Share on other sites

• MVP 2023

@Cara Bereck Levy, as far as I can tell, there is absolutely nothing on this function in the help file. Can you help?

##### Share on other sites

• MVP 2023

By the way, the answer to your question, @JOYE, is that FACTOR is how you deal with the decimal placement since you are converting the string representation to an integer. If the string looks like this: "123.45", then you would use a factor of 100 to result in an integer value of 12345. You can then display this integer number on the HMI screen and identify where to place the decimal. If you use the number in calculations, you would need to account for the fact that the number has been multiplied by 100 and deal with that properly.

##### Share on other sites

I had a crash course in UniLogic string to num conversions (formatting/handling). You have to remove leading spaces and trailing non numeric characters if I recall correctly. The Visilogic string to num FB is more flexible as to what it will convert. If your ASCII string is purely numeric characters you should be Okay. If you need a subroutine to strip off other characters let me know. I could share a snippet of code I used.

• 1
##### Share on other sites

• 4 months later...
On 16/2/2019 at 10:36, hotwires said:

Tuve un curso intensivo en la cadena UniLogic para numear las conversiones (formateo / manejo). Tienes que eliminar los espacios iniciales y los caracteres no numéricos finales si recuerdo correctamente. La cadena de Visilogic a num FB es más flexible en cuanto a lo que convertirá. Si su cadena ASCII tiene caracteres puramente numéricos, debería estar bien. Si necesita una subrutina para quitar otros caracteres, hágamelo saber. Podría compartir un fragmento de código que utilicé.

Could you help me? I need to convert a string into a number. My string has a decimal point, for example, "34.123" and sign "-" when the reading is negative

##### Share on other sites

If you are still needing help, I'll look through my files and see if I can post a snippet (photo) of the logic I used to convert ASCII string from a gram scale to an integer for comparison to a tolerance (window) and give an output if weighed part is "bad". Back when I worked on this the help section was sparse and (even though I would consider myself an intermediate programmer ((on a scale of: novice, intermediate, advanced, and expert)) it took me a considerable amount of time to reach an efficient solution. See photo below for a start. The - sign will need a little addition logic. Let me know if you need help with that part.

• 1
##### Share on other sites

• 2 years later...
On 2/16/2019 at 6:36 PM, hotwires said:

I had a crash course in UniLogic string to num conversions (formatting/handling). You have to remove leading spaces and trailing non numeric characters if I recall correctly. The Visilogic string to num FB is more flexible as to what it will convert. If your ASCII string is purely numeric characters you should be Okay. If you need a subroutine to strip off other characters let me know. I could share a snippet of code I used.

Hi @hotwires would you mind sharing your subroutine on stripping off some characters in Unilogic to use the string to num block

## 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

×