It seems Jscript is missing the ability to read from a PATH using WILDCARDS to create a Array of File Names. It would be complimentary to the File Helpers you have now.
Some like: filearray = file.ReadFromPath(filePath,wildcards|name);
Wildcards|Name values could be “.CVS"or “MyFile.txt” or "My.*”
function getFileList(p,f)
{
var objFSO = new ActiveXObject("Scripting.FileSystemObject");
var fldr = objFSO.GetFolder("D:/Programs/POS/");
var files = new Enumerator(fldr.Files);
var fileList = new Array();
var fltext = "";
for (; !files.atEnd(); files.moveNext()) {
fileList.push(files.item());
fltext += files.item() + "\r\n";
}
//return fileList.length;
return "Count:"+fileList.length + "\r\n" + fltext;
//return fileList;
}
You would need to build a routine to parse the wildcards and sort things out to return an array, but it could become a useful utility/function to have on-hand.
Yea read up on “ActiveXObject” and saw a few issues with compatibility going forward. I elected to do something simple with “ACTION: Start Process” and DIR C:\SPOS\*.clb /b > C:\SPOS\check_clb.out - directing output to a text file.
Reading the file is easy using file.ReadFromFile(filePath);.
Sorry for bumping an old thread but during implementation of this function @emre I realised we do not have a “File.Exists” feature to check for existence of a File or Directory?
If we use a path parameter that does not exists Samba crashes out.
I currently have implemented:
var fso = new ActiveXObject("Scripting.FileSystemObject") ;
if (!fso.FolderExists(path)) {
dlg.ShowMessage("Folder does not exist!:" + path) ;
return '' ;
}