Hiho @ all,
While working in a DOS-Box import works really fine. But writing a script
which imports the same pakages throws an exception.
Here the procedure (We're now inside the DOS-Box):
c:\>jython
Jython 2.0 on java1.3.0 (JIT:null)
Type "copyright", "credits" or "license" for more information.
>>> import fpformat
>>> print fpformat.fix(2.1, 0)
2
>>> [CTRL+C]
c:\>
I'm working with AdventNets' SimulationToolkit which simulates Agents'
behavior using jython-scripts. I need to convert an INT to a STRING but
found no hint to solve this problem. Therefore I'm using fpformat.fix()
because it returnes a string. But the following script always throws an
exception:
# ---------------------------------- start of jython script
----------------
# Import support for floating point
import fpformat
# Get the value of the scalar node (provided by the SimulationToolkit)
value = scriptinterface.getNodeValue(".1.3.6...")
# Convert the value to INT
valueAsInt=string.atoi(value)
# Add 1.1 to value
valueAsFloat=valueAsInt+1.1
# Cut all numbers after dot and dot itself und convert to string
value=fpformat.fix(valueAsFloat, 0)
# Write back (increased) value to node (provided by the SimulationToolkit)
scriptinterface.updateValue(".1.3.6...",value,"CONST")
# ---------------------------------- end of jython script ----------------
It works when done inside a DOS-Box running Jython as seen above. But the
script itself results in:
File "D:\AdventNet\simulator\mibs\_behavior_scripts_\script.py", line 2,
in ?
ImportError: no module named fpformat
Exception while executing the Python Script
which is loged in a log-file by the SimulationToolkit.
In search of the solution the Tutorial, the "How to" and the FAQ left me
unsuccessful and helpless. Has anybody any suggestion how to prevent this,
i.e. how to be able to import? Or any hint how to convert an INT to a
STRING without using this intricately solution?
TIA for your help.
Yours sincerely,
Joern
____________________________________________________________
MicroNova electronic GmbH
Joern Eckhoff
Kommunikation und Telekommunikation
Unterfeldring 17
D-85256 Vierkirchen
Tel.: (08139) 93 00-63
Fax.: (08139) 93 00-80
E-Mail: Joe...@mi...
WWW: http://www.micronova.de
____________________________________________________________
|