variable script expression

Post Reply
User avatar
_Thibs_
Newbie
Posts: 10
Joined: Mon Nov 06, 2017 3:19 pm

variable script expression

Post by _Thibs_ »

Hello,

Curently I'm trying to use the variable script expression to define a choice of variable in a check point with an external metada (from a XML file).
Here is my code :

Code: Select all

function choixqte() {
	var Xpathquantites = [Metadata.Text:Path=''/gaxml/Quantités'',Dataset=''Xml'',Model=''XML''];
	var qauntites = job.getVariableAsString(Xpathquantites);
	var Xpathqrequiredquantity = [Metadata.Text:Path=''/gaxml/RequiredQuantity]'',Dataset=''Xml'',Model=''XML''];
	var requiredquantity = job.getVariableAsString(Xpathqrequiredquantity);					  
	if qauntites != "" {
		return qauntites;
}
	else { return requiredquantity; }
}
Switch returns a syntax error. Do you have any idea why ?

Thanks a lot in advance,
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: variable script expression

Post by freddyp »

Your Xpathquantites variable is not a string. The same for Xpathqrequiredquantity.
Even with that out of the way, it will still not work because you define a function but you do not call it. Add

Code: Select all

choixqte();
as the last line.
Alternatively, do not use a function, but in that case, and this is very important when using script expressions, you must not "return" a value, but simply "state" it:

Code: Select all

if qauntites != "" {
	qauntites;
} else {
	requiredquantity;
}
r.zegwaard
Member
Posts: 93
Joined: Fri Jul 08, 2011 10:31 am
Location: The Netherlands

Re: variable script expression

Post by r.zegwaard »

Code: Select all

if qauntites != "" {
Place brackets in the if statement

Code: Select all

if (qauntites != "") {
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: variable script expression

Post by freddyp »

Of course! Blind copy&paste error :oops: . Thanks.
User avatar
_Thibs_
Newbie
Posts: 10
Joined: Mon Nov 06, 2017 3:19 pm

Re: variable script expression

Post by _Thibs_ »

Thanks I try that
Post Reply