<html>
<head>
<title></title>
<HTA:APPLICATION ID="xyzabc" APPLICATIONNAME="asgasd" SCROLL="yes" SINGLEINSTANCE="yes"/>
<style type="text/css">
* { font-family:courier new; font-size:14px; }
</style>
<script type="text/jscript">
//-----------------------------
var locations = {
posA: "H:/Schnitt_IGES/A319",
posB: "O:/SCHNITT_IGES_2003_02_25/A319",
posC: "O:/SCHNITT_IGES_2003_02_25/A318-A321_SA_Matten",
infile: "c:/test/STL_A319_A058_IN.txt",
outfile: "c:/test/STL_A319_A058_OUT.txt"
};
//-----------------------------
function getCommandline()
{
var cmln = xyzabc.commandLine.replace(/ /g,"").split("-");
if( cmln.length == 3 )
{
locations.infile = cmln[1];
locations.outfile = cmln[2];
}
};
//-----------------------------
function init()
{
var infile, list;
getCommandline();
list = getSortedList();
infile = loadFile( locations.infile ).replace(/\r\n/g,"\n").split("\n");
save( checkIfInFileList( list, infile ) );
}
//-----------------------------
function checkIfInFileList( list, infile )
{
var i,temp;
var out = [];
for( i = 0; i < infile.length; i++ ) { out = out.concat( findInList( infile[i] ) ); }
return out;
function findInList( s )
{
var i = 0;
var out = [];
for( i = 0; i < list.length; i++ )
{
if( s == list[i].n.join("_").substr( 0, 14 ) ) out.push( list[i] );
}
if( out.length == 0 ) return [s];
return out;
}
};
//-----------------------------
function save( list )
{
var out = [];
for( var i = 0; i < list.length; i++ )
{
if( list[i].n )
{
out.push( list[i].n.join("") + ".nc" );
msg( i + " " + list[i].n + " - " + list[i].p );
}
else
{
out.push( "! datei nicht gefunden: '" + list[i] + "'" );
msg( i + " " + "! datei nicht gefunden '" + list[i] + "' !" );
}
}
saveFile( locations.outfile, out.join("\r\n") );
};
//-----------------------------
function getSortedList()
{
var out = new Array();
var locs = [ locations.posA, locations.posB, locations.posC ];
var temp, i, k;
for( i = 0; i < locs.length; i++ )
{
temp = getFiles( locs[i], 5 )[1];
for( k = 0; k < temp.length; k++ )
{
temp[k] = { p:temp[k].path, n:temp[k].name };
temp[k].p = temp[k].p.replace(/\\/g,"/");
temp[k].p = temp[k].p.substr( 0, temp[k].p.lastIndexOf("/") );
temp[k].n = temp[k].n.split(".")[0];
temp[k].n = [ temp[k].n.substr( 0, 14 ), temp[k].n.substr( 14 ) ];
out.push( temp[k] );
}
}
out.sort( sort );
out = findLast( out );
return out;
//__
function sort( a, b )
{
var i;
a = a.n;
b = b.n;
for( i = 0; i < a.length; i++ )
{
if( !b[i] ) return 1;
if( a[i].length > b[i].length ) return 1;
if( a[i].length < b[i].length ) return -1;
if( a[i] > b[i] ) return 1;
if( a[i] < b[i] ) return -1;
}
return 0;
};
//__
function findLast( arr )
{
var i = 0;
var out = new Array();
var temp = [];
var current000, last000;
var currentX, lastX;
var current00x, last00x;
for( i = 0; i < arr.length; i++ )
{
current000 = arr[i].n[0];
current00x = arr[i].n[1].split("_")[1];
currentX = arr[i].n[1].split("_")[0];
if( last000 != current000 )
{
out = out.concat( temp );
temp = [];
}
if( i > 0 && lastX != currentX ) { temp = []; }
temp.push( arr[ i ] );
last000 = current000;
lastX = currentX;
last00x = current00x;
}
return out;
};
};
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
function loadFile(FileName)
{
var fso,f1;
var FileStr = "";
fso = new ActiveXObject("Scripting.Filesystemobject");
if(fso.FileExists(FileName))
{
f1 = fso.OpenTextFile(FileName, 1);
if(f1.AtEndOfStream) msg("(!) Die Datei ist leer<br>", true); else FileStr = f1.ReadAll();
f1.close();
}
else { msg("(!) Datei nicht gefunden! --->" + FileName + "<br>", true); }
return FileStr;
}
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
function saveFile(FileName,str)
{
var fso, folder, file, foldername;
//____
function getfoldername(s) { s = s.replace(/\\/g,"/"); s = s.substr( 0, s.lastIndexOf("/") ); return s; }
fso = new ActiveXObject("Scripting.Filesystemobject");
foldername = getfoldername(FileName);
if(fso.FolderExists(foldername))
{
folder = fso.Getfolder(foldername);
if(folder.attributes!=16&&folder.attributes!=48)
{
msg("[savefile] kann auf Verzeichnis nicht zugreifen ---><b>" + foldername + "</b> (att:" + folder.attributes + ")");
return false;
}
if(fso.FileExists(FileName))
{
file = fso.GetFile(FileName);
if(file.attributes!=0&&file.attributes!=32)
{
msg("[savefile] kann auf Datei nicht zugreifen ---><b>" + FileName + "</b> (att:" + file.attributes + ")");
return false;
}
}
file = fso.OpenTextFile(FileName, 2, true);
file.write(str);
file.close();
}
else
{
msg("Verzeichnis nicht gefunden! ---><b>" + foldername + "</b>");
}
}
//-----------------------------------------------------------------------------------
//-- returns an array: [ array of folder objects, array of file objects ]
//-- filter:
//-- n = 0000 (0): all folders and subfolders and all files
//-- n = 0001 (1): no folders
//-- n = 0010 (2): no files
//-- n = 0100 (4): no subfolders
//-- ext = extension as STRING
//-- part = member as STRING, eg. "name"
//-----------------------------------------------------------------------------------
function getFiles( startfolder, n , ext, part )
{
if( !n ) n = 0;
var fso = new ActiveXObject("Scripting.FileSystemObject");
var folders = new Array();
var files = new Array();
if( !fso.FolderExists( startfolder ) )
{
msg("(!) Folder " + startfolder + " not found!", true );
return [ [],[] ];
}
getNext( startfolder );
return [ folders, files ];
function getNext( fld )
{
var folderObj = fso.getFolder( fld );
var filesEn, foldersEn;
var tmp = "";
if( (n & 2) == 0 )
{
filesEn = new Enumerator( folderObj.Files );
for (; !filesEn.atEnd(); filesEn.moveNext())
{
tmp = filesEn.item().name;
if( typeof(ext) == 'undefined' || tmp.substr( tmp.length - ext.length, ext.length ).toLowerCase() == ext.toLowerCase() )
{
if( typeof(part) != 'undefined' && filesEn.item()[part] != 'undefined' )
files.push( filesEn.item()[part] )
else
files.push( filesEn.item() );
}
}
}
if( (n & 1) == 0 )
{
folders.push( folderObj );
foldersEn = new Enumerator( folderObj.SubFolders );
if( (n & 4) == 0 )
{
for (; !foldersEn.atEnd(); foldersEn.moveNext()) getNext( foldersEn.item().path );
}
}
}
}
//-----------------------------
function msg( s ) { document.getElementById("msgs").innerHTML += s; }
</script>
<script type="text/vbscript">
</script>
</head>
<body onLoad="init()">
<div id="msgs"></div>
</body>
</html>
so sieht datt ding aus,was ich einbinden möchte.
mein teil,wo also dieser script ausgerufen wird, sieht bisher so aus:
function Go()
{
};
der html-teil so:
<td colspan=10 align="center">
<input type="button" value="Start" name="Start" onClick="Go()" disabled></input></td>
<td width=10></td>
die ausgabe soll hier erfolgen:
<td width=10></td>
<td height=355 width=1000 colspan=10 bgcolor=white border=2px><div id="msgs" class="rollbalken"></div></td>
<td width=10></td>
was muss ich nun weglöschen bzw wo einbinden,das er mir das ausgibt,was er sonst in einem neuen fenster tun würde?
lg romero