IBM Support

HD83706: API: CONDITION ERROR IN LOOP STATEMENT WITH TEXTSTREAM.ATENDOFS TREAM/OPENASTEXTSTREAM

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as Permanent restriction.

Error description

  • API: Condition error in loop statement with
    TextStream.AtEndOfStream/OpenAsTextStream.
    .
    Create a VBA project and add the code below.
    The first section gives a overflow because the
    boolean statement TRUE is ignored if
    oTextStream.AtEndOfStream is used.
    WorkAround suggestion is in the last section.
    .
    Sub CATMain()
    ' FIRST create a empty file "C:\test.txt"
    Dim oTextStream As TextStream
    Dim RLine As String
    Dim oFile As File
    Dim i As Integer
    i = 0
    Set oFile = CATIA.FileSystem.GetFile("C:\test.txt")
    Set oTextStream = oFile.OpenAsTextStream
    ("ForReading")
    '
    Do
    RLine = oTextStream.ReadLine
    i = i + 1
    If i > 3 Then
    MsgBox "Overflow error"
    GoTo OverFlow
    End If
    Loop Until oTextStream.AtEndOfStream
    MsgBox "No overflow error"
    OverFlow:
    '
    ' workaround
    Dim FileState As Boolean
    Do
    RLine = oTextStream.ReadLine
    If oTextStream.AtEndOfStream Then
    FileState = True
    End If
    Loop Until FileState
    End Sub
    .
    

Local fix

Problem summary

  • API: Condition error in loop statement with TextStream.AtEndOfS
    tream/OpenAsTextStream
    API: Condition error in loop statement with
    TextStream.AtEndOfStream/OpenAsTextStream.
    .
    Create a VBA project and add the code below.
    The first section gives a overflow because the
    boolean statement TRUE is ignored if
    oTextStream.AtEndOfStream is used.
    WorkAround suggestion is in the last section.
    .
    Sub CATMain()
    ' FIRST create a empty file "C:\test.txt"
    Dim oTextStream As TextStream
    Dim RLine As String
    Dim oFile As File
    Dim i As Integer
    i = 0
    Set oFile = CATIA.FileSystem.GetFile("C:\test.txt")
    Set oTextStream = oFile.OpenAsTextStream
    ("ForReading")
    '
    Do
    RLine = oTextStream.ReadLine
    i = i + 1
    If i > 3 Then
    MsgBox "Overflow error"
    GoTo OverFlow
    End If
    Loop Until oTextStream.AtEndOfStream
    MsgBox "No overflow error"
    OverFlow:
    '
    ' workaround
    Dim FileState As Boolean
    Do
    RLine = oTextStream.ReadLine
    If oTextStream.AtEndOfStream Then
    FileState = True
    End If
    Loop Until FileState
    End Sub
    .
    

Problem conclusion

  • THIS PROBLEM IS PERMANENT RESTRICTION IN
    CATIA.
    Incident Diagnosis:
    API: Condition error in loop statement with
    TextStream.AtEndOfStream/OpenAsTextStream
    .
    Restriction Explanation:
    boolean implemented differently between catia and
    vba.
    .
    From automation documentation :
    Support of boolean type in CATVBA
    There is a known limitation concerning the usage of
    the Boolean type in the V5 Automation methods
    invoked from VBA. In V5 applications, the Boolean
    type is defined as an 'unsigned char' where the
    VBA definition is a short. When a V5 method returns
    True, the returned integer value is 1, though VBA is
    expecting -1.
    Because of this difference, the following VBA code
    will not work as expected (the method boolMethod
    returns True) :
    .
    If myObj.boolMethod() = True Then // This test will
    fail
    ...
    End If
    .
    to correct this limitation, you have to write some
    code like this :
    If myObj.boolMethod() Then End If
    or
    If myObj.boolMethod() != False Then
    ...
    End If
    .
    For the same reason, the 'Not' operator cannot be
    applied directly on the returned value of such
    method:
    Not(myObj.boolMethod())
    will return True instead of returning False. To use
    correctly the 'Not' operator you have to use a
    variable to store the boolean value before applying
    the operator :
    .
    Dim myBool
    myBool = myObj.boolMethod()
    Not(myBool)
    .
    will correctly return False
    Note that this limitation is specific to VBA and is not
    concerning VBScript.
    .
    Following the Automation documentation, the
    customer code has to be replaced by the following :
    Dim TextIsFinished
    Do
    RLine = oTextStream.ReadLine
    TextIsFinished = oTextStream.AtEndOfStream
    MsgBox RLine
    Loop Until (TextIsFinished)
    .
    

Temporary fix

Comments

APAR Information

  • APAR number

    HD83706

  • Reported component name

    CATIA V5 NT>XP

  • Reported component ID

    569151000

  • Reported release

    519

  • Status

    CLOSED PRS

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2009-03-30

  • Closed date

    2009-04-10

  • Last modified date

    2009-04-10

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

Fix information

Applicable component levels

[{"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSVJ2K","label":"CATIA"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"519","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
10 April 2009