Process Switch Variables

Post Reply
User avatar
JimmyHartington
Advanced member
Posts: 489
Joined: Tue Mar 22, 2011 7:38 am

Process Switch Variables

Post by JimmyHartington »

I am trying to create a script, which can recieve HTML input in various ways.
  • Single line text with variables
  • Multi line text with variables
  • Static file
  • Incoming job or
  • Dataset
When using the Single/multi line text with variables a variable as [Job.NameProper] or [Job.PrivateData:Key="UUID"] gets replaced with the correct values.

But if I read a static file with this content in my script the variables are not replaced.

Code: Select all

<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
<p><strong>Name: </strong>[Job.NameProper]</p>
</body>
</html>
I can not seem to find in the documentation for scripting if this is possible.

What would be a dream scenario is to have a Process Switch Variables Yes/No list.
freddyp
Advanced member
Posts: 1153
Joined: Thu Feb 09, 2012 3:53 pm

Re: Process Switch Variables

Post by freddyp »

In the case of something with variables, it is Switch that evaluates the input before passing it to your script. In the case of a static file, Switch does not read the file, it only gives you the path. It is your script that reads the file, so any string replacements in the file are up to your script. You can do what you want by searching with a regular expression that returns a list of matches and you loop over the matches to replace them.

You could also use the "String Replace" app: inject your static file, send it through "String Replace", pick it up as a dataset and use the dataset in your script.

Note that in either case you can also work with your own variable strings in the static file, they do not have to be Switch variables.
User avatar
JimmyHartington
Advanced member
Posts: 489
Joined: Tue Mar 22, 2011 7:38 am

Re: Process Switch Variables

Post by JimmyHartington »

So there is no way in a script to use a Switch class or function to take the string and replace all Switch Variables?
freddyp
Advanced member
Posts: 1153
Joined: Thu Feb 09, 2012 3:53 pm

Re: Process Switch Variables

Post by freddyp »

No.
Post Reply