Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Ruby win32ole properties
Andreas Warberg
6/26/2008 9:12:00 AM
Hi
I'm running simulations in Vissim using ruby and win32ole to connect to
a COM server.
I wish to set a parameter in the COM server using the following
description from the manual:
AttValue ([in] BSTR Attribute, [in] VARIANT Value)
Sets an evaluation attribute. Please get the language independent
attribute
tag from the table at the end of this section.
Parameters
[in] BSTR Attribute : Attribute name (see below)
[in] VARIANT Value : Attribute value. (type according to attribute)
Example
eval.AttValue(â??VEHICLERECORDâ??) = True
In Excel I have created the following sub to perform the task:
Sub test()
Dim vissim
Set vissim = CreateObject("VISSIM.Vissim")
vissim.LoadNet "mynet.inp"
Dim eval
Set eval = vissim.Evaluation
MsgBox "Before: " & eval.AttValue("NODE")
eval.AttValue("NODE") = 1
MsgBox "After: " & eval.AttValue("NODE")
vissim.Exit
End Sub
Which works fine.
In Ruby I am out of luck, however:
def test
vissim = WIN32OLE.new('VISSIM.Vissim')
vissim.LoadNet 'mynet.inp'
eval = vissim.Evaluation
puts "Before: #{eval.AttValue('NODE')}"
#eval.AttValue("NODE") = 1 # this doesn't work, obviously
eval.AttValue["NODE"] = 1 # error here number of parameters
puts "After: #{eval.AttValue('NODE')}"
end
Running test I get:
C:/greenwaves/code/test.rb:33:in `method_missing': AttValue
(WIN32OLERuntimeError)
OLE error code:0 in <Unknown>
<No Description>
HRESULT error code:0x8002000e
Invalid number of parameters.
I tried exchanging 'eval.AttValue["NODE"] = 1' with
eval.AttValue("NODE",1) which also complains about the number of
parameters.
Apparently I can only access the getter-method. Is there something else
I can try?
Kind regards
Andreas
--
Posted via
http://www.ruby-...
.
2 Answers
Siep Korteling
6/26/2008 9:47:00 AM
0
Andreas Warberg wrote:
> eval = vissim.Evaluation
Can't test your code, maybe the variable named 'eval' is confusing
things.
Regards,
Siep
--
Posted via
http://www.ruby-...
.
Andreas Warberg
6/26/2008 10:10:00 AM
0
Siep Korteling wrote:
> Can't test your code, maybe the variable named 'eval' is confusing
> things.
Nah that isn't it. I can't set global vissim parameters either:
irb(main):009:0> vissim = WIN32OLE.new('VISSIM.Vissim')
=> #<WIN32OLE:0x2c2a5cc>
irb(main):010:0> vissim.LoadNet 'mynet.inp'
=> nil
irb(main):011:0> vissim.AttValue('UNITDISTANCE1')
=> 0
irb(main):012:0> vissim.AttValue['UNITDISTANCE1'] = 0
WIN32OLERuntimeError: AttValue
OLE error code:0 in <Unknown>
<No Description>
HRESULT error code:0x8002000e
Invalid number of parameters.
from (irb):12:in `method_missing'
from (irb):12
irb(main):013:0> vissim.AttValue('UNITDISTANCE1',0)
WIN32OLERuntimeError: AttValue
OLE error code:0 in <Unknown>
<No Description>
HRESULT error code:0x8002000e
Invalid number of parameters.
from (irb):13:in `method_missing'
from (irb):13
irb(main):014:0>
No 'eval' involved.
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Ruby win32ole properties
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password