<html>
<head>
<title>CATIA Starttool</title>
<HTA:APPLICATION
ID="myCATIA"
APPLICATIONNAME="myCatia"
SCROLL="no"
>
//****** Open last used environment and set it as default selection
<script type="text/javascript">
<!-- THESE 5 FUNCTIONS REPLACE ALL MISSING CODE
// Reads textfile, file is created automatically, if not exist
function readCustomers(){
var fso,iStream,cust,n,tarr;
customers={};
fso=new ActiveXObject('Scripting.FileSystemObject');
iStream=fso.OpenTextFile('C:/Temp/CAD_Kunde.txt',1,true);
cust=iStream.ReadLine();
for(n=0;!iStream.AtEndOfStream;n++){
tarr=iStream.ReadLine().split(';');
customers[n]=new Customer(tarr);
}
iStream.Close();
customers[0].selectionElement.selectedIndex=cust;
customers[cust].createReleaseOptions(cust);
window.activeCustomer=cust;
return;
}
// Customer (environment) constructor function
function Customer(txt){
var n,x=0;
this.selectionElement=document.getElementById('select1');
this.customerName=txt[0];
this.catiaRelease=[];
for(n=1;n<txt.length-1;n++){
this.catiaRelease[n-1]=txt[n];
x++;
}
this.len=x;
this.defaultOption=parseInt(txt[txt.length-1]);
this.selected=false;
this.createCustomerOption();
}
// Creates customer (environment) options
Customer.prototype.createCustomerOption=function(){
var opt;
opt=document.createElement('OPTION');
opt.text=this.customerName;
opt.value=this.customerName;
this.selectionElement.add(opt);
return;
}
// Creates release options
Customer.prototype.createReleaseOptions=function(idx){
var target,n,opt;
target=document.getElementById('select2');
target.length=0;
for(n=0;n<this.len;n++){
opt=document.createElement('OPTION');
opt.text=this.catiaRelease[n];
opt.value=this.catiaRelease[n];
target.add(opt);
}
target[this.defaultOption].selected=true;
//target[0].selected=true; // Move comment line above, if this option is used
window.activeCustomer=idx;
return;
}
// Saves textfile
function saveCustomers(){
var fso,oStream,n,m,str='',cust=document.getElementById('select1');eos=cust.length;
fso=new ActiveXObject('Scripting.FileSystemObject');
oStream=fso.OpenTextFile('C:/Temp/CAD_Kunde.txt',2,true);
oStream.WriteLine(cust.selectedIndex);
for(n=0;n<eos;n++){
str='';
str+=customers[n].customerName+';';
for(m=0;m<customers[n].len;m++){
str+=customers[n].catiaRelease[m]+';';
}
str+=customers[n].defaultOption;
oStream.WriteLine(str);
}
oStream.Close();
}
//***********
function OpenAction(object) {
self.resizeTo(299,299);
OpenActionVB();
readCustomers();
}
//********
function RunScript(object) {
saveCustomers();
BetriebssystemKommando(object.select1.options[object.select1.selectedIndex].value,
object.select2.options[object.select2.selectedIndex].value,
select3=document.getElementById('OSName'),
object.select4.options[object.select4.selectedIndex].value,
object.select5.options[object.select5.selectedIndex].value,
object.select6.options[object.select6.selectedIndex].value);
}
//******** checking 64-Bit or 32-Bit
OS = navigator.userAgent;
if (OS.indexOf("Win")!=-1) {
if ((OS.indexOf("Windows NT 5.1")!=-1) || (OS.indexOf("Windows XP")!=-1))
OSName="Win XP";
else if ((OS.indexOf("Windows NT 7.0")!=-1) || (OS.indexOf("Windows NT 6.1")!=-1))
OSName="Win 7";
else
OSName="Win Ver. Unknown";
// selection based on 64-Bit or 32-Bit
if ((OS.indexOf("WOW64")!=-1) || (OS.indexOf("x64")!=-1) || (OS.indexOf("Win64")!=-1) || (OS.indexOf("IA64")!=-1)) OSName= "DEFAULT_64"
else OSName="DEFAULT"
}
//********
//--></script>
<script language="vbscript">
Sub OpenActionVB()
cdiWorkDirRoot="C:\CDI"
cdiBinaryRoot="i:\cad\catiav5\CDI"
'*** CDI Software im Zugriff ?
set objFSO = createObject("Scripting.FileSystemObject")
If objFSO.FolderExists(cdiBinaryRoot) then
'*** CDIWORK Rootverzeichnis anlegen
If not objFSO.FolderExists(cdiWorkDirRoot) then
objFSO.CreateFolder(cdiWorkDirRoot)
End if
'*** CDIWORK Rootverzeichnis Vollzugriff für alle aus der Gruppe BGST-GL-PDMUSR
Set objShell = CreateObject("WScript.Shell")
If objFSO.FolderExists(cdiWorkDirRoot) Then
intRunError = objShell.Run("%COMSPEC% /c Echo J| cacls " & cdiWorkDirRoot & " /e /c /g BAT\BGST-GL-PDMUSR:F ", 2, True)
intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls " & cdiWorkDirRoot & " /e /c /g BAT\BGST-GL-PDMUSR:F ", 2, True)
End If
'*** CDIWORK Benutzerverzeichnis anlegen
Set objWSHNetwork = CreateObject("WScript.Network")
userName=objWSHNetwork.UserName
If not objFSO.FolderExists(cdiWorkDirRoot&"\"&userName) then
objFSO.CreateFolder(cdiWorkDirRoot&"\"&userName)
End if
'*** CDIWORK Verzeichnisstruktur im Benutzerverzeichnis anlegen
If not objFSO.FolderExists(cdiWorkDirRoot&"\"&userName&"\"&"WORK") then
objFSO.CreateFolder(cdiWorkDirRoot&"\"&userName&"\"&"WORK")
End if
If not objFSO.FolderExists(cdiWorkDirRoot&"\"&userName&"\"&"INDEX") then
objFSO.CreateFolder(cdiWorkDirRoot&"\"&userName&"\"&"INDEX")
End if
If not objFSO.FolderExists(cdiWorkDirRoot&"\"&userName&"\"&"LOG") then
objFSO.CreateFolder(cdiWorkDirRoot&"\"&userName&"\"&"LOG")
End if
If not objFSO.FolderExists(cdiWorkDirRoot&"\"&userName&"\"&"RFCTRACEDIR") then
objFSO.CreateFolder(cdiWorkDirRoot&"\"&userName&"\"&"RFCTRACEDIR")
End if
End if
End Sub
//*****************
Sub BetriebssystemKommando(Kunde,Version,Typ,Task,LocalSettings,LocalCache)
Set objFS = CreateObject("Scripting.FileSystemObject")
strTmpName = "C:\Temp\CAD_Kunde.txt"
Set objScript = objFS.CreateTextFile(strTmpName)
objScript.Write Kunde
objScript.Write select1
strCmdLine = "i:\metaph\pdmsetup & muxstart & dspstart -d & i:\catiav5\start\V5start.bat " & Kunde & " " & Kunde & "_" & OSName & " " & Version & " " & Task & " " & " I:\catiav5\start " & LocalSettings & " " & LocalCache
objScript.Close
Set objShell = CreateObject("WScript.Shell")
objShell.Run(strCmdLine)
End Sub
</script>
</head>
<body onload="OpenAction()" >
<style>
BODY
{
background-color:buttonface;
font-family: Helvetica;
font-size: 10pt;
margin-top: 10px;
margin-left: 10px;
margin-right: 10px;
margin-bottom: 10px;
}
</style>
<form name="formname">
<table style="width: 100%;" border="0" cellpadding="2"
cellspacing="0">
<tbody>
<tr>
<td>
Environment <br>
</td>
<td>
<select name="select1" id="select1" size="1" onchange="customers[this.selectedIndex].createReleaseOptions(this.selectedIndex);">
</select>
</td>
</tr>
<tr>
</tr>
<tr>
<td>
Release
</td>
<td>
<select name="select2" size="1" onchange="customers[activeCustomer].defaultOption=this.selectedIndex;">
</select>
</td>
</tr>
<tr>
<td>
Task
</td>
<td>
<select name="select4" size="1">
<option value="DEFAULT">DEFAULT</option>
<option value="AL2">AL2</option>
<option value="DMU">DMU</option>
<option value="EHD">EHD</option>
<option value="FEM">FEM</option>
<option value="IPPRO">IPPRO</option>
<option value="EHD">EHD</option>
<option value="KIN">KIN</option>
<option value="NC">NC</option>
<option value="ZADMIN">ZADMIN</option>
</select>
</td>
</tr>
<tr>
<td>
Delete user settings
</td>
<td>
<select name="select5" size="1">
<option value="1">YES</option>
<option value="0">NO</option>
</select>
</td>
</tr>
<tr>
<td>
Delete local cache
</td>
<td>
<select name="select6" size="1">
<option value="1">YES</option>
<option value="0">NO</option>
</select>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input id=runbutton class="button" type="button" value="Run" name="run_button" onClick="RunScript(document.formname)">
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
あなたは私を助けることができる1つの以上の時間を願っていますワーキング。 CAD_Kunde.txtを次のようにフォーマットします。
1
BEHR;B18 SP4;B18 SP7;0
AUDI;B19 SP3;0
BMW;B19 SP3;0
BIT;B18 SP4;B19 SP3;B16 SP9;0
1行目=ゼロベースのインデックス最後に使用された環境。
その他の行: 最初の行には環境名、次にすべてのリリース、最後の数字は0ベースのインデックスで、リリースはアクティブです。セミコロンで区切られたすべての値は、行末にスペースまたはその他の非印字文字(ENTER以外)を使用することはできません。ファイルの最後の行はemptylineで、は1つだけです。
コードはテキストファイルのエラーから保護されていません。セミコロンはデータとして使用することはできません。
環境やリリースも維持しやすく、テキストファイルに更新するだけです。
プログラムはすべてのクリックを選択ボックスで記憶し、Run
をクリックするたびにファイルを保存します。必要に応じて追加の保存ボタンを追加するのは簡単です。クリックしたリリースを保存したくない場合は、createReleases
のコメントを上記の行で切り替えてください。
この情報では難しいです。 'Option'宣言も投稿できますか? – Teemu
ええ、これは私が意味していたものではなく、 'Option'のコンストラクタ関数です。 'optionName'には何が含まれているのか分かりませんが、あなたの定義している' object.select2.options [x]のように見えます。最初は 'Option'オブジェクトの中で行い、その後は元のコードの2行後に再度行います。 – Teemu
コード全体を送信せず、 'Option'関数のみを送信してください。 – Teemu