How to convert String value into integer value?

variables
rpa

#1

In java script we can use .parseInt('1234.44') to convert string to integer. How to do it on RPA Express ?
This is urgent!! :slight_smile: Thanks,
Lasitha


#2

@Lasitha_Wijenayake - you can copy a string value to clipboard and set clipboard value to a Number variable.


#3

ok thanks i’ll try out .


#4

Hi @azinchuk
I try the same conversion but get an “unexpected error”:

When I copy the current value of variable “numbpagesocr” to the clipboard it contains “417” which is the correctly scanned value. I need to do a calculation with that value afterwards, thats why I need it as number.

Any idea what the error is about?
Thanks and kind regards


#5

@timriewe - maybe the OCRed text contains whitespaces. Try to use the Trim Whitespace action on your variable - https://kb.workfusion.com/display/RPAe/Text#Text-TrimWhitespaceTrimWhitespace


#6

Hi @azinchuk
I did, see step 35 in my action flow.


#7

Same problem Occur


#8

Can confirm that clipboard solution definitely worked for me.
In my case I had just a “Substring Between” before it.

Does it work for you guys if you’d just put the correct value to first variable without OCR/Whitespaces?
Try to check also for regex new line, I had that issue with string one time and had no idea it was there.


#10

hi,

Facing the same issue ,in my case we are splitting a string and picking a value from string for further comparisons but the conversion is not happening from string to integer(by copying to clipboard from split string variable and copying the clipboard value to number variable). please let me know how u have solved the issue.

Thanks in Advance


#11

Hi @jyoti_rupanwar
I could not solve this using OCR in this case. Instead I found the value I needed in another place where I could simply copy it.


#12

@jyoti_rupanwar I just remember that I did manage the conversion in another process where I realized that the OCR returned a 4 digit result for a a 3 digit number. So what I did was:

  • OCR action to “number”
  • Trimwhitespaces “number”
  • Substring from “number” to “number” start character position 2

That did the job as the first character of the OCR result is then ignored.