Help removing space from a value

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Tinn
Newbie
Posts: 2
Joined: Tue May 18, 2010 5:42 am

Help removing space from a value

Post by Tinn » Tue May 18, 2010 5:46 am

Hi Guys

Im new at macro and i need your help.

Im writing a macro i need a way to remove all the spaces of a value so that i can compare values.

i copy a value

getclipboard>part3

but the problem is that %part3% has spaces behind it.

say for example if i just wanted "test" as a value with no spaces behind how do i do that.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue May 18, 2010 8:08 am

StringReplace>part3,SPACE,,part3
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

trim removes trailing spaces

Post by adroege » Tue May 18, 2010 12:18 pm

The problem with StringReplace is that it removes embedded spaces as well which could be a problem. RTrim only removes the trailing spaces.

[code]

VBStart
VBEnd

Let>part3=program files%SPACE%

//This removes ALL spaces
//StringReplace>part3,SPACE,,part3

//Escape the double quotes if necessary
StringReplace>part3,","",part3
//This only removes spaces at the end of the string
VBEval>RTrim("%part3%"),part3

MessageModal> |%part3%|
[/code]

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue May 18, 2010 12:20 pm

In v12 to remove trailing spaces:

RTrim>part3,part3

To remove leading spaces:

LTrim>part3,part3

To remove leading and trailing spaces:

Trim>part3,part3

Or to remove ALL spaces as per my last post:

StringReplace>part3,SPACE,,part3
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

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