Syntax Error

Post Reply
mclarke
Member
Posts: 54
Joined: Thu Feb 28, 2013 5:29 pm
Location: Syracuse, NY

Syntax Error

Post by mclarke »

I'm trying to teach myself Javascript in order to better use the Scripting module. I have a question about a syntax error in my first script.
I'd like to set the value of a property in a flow element with a simple script. I came up with the following:

var fileStat = new FileStatistics(job.getPath());
var checkPath = fileStat.getString("[Metadata.Text:Path="/field-list/field[2]/value",Dataset="NYCM-Sort-Submit-All",Model="XML"]");
if checkPath === "FIRST CLASS" {
return "C:/JSON_files/NYCM-260.json";
}
return "C:/JSON_files/NYCM-261.json"

The value is from an XML submit point dataset. I'm sure I'm way off base, but would appreciate it for someone to explain what I did wrong.

Thank you.
cstevens
Member
Posts: 103
Joined: Tue Feb 12, 2013 8:42 pm

Re: Syntax Error

Post by cstevens »

FileStatistics are normally used for getting properties of a PDL file like number of pages, trim size etc. I think you want the embedded data set

Code: Select all

var dataset = job.getDataset("NYCM-Sort-Submit-All");
Then you can use evalToString to get the value you want out of the XML:

Code: Select all

var checkPath = dataset.evalToString("/field-list/field[2]/value", null);
mclarke
Member
Posts: 54
Joined: Thu Feb 28, 2013 5:29 pm
Location: Syracuse, NY

Re: Syntax Error

Post by mclarke »

I will make the change, thank you.

Enfocus doesn't really make interpreting the help file easy for beginners.
rgpepper
Member
Posts: 80
Joined: Wed Oct 14, 2015 2:09 am

Re: Syntax Error

Post by rgpepper »

mclarke wrote: Thu Apr 12, 2018 6:57 pm I will make the change, thank you.

Enfocus doesn't really make interpreting the help file easy for beginners.
Right??! It doesn't translate well, there's a "layer"missing I'd say.
mclarke
Member
Posts: 54
Joined: Thu Feb 28, 2013 5:29 pm
Location: Syracuse, NY

Re: Syntax Error

Post by mclarke »

Thanks to posters here and some dedicated Internet research on my own, I'm getting better at the simple scripting. But, this is one area that Enfocus could really help out new users. The flow element and apps from the store will only get you so far, if you need to move into more advanced flows.

I wouldn't even mind paying for good, Switch-focused online training in Javascript and script development.
jan_suhr
Advanced member
Posts: 586
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Syntax Error

Post by jan_suhr »

mclarke wrote: Wed Mar 27, 2019 2:00 pm I wouldn't even mind paying for good, Switch-focused online training in Javascript and script development.
Dwight Kelly have seminars now and then on Scripting Switch.

viewtopic.php?f=13&t=2239
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
Post Reply