Functionality Like Python Dictionary

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
CGooley
Newbie
Posts: 17
Joined: Tue Jun 25, 2019 6:13 pm

Functionality Like Python Dictionary

Post by CGooley » Mon Jul 01, 2019 4:51 pm

Hi,

I'm wondering if there is a functionality like a dictionary (https://www.w3schools.com/python/python ... naries.asp), where I can associate a list of values with their definitions.

I'm currently using if statements to achieve this, but perhaps there is a better way? Thanks!

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

Re: Functionality Like Python Dictionary

Post by JRL » Mon Jul 01, 2019 8:16 pm

Wow that's interesting!

Macro Scheduler doesn't have that but it does have python code execution capabilities. Have you tried that? SEE THIS Otherwise, can you show an example of what you're doing with IF> statements and maybe there are other ways to accomplish what you want to do. For example, some of the Python Dictionary functionality might be replicated using text files and SQL. Or perhaps by using JSONParse>. Or maybe by using labelToVar> then putting the list into an array using Separate> and working with the array.

I've done a little with python but not enough to be comfortable sharing. I think I'm going to see what I can do with the dictionary function. if nothing else it just looks like fun.

<After a bit of tinkering>
Here's an example from the page you provided. Be sure to read about PyExec> in the URL above. This doesn't work if the libraries are not installed.

Code: Select all

/*
python_code:
thisdict =  {
  "brand": "Ford",
  "model": "Mustang",
  "year": 1964
}

x = thisdict["model"]
*/

LabelToVar>python_code,pcode

PYExec>pcode,output,x

MDL>x

User avatar
PepsiHog
Automation Wizard
Posts: 393
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: Functionality Like Python Dictionary

Post by PepsiHog » Wed Jul 03, 2019 5:51 pm

@JRL,
Sounds like you're being rude if you read it quickly. :lol:

x = thisdict["model"]

Sorry, way too tempting. The devil made me do it.

PepsiHog
MS v14 Windows 10

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2018) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

CGooley
Newbie
Posts: 17
Joined: Tue Jun 25, 2019 6:13 pm

Re: Functionality Like Python Dictionary

Post by CGooley » Wed Jul 03, 2019 7:31 pm

Thank You!

I will take a look at this and play around.

Thanks again for helping this beginner.

Post Reply