/file 2/i.test(value)
The above is what is called a regular expression. These are similar to using:
If value contains "file 2"
… in the Actions Editor.
You can read about building JavaScript regular expressions in many places on the web.
They allow for more flexibility in constructing logical expressions.
Here is one of many links explaining how they work.
https://blog.bitsrc.io/a-beginners-guide-to-regular-expressions-regex-in-javascript-9c58feb27eb4You define a pattern and then test a variable for the presence of the value.
/[pattern]/i //(The i is a flag means to ignore case sensitivity. Otherwise, string is evaluated by case.)
You can assign regular expressions to variables and use them over and over in your code:
var re = /file \d/i;
if ( re.test(value) ) {
//Do some stuff because [value] contains "file " followed by a single digit 0-9.
}
You can test your expression by writing some basic code in the PowerPac exeJavascriptDirect code tester page:
https://pgsoftwaretools.com/powerpac/assessments/exec-js/index.htmlFor example, the original expression could also have been more simply written like this:
/\d$/i.test(value)
… and it would return true if the [value] ENDED in a single digit 0-9.
OR even like this:
/^load.*\d$/i.test(value)
… and it would return true ONLY if [value] BEGAN with the string "load" and ENDED in a single digit 0-9.
So if [value] = "load file 3" the expression would evaluate to true because the expression starts with the string "load" and ends with the digit 3.
But I didn't use these additional examples because in the ToolBook example I submitted, I needed to know which number the string ended in rather than just whether it ended in a number.
Regular expressions are supported in many PowerPac functions that involve searching for objects, splitting into arrays, etc.
Considering the magnitude of your project, learning to write these expressions would be a huge plus for you.