Arithmetic Operators as variables

Ideas for new features & functions

Moderators: Dorian (MJT support), JRL

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

Arithmetic Operators as variables

Post by Grovkillen » Wed Dec 15, 2021 10:18 am

It would be useful to be able to set the operator programmatically instead of hardcoded like it's now.

Code: Select all

Let>OPERATOR=+
Let>TERM_1=20
Let>TERM_2=12

Let>RESULT={(%TERM_1% + %TERM_2%)}
//These are not working... could be useful if they did
Let>RESULT={(%TERM_1% %OPERATOR% %TERM_2%)}
Let>FULL_FUNCTION=%TERM_1% %OPERATOR% %TERM_2%
Let>RESULT={(%FULL_FUNCTION%)}
Let>ME=%Script%

Running: 15.0.24
version history

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

Re: Arithmetic Operators as variables

Post by JRL » Wed Dec 15, 2021 9:20 pm

This works for me.

Code: Select all

Let>OPERATOR=+
Let>TERM_1=20
Let>TERM_2=12
LabelToVar>Full_Function,vCode

IncludeFromVar>vCode
MDL>res


Let>OPERATOR=-
Let>TERM_1=44
Let>TERM_2=19
LabelToVar>Full_Function,vCode

IncludeFromVar>vCode
MDL>res

/*
Full_Function:
  Let>RES={(%Term_1% %OPERATOR% %Term_2%)}
*/

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

Re: Arithmetic Operators as variables

Post by Grovkillen » Thu Dec 16, 2021 9:00 am

Ah! Smart, thank you for this.
Let>ME=%Script%

Running: 15.0.24
version history

hagchr
Automation Wizard
Posts: 327
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: Arithmetic Operators as variables

Post by hagchr » Thu Dec 16, 2021 11:59 am

Or use tmp variable

Code: Select all

Let>OPERATOR=+
Let>TERM_1=20
Let>TERM_2=12
Let>RESULT={(%TERM_1% + %TERM_2%)}

Let>tmp=%TERM_1% %OPERATOR% %TERM_2%
Let>RESULT={tmp}

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

Re: Arithmetic Operators as variables

Post by JRL » Mon Dec 20, 2021 2:01 pm

Nice solution! I like it!

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

Re: Arithmetic Operators as variables

Post by Grovkillen » Mon Dec 20, 2021 2:45 pm

Clean! Thanks!!
Let>ME=%Script%

Running: 15.0.24
version history

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