I have had one issue with my custom index search dialogue that I didn't resolve but circumnavigated.
I wanted to use a Case Switch operation to set one variable based on the return value of a dropdown list.
I have been unable to get the case switch to work but have used an if else sub to reach the same end (though less tidily I think).
The code that isn't working is:
var MatchOption = "";
switch (MatchOpt) {
case "Match Exact word or phrase":
MatchOption = "MatchPhrase";
break;
case "Match Any of the words":
MatchOption = "MatchAnyWord";
break;
case "Match All of the words":
MatchOption = "MatchAllWords";
break;
default: MatchOption = "Help"
}
MatchOpt is the return variable from the dropdown box and its value has been set to the current selection using the commands 'var oRslt = dialog.store();' and 'MatchOpt = (this.GetListSel(oRslt["pop1"],path))?path.reverse():"";' higher up in the code.
I added app.alert boxes into the code at the end of each case statement and then added the default: "Help" and another app.alert, to identify what the two variables were recorded as at each point through the process.
The return variable from the dropdown, MatchOpt, was correct (depending on the dropdown setting) at every stage but MatchOption remained null ("") regardless of what it should have read (one of the 3 case options) until it picked up the default value.
Would my problem be that the return value from the dropdown is a string containing multiple words, eg "Match Exact word or phrase" and the Case operation will only work on a single text word, eg. case "MatchExact": ~etc., rather than case "Match Exact word or phrase": ~etc. ?
Regards,
Nifty Styles
Norfolk, England
Using Acrobat 8.2.5 Professional
If you want to account for partial matches you need to use something else, like the match() or indexOf methods.
See here for more info: http://w3schools.com/jsref/jsref_obj_string.asp
Also, in your default clause you're not assigning the value to MatchOption.
- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com