Search code examples
ibm-doors

Trying to understand the DOORS DXL interpreter: in place data


I have a problem understanding why the interpreter does not accept this:

Object co = current Object
Object o  = object(co."Absolute Number")

The error is: "incorrect arguments for function (object)" / "incorrectly concatenated tokens". I verified that the type returned by co."Absolute Number" matches the expectation of Object object(int absno[, Module m]) as it was declared according to the DXL manual:

print type(co."Absolute Number")

which prints "Integer". Appears to be fine, but obviously, it is not.

It is not a problem of that particular attribute. co."Object Text" should return a string, but with that attribute as well, the interpreter does not recognize the data type.

Adding brackets at various places does not help. Trying to explicitly convert the returned attribute value to integer does not help. What helps is storing the returned value to an integer variable:

Object co = current Object
int no    = co."Absolute Number"
Object o  = object(no)

which I do not like because it introduces unused variables. What works as well is to use the standard string approach: convert the attribute value to string and then (back) to integer:

Object o  = object(intOf(co."Absolute Number" ""))

but that is rather hacky for me. What did I overlook?


Solution

  • You are correct, the DXL compiler is a bit strange with things like this. The best way is the one you mentioned:

    Object co = current
    Object o  = object(intOf(co."Absolute Number" ""))
    

    Saving you from creating extraneous variables. Also, side note: you notice I left out Object after current as it is unnecessary.

    This also begs the question though... why do you need to create co and o, since once this is executed they are both handles to the same object. You can just do:

    Object o = current
    

    Hope this helps.