[VBS ] Wscript物件使用
各位大大你好
我們有個系統 是用來顯示連續的圖片
而這些圖片呢 是要經過一個叫 ESRI ArcMap這個軟體所繪製的
然後繪製圖片需要很多步驟
所以ArcMap它裡面有一個功能 叫 Model Builder
可以把這些動作都包起來
此外它還可以輸出成 VB Script的碼
不過它只有片段而已 並不是可以執行的
所以我想到是寫一段 VB Script 把它加在系統的網頁裡
<html>
<head>
<script language="VBScript">
Sub RunProgram
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "ArcMap.exe D:\test.mxd"
' Create the Geoprocessor object
set gp = WScript.CreateObject("esriGeoprocessing.GPDispatch.1")
' Check out any necessary licenses
gp.CheckOutExtension "GeoStats"
' Load required toolboxes...
gp.AddToolbox "C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Geostatistical
Analyst Tools.tbx"
gp.AddToolbox "C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management
Tools.tbx"
' Set the Geoprocessing environment...
gp.scratchWorkspace = "C:\test"
' Script arguments...
請在”=”後鍵入週數,例如2007年第1週,就輸入200701 =
wscript.arguments.item(0)
if 請在”=”後鍵入週數,例如2007年第1週,就輸入200701 = "#" then
請在”=”後鍵入週數,例如2007年第1週,就輸入200701 = """周別"" = 200701" '
provide a default value if unspecified
end if
請選擇圖層 = wscript.arguments.item(1)
if 請選擇圖層 = "#" then
請選擇圖層 = "testpoint" ' provide a default value if unspecified
end if
GA_lyr = wscript.arguments.item(2)
if GA_lyr = "#" then
GA_lyr = "C:\test\GA.lyr" ' provide a default value if unspecified
end if
匯出的圖層 = wscript.arguments.item(3)
if 匯出的圖層 = "#" then
匯出的圖層 = "C:\test\point_test.shp" ' provide a default value if
unspecified
end if
' Local variables...
點圖層暫存 = "testpoint"
GA_Layer暫存 = "GALayer"
Ordinary_Kriging = "Ordinary Kriging"
' Process: 利用屬性選取...
gp.SelectLayerByAttribute_management 請選擇圖層, "NEW_SELECTION", 請在”=”後
鍵入週數,例如2007年第1週,就輸入200701
' Process: 匯出所選取的圖層...
gp.CopyFeatures_management 點圖層暫存, 匯出的圖層, "", "0", "0", "0"
' Process: Create Geostatistical Layer...
gp.GACreateGeostatisticalLayer_ga Ordinary_Kriging, "C:\test\point_test.shp 病
例比率千", GA_Layer暫存
' Process: Save To Layer File...
gp.SaveToLayerFile_management GA_Layer暫存, GA_lyr
End Sub
</script>
</head>
<body>
<button onclick="RunProgram">Run Program</button> <p>
</body>
</html>
執行結果 它是說 型態不符合 RunProgram
不知道哪邊的程式有問題呢
謝謝大家
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 211.76.175.169