Dalim TWiST Best Practice: Managing Regular Expressions

Posted by Scott Tully on Tue, Apr 30, 2013 @ 01:05 PM

Tags: Best Practice, TWiST, RegEx, Regular Expressions, SetParamFromRE

Ask any experienced Dalim TWiST Administrator, "what's the key to TWiST workflow engineering success?" and they will likely respond with "Reg Ex" (short for Regular Expressions) and "SetParamFromRE" (set parameter from regular expression). I would add "TwistTable" and say, "master these three elements and you can do just about anything in TWiST".

Even so, I wish to bring to your attention a fourth element, an often unnoticed, unused feature of the SetParamFromRE tool: the "Manage Expressions" feature.

Expressions Button

 

So, what have you been missing?

Using the Manage Expressions feature allows you to save, and over time, build-up a "library" of expressions that will undoubtedly save you and your organization hundreds of TWiST man-hours. On a more personal-level, having a library of expressions will save hours of [workflow] debugging heartache.

If I had a dollar for every time I had typed [getmem Document SizeMM_Width], ran a file, found the value to be empty and gone back into SetParamFromRE to fix it…(sharp Admins already see the issue, don't you?)...I could have bought a Dunkin' Donuts franchise.

The problem, if you have not spotted it, is a single keystroke: "m". The correct syntax is: [getMem Document SizeMM_Width], which returns the value of the variable $TwistTable(Document,SizeMM_Width), the width of the document in millimeters (mm).

You see, simple typo's are thieves of time. Taking action to prevent them is a wise investment that will promptly pay dividends. I encourage you to start building your own library of frequently used expressions, today.

Where to begin?

A great place to start is the "Document" category. This default TwistTable category contains the most commonly used/needed workflow variables like geometry, resolution, colorspace, and channels. Just drop a FileCheck and ShowMemories tool in your most active production workflow and you'll quickly see that there are 36+ variables containing 'decision-making' values.

Expressions Menu

Heck, I'm willing to bet you are already calling 2 or more Document category variables in the majority of your published workflows now.

Once you've become familiar with the functionality of the Manage Expressions feature, it's up to you to make using it a part of your workflow engineering process. I'm confident that you're already thinking of adding a few custom expressions, you know the ones, those situational statements that took a bit of trial and error to work out, as prime candidates for your new library.

Here's a non-TwistTable expression that every TWiST Admin needs. In the image below, I'm using the command expr, to convert millimeters (mm) to inches (in) on-the-fly. This expression, along with "Convert SizeMM_Height to Inches" were probably the first expressions I saved when Manage Expressions was added to the SetParamFromRE tool in 2007.

Managing Regular Expressions

You may be wondering, "if I'm saving these expressions, where is the parameter file?"

Your valuable keystrokes are stored automatically by TWiST in a separate, parameter-like configuration file: Expressions.cnf. Location: /symlnks/var/6.0/setup/TWiST/Expressions.cnf

Take care friends, it's easy to overwrite this valuable file [arrrgh]…so I suggest keeping a copy outside of your TWiST environment as your investment grows.

One last nugget: if you manage a multi-host environment or work in a multi-site organization, you can distribute the Expressions.cnf file. In this way, you can share your contributions with a colleague and build-up the ultimate expressions library.

As always, consult your User Documentation as the primary resource for all things TWiST.