Simple conditionals and checking for spaces

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
SandyDoss
Junior Coder
Posts: 40
Joined: Wed Sep 07, 2016 12:47 am

Simple conditionals and checking for spaces

Post by SandyDoss » Tue Sep 13, 2016 5:06 pm

Hi,
Is there a way to check for a variable with a value of spaces in a simple condition, as in

Code: Select all

If>variable_name=" "
It looks like in the above statement the use of double quotes causes the MacroScheduler program to compare literally using the double quotes, instead of the double quotes delineating a string of spaces. Am I correct in this?

In the case of the script I'm writing now, I can change the statement to look for a value > 1, as I'm pulling in data from specific cells in a .xls sheet while looping through the rows, and I know that this particular column will have either digits or spaces. But for future reference, the check for spaces, or 'lack of data' might be useful.

As a sidebar, I also don't see anything in the manual about reserved words (other than, I'm assuming, your commands). If I'm wrong, please point me in the right direction :)

Thanks--Sandy

dtaylor
Junior Coder
Posts: 46
Joined: Mon Aug 08, 2016 2:42 am

Re: Simple conditionals and checking for spaces

Post by dtaylor » Tue Sep 13, 2016 7:21 pm

Try this to perform a match for a single space.

Code: Select all

If>variable_name=%SPACE%
OR this to match one or more spaces using a Regular Expression.

Code: Select all

RegEx>^\s+$,variable_name,0,match,num,0
If>num>0
  Remark>match found
Else
  Remark>no match found
EndIf

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

Re: Simple conditionals and checking for spaces

Post by Marcus Tettmar » Wed Sep 14, 2016 8:28 am

Or just:

Code: Select all

If>variable_name={" "}
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

SandyDoss
Junior Coder
Posts: 40
Joined: Wed Sep 07, 2016 12:47 am

Re: Simple conditionals and checking for spaces

Post by SandyDoss » Wed Sep 14, 2016 2:54 pm

Thanks to all suggestions. I'll keep the use of parentheses in mind :)

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