-
1. Re: Exact pages path using regular wild card expression
Test Screen Name Aug 26, 2014 11:53 PM (in response to Jo_2013)I've never used regular expressions in JavaScript, but I have used them and I have this comment.
. (period) alone means "any single character".
.* means any number of characters
^.*$ means everyting, any number of characters from beginning to end of a line (i.e. the whole thing, or a whole line)
-
2. Re: Exact pages path using regular wild card expression
Test Screen Name Aug 26, 2014 11:54 PM (in response to Test Screen Name)If though you're saying you don't know the directory name, just the start of it, that is never going to work, not with any method.
-
3. Re: Exact pages path using regular wild card expression
try67 Aug 27, 2014 1:20 AM (in response to Jo_2013)What you're trying to do is not possible.
-
4. Re: Exact pages path using regular wild card expression
Jo_2013 Sep 1, 2014 11:21 PM (in response to Test Screen Name)I have been trying a script from the console as a test with mixed results.
The aim is to search the directory for a folder containing the text from the PackageNo field and the result will be shown an an application alert as a test.
eg PackageNo field = 002 compare to the Directory path = /h/Drawing Office/PDF/Scripting Form Fields/Mail Merge/002 - Centrifuge
The first time the script was run it actually worked, but after the first time it came up with the console error
sFolders is not defined
8:Console:ExecException in line 8 of function top_level, script Console:Exec
I am at a loss on how to fix this error, if you can please test the script and advise where it is going wrong, I will be most grateful, thanks.
This is the script
var pack = this.getField("PackageNo").valueAsString;
var topFolder = "/h/Drawing Office/PDF/Scripting Form Fields/Mail Merge/";
scanSubFolders(topFolder);
// extract the package number from the directory namevar f = sFolders.slice(0,3);
// if the directory package number is equal to the RFT package no
if (pack = f)
app.alert(f);
function scanSubFolders(tFolder) { // folder object, RegExp or string
var sFolders = new Array();
sFolders[0] = tFolder;
for (var j = 0; j < sFolders.length; j++){ // loop through folders
}
}; -
5. Re: Exact pages path using regular wild card expression
try67 Sep 2, 2014 12:36 AM (in response to Jo_2013)The scanSubFolders method doesn't seem to do anything... It just contains an empty loop and doesn't return any value.
If all you want to do is check if a specific string is present in another string just use the indexOf method, or the test method.
-
6. Re: Exact pages path using regular wild card expression
Jo_2013 Sep 4, 2014 11:22 PM (in response to try67)Thank you for your reply.
I have fixed so there is no empty loop and now have the entire script run from the function, and then tested in the console.
The console does not report back any errors but the application alert does not appear.
The directory sub folder "002 - centrifuge" actually exists, so that the alert should show.
Can you please give some insight as to why the script is not working?
var scanSubFolders = function(tFolder) {
tFolder = "/h/QCC Drawing Office/PDF/Scripting Form Fields/Mail Merge/";
var sFolders = new Array();
sFolders[0] = tFolder;
for (var j = 0; j < sFolders.length; j++){ // loop through folders
var fileString = String(sFolders[j]);
if (fileString = "002 - centrifuge")
{
app.alert(fileString);
}
else
scanSubFolders(sFolders[j]);
}
};
-
7. Re: Exact pages path using regular wild card expression
Bernd Alheit Sep 5, 2014 1:41 AM (in response to Jo_2013)sFolders[0] contains always "/h/QCC Drawing Office/PDF/Scripting Form Fields/Mail Merge/"
Why do you overwrite the parameter tFolder at the beginning of the function?
-
8. Re: Exact pages path using regular wild card expression
try67 Sep 5, 2014 2:22 AM (in response to Jo_2013)Also, this is a classic error:
if (fileString = "002 - centrifuge")
It needs to be:if (fileString == "002 - centrifuge")
-
9. Re: Exact pages path using regular wild card expression
Jo_2013 Sep 7, 2014 11:43 PM (in response to try67)Thanks , appreciate all your help.
I have modified the script as follows:
- replaced the = sign to ==
- Removed the reference to sFolders[0] = tFolder;
There are no errors in the console but the application alert is still not appearing.
Can you advise why it would not be working?
Script as follows:
var scanSubFolders = function(tFolder) {
tFolder = "/h/QCC Drawing Office/PDF/Scripting Form Fields/Mail Merge/";
var sFolders = new Array();
for (var j = 0; j < sFolders.length; j++){ // loop through folders
var fileString = String(sFolders[j]);
if (fileString == "002 - centrifuge")
{app.alert(fileString);
}
else
scanSubFolders(sFolders[j]);}
}; -
10. Re: Exact pages path using regular wild card expression
Bernd Alheit Sep 8, 2014 1:36 AM (in response to Jo_2013)In nthis case sFolders is always empty. Why do you change the value of the function parameter tFolder ?
-
11. Re: Exact pages path using regular wild card expression
Test Screen Name Sep 8, 2014 2:39 AM (in response to Bernd Alheit)I have no idea how you are trying to do what we have already says is impossible. There just doesn't seem to be anything in the script which even tries to scan a folder.



