Get number from clipboard and make calculation

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
thargi22
Newbie
Posts: 2
Joined: Mon Jan 24, 2011 6:55 pm

Get number from clipboard and make calculation

Post by thargi22 » Mon Jan 24, 2011 7:20 pm

Hello,

This code:
Let>Source=58,45
Let>Find=,
StringReplace>%Source%,%Find%,.,x
MessageModal>%x%
let>x=x+1
MessageModal>%x%

works ok and give as result: 59,45

but when i get the source from a cell in excel, with this code:
Press CTRL
Send>c
Release CTRL
Wait>0.10
GetClipBoard>r
Let>Source=r
Let>Find=,
StringReplace>%Source%,%Find%,.,x
MessageModal>%x%
let>x=x+1
MessageModal>%x%

the result is: x+1

Thanks for your help

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Jan 24, 2011 7:29 pm

When you copy data from excel to the clipboard the data comes with a carriage return and line feed character attached. You need to strip those out from the value of the variable before you use teh variable.

Try this:

Code: Select all

Press CTRL
Send>c
Release CTRL
Wait>0.10
GetClipBoard>r
StringReplace>r,%crlf%,,r
Let>Source=r
Let>Find=,
StringReplace>%Source%,%Find%,.,x
MessageModal>%x%
let>x=x+1
MessageModal>%x% 

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts