The Unofficial Macro Scheduler Puzzler of the Week

Anything Really. Just keep it clean!

Moderators: Dorian (MJT support), JRL

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

The Unofficial Macro Scheduler Puzzler of the Week

Post by JRL » Fri Sep 13, 2013 5:07 am

Here it is Friday, the 13th day of September in the year 2013. Seems a perfect time to begin a weekly contest. (Couldn't wait for the 13th month and we're well beyond the 13th century.)

Thought I'd start out with a beginners level question and an advanced level question. For the beginners lets limit responders to those who have fewer than 50 posts on the forum.

So lets get to the puzzles. For the beginners, I'll give 20 rep points to the first correct response for the following question.

I want to assign to a variable the text value 1+1. How can I do that?



For anyone to answer
For bragging rights and 20 rep points for the first correct answer, what's wrong with the following code? Consider various values for variable "var", not just "ABC".

Advanced

Code: Select all

Let>var=ABC

If>{(%var%<>"ABC")or(%var%<>"DEF")or(%var%<>"GHI")}
  MDL>Do This
Else
  MDL>Do That
EndIf

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Post by Jerry Thomas » Fri Sep 13, 2013 2:57 pm

Any string will match this condition

Because if Var = ABC then it doesn't = DEF or GHI

It should be a positive compare

If>{(%var%="ABC")or(%var%="DEF")or(%var%="GHI")}
Thanks,
Jerry

[email protected]

EnderFFX
Pro Scripter
Posts: 92
Joined: Mon Mar 08, 2004 6:17 am

Re: The Unofficial Macro Scheduler Puzzler of the Week

Post by EnderFFX » Fri Sep 13, 2013 4:36 pm

JRL wrote:I want to assign to a variable the text value 1+1. How can I do that?

]
Can the answer be done in a single Let statement?

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

Post by JRL » Fri Sep 13, 2013 10:08 pm

Jerry,

Good job, that is correct. a string of "not equals" separated by "Or" will always evaluate to "True". Kind of a worthless test.




EnderFFX,
Yes

HabitualWerewolf
Newbie
Posts: 3
Joined: Wed Jul 14, 2010 9:33 am
Location: Saint Paul, Minnesota, United States of America
Contact:

Post by HabitualWerewolf » Sat Sep 14, 2013 7:35 am

The rookie part hasn't been answered yet has it?

I'm probably misreading the question or something because it sounds too easy but what the heck, here's my answer to
So lets get to the puzzles. For the beginners, I'll give 20 rep points to the first correct response for the following question.

I want to assign to a variable the text value 1+1. How can I do that?
Let>myVariable="1+1"

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

Post by JRL » Sat Sep 14, 2013 2:53 pm

HabitualWerewolf,

Nice try but that will leave quotes around the text. I don't want the quotes. You could do a second operation and stringreplace> the quotes away but there is an easy way to do this in one line.

Still looking for the easy answer.

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Post by Jerry Thomas » Mon Sep 16, 2013 2:14 pm

Just for general interest, there are at least 6 'alternative' ways to do this that don't involve using a 'Let' command, but are still completed in 1 line.
(They fall into the 'it's ugly but it works' category)

I'll wait til JRL calls this done to post those.
Thanks,
Jerry

[email protected]

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

Post by JRL » Wed Sep 18, 2013 5:05 am

I can think of 9 one liners and that doesn't include using VBScript which would likely provide several more one line methods. All one needs to do is find in the forum the syntax for using the Let> function.

This question was prompted by a co-worker who used the Separate> function to be able to set a customer part number to a variable. The part number was in the form 333-444. Trying to set it using Let> was giving him a result rather than the hyphenated P/N. I was a little flummoxed when I first saw what he had done, but I understood why he had done it, he didn't know the easy way using Let>.

Someone out there knows how to do this. Give the answer and grab some points for your effort.

If no one answers correctly I'll tell all on Friday the 20th. Also, I'll have another Puzzler.

User avatar
Grovkillen
Automation Wizard
Posts: 1131
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Post by Grovkillen » Wed Sep 18, 2013 8:07 am

Sorry for not sticking with the rules (I'm 50+ posts) but I have waited almost a whole week! :) Anyway here's a super hard coded solution to assign a variable the text "1+1". I.e. it's not very dynamic.

Code: Select all

Let>JRL={copy("1+1",0,3)}
MDL>JRL
Let>ME=%Script%

Running: 15.0.27
version history

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

Post by Marcus Tettmar » Wed Sep 18, 2013 11:47 am

Why use Copy to copy all characters from start to end - so your result is the same as the input - not sure what the point of that is. Or are you just showing off ;-)
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

User avatar
Grovkillen
Automation Wizard
Posts: 1131
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Post by Grovkillen » Wed Sep 18, 2013 12:02 pm

Yeah, Marcus... I'm always showing off :D

Anyway here's the not so super hard way to do the same thing:

Code: Select all

Let>JRL={"1+1"}
MDL>JRL
Let>ME=%Script%

Running: 15.0.27
version history

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

Post by JRL » Thu Sep 19, 2013 4:29 am

Grovkillen,

Congratulations, that is a correct answer and is the exact answer I was looking for though I'd have accepted others such as.

Code: Select all

Trim>1+1,var
Grovkillen wrote:...but I have waited almost a whole week!
Yes you have... good job and thank you for holding off for so long. I'll tell you what I'll do. I'll amortize the 20 rep points based on the percent you are past 50 posts and give you 16 points for your answer.

@Jerry,

Fire away with those alternate methods.

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Thu Sep 19, 2013 12:41 pm

Jerry Thomas wrote:Just for general interest, there are at least 6 'alternative' ways to do this that don't involve using a 'Let' command, but are still completed in 1 line.
(They fall into the 'it's ugly but it works' category)

I'll wait til JRL calls this done to post those.
Hi Jerry,
Would you please reveal your SIX "ugly but work" alternatives?
Thanks.

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Thu Sep 19, 2013 12:44 pm

Hi JRL,
I visit the water cooler late and miss the show.
Are there more puzzles this Fri?

User avatar
Grovkillen
Automation Wizard
Posts: 1131
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Post by Grovkillen » Thu Sep 19, 2013 1:20 pm

JRL wrote:Congratulations, that is a correct answer and is the exact answer I was looking for....
Thanks for the points!!! :) And thanks for the fun puzzle.
Let>ME=%Script%

Running: 15.0.27
version history

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