Using Java-COM Bridge

The OLE/COM adapter of Pnuts provides an easy way to access OLE/COM server of Windows like Visual Basic.

Any Java-COM bridge can be used with Pnuts to call COM objects, if the Java-COM bridge has a basic functionality to works with adapter classes. Currently there are a few Java-COM bridges that can be used with Pnuts. Please see http://www.etale.com/~tomatsu/pnuts/pnuts-com.html

The following script shows how its usage is similar to Visual Basic's.

use("vbscript")

objXL = CreateObject("Excel.Application")
objXL.Workbooks.Add()
objXL.Cells(1, 1).Value = 5
objXL.Cells(1, 2).Value = 10
objXL.Cells(1, 3).Value = 15
objXL.Range("A1", "C1").Select()

objXLchart = objXL.Charts.Add()
objXL.Visible = true
objXLchart.Type = -4100

for (i = 5; i < 180; i += 5){
   objXLchart.Rotation = i
}

for (i = 175; i >= 0; i -= 5){
   objXLchart.Rotation = i
}

Here is another example. This function shows a web page on Internet Explorer.

use("vbscript")

function ie(url){
  explorer = CreateObject("InternetExplorer.Application")
  explorer.Visible = True
  explorer.Navigate(url)
}

Since program using the Java-COM bridge cannot be protected by Java2 security framework, this feature shouldn't be used when scripts can be untrusted.


Back