Comparing a non-String, for example an integer
(Int), to a String is a problem
specific to each application.
- In the Jacl scripting language, essentially all data types including integers
are treated as strings during expression evaluation. As a result, the comparisons
work as intended.
- In Jython scripting language, there are dynamic types where the scripts
must use valid or matching types.
If your Jacl script contains an expression with a mixture of string and
integer types then you need to manually modify the converted Jython code to
use matching types. Otherwise, the expected conditions will not match. A
common source of this problem is that all command-line
argv parameters
are Strings:
JACL: set argvParam [lindex $argv 0]
JACL: while {i <= argvParam} {
==>
JYTHON: argvParam = sys.argv[0]
JYTHON: while (i <= argvParam):
Solution
Where applicable, manually insert explicit type conversion before
the comparison operations:
JYTHON: argvParam = int(sys.argv[0]) # manually modified
JYTHON: while (i <= argvParam):