Page 1 of 1

reading folder on a mapped network drive - not work

Posted: Tue Oct 10, 2017 9:00 pm
by bepsy72
Hi,
I'm trying to read a folder on a mapped network drive, but is doesn’t work.
The strange things is that the script work when i test it with a fixture pane in SwitchScripter, and give me the results.
When i run the script whitin a flow i got an error. (Error in line 56 of script : Error. Trying to access undefined member '3')

Any suggestion?




Here my code

function GetMyFolderList(mydir){

var MyDir = new Dir(mydir);
var FolderList = MyDir.entryList("*");
return FolderList;
}


function jobArrived( s : Switch, job : Job )
{

// work on test, not work in a flow
var lista = GetMyFolderList("X:\\");
s.log(1,lista[3]); // Error in line 56 of script : Error. Trying to access undefined member '3'

// work on test, work in a flow
var lista = GetMyFolderList("C:\\");
s.log(1,lista[3]);


}

Re: reading folder on a mapped network drive - not work

Posted: Tue Oct 10, 2017 9:06 pm
by jan_suhr
Have you tried with another item from the list, like the first one [0]

Re: reading folder on a mapped network drive - not work

Posted: Tue Oct 10, 2017 9:15 pm
by bepsy72
Yes, I've tried now, but nothing to do. Same error.
Error in line 54 of script : Error. Trying to access undefined member '0'

Its probally Javascript that doesn't read a network drive?

Re: reading folder on a mapped network drive - not work

Posted: Tue Oct 10, 2017 9:21 pm
by jan_suhr
Have you tried with the server name instead of X, like //SERVER_NAME/

Re: reading folder on a mapped network drive - not work

Posted: Tue Oct 10, 2017 9:33 pm
by cstevens
I'm not sure that's a valid call for an entry list. It should have 3 arguments like this:

entryList( filter : String, filterSpec : Number, sortSpec : Number )

or in your code

var FolderList = MyDir.entryList( "*.*", Dir.Files, Dir.Time);

That would return all files sorted by modified date.

If that doesn't work try outputing the results in a log message:

s.log(1, lista.toString());

to see if you're returning anything valid from your function call.

Re: reading folder on a mapped network drive - not work

Posted: Tue Oct 10, 2017 9:56 pm
by bepsy72
I try with //SERVER NAME/ and it work fine!!!
:D Thanks!!