Plex 2E

  • 1.  Meta Loops and Source Codes

    Posted Jun 05, 2017 10:41 AM

    Hi,

     

    Anyone knows if it is possible to call a source code mapping the current field as the parameter to that source code?

     

    Best regards.



  • 2.  Re: Meta Loops and Source Codes

    Posted Jun 05, 2017 01:06 PM

    please give a better description of what you are trying to do so I can say how I would solve your problem. I may well say with loops and source codes but currently I don't understand what you want to achieve and also what technique you are trying to do the accomplish the task while using meta and source code



  • 3.  Re: Meta Loops and Source Codes

    Posted Jun 06, 2017 05:07 AM

    Hi George,

     

    Sorry for not being clear enough. Our ultimate goal is to concatenate a conversion to string of all fields of a particular variable. The problem is we need to convert fields to string in an invariant, culture independent, way. Using ++cast to wilds different results for number, for example. They can be formatted using ',' or '.' as a decimal separator depending on configuration.

     

    Using Plex 721 we managed to work around this by casting the "current field" to a field of "type SYS" Object and then casting this object to a character field. Objects of type ObObjFld (java ObRun) just call a toString of the underlying data object. Javas toString of Dates, BigDecimals, etc is culture independent, which is what we want.

     

    But we also need to do this using Plex 500, so we need a different solution. Plex 500 does not suport fields of type Object (for java at least). One of the ways we could achieve this would be to control the way the field is being cast to an ObCharFld using source code. If we managed to call

    &(1:).getData().toString();

    for each field we would have achieved our goal. But it doesn't seem to be possible to call a source code while mapping the field of a "+for each field" meta loop as a parameter.

     

    We could check the [type sys] of the current field, cast it to a generic field of the same type, and then call a source code to convert it to string. The problem with this approach is that the generic field may have different restrictions than the actual field, and we could end up losing information while casting, which would be a problem.

     

    The only solution we reached was defining a "special type NME ... output FNC" with a conversion function, and then defining a conversion function for that field. But this forces us to define a bunch of functions which we would like to avoid.

     

    Best regards.



  • 4.  Re: Meta Loops and Source Codes

    Posted Jun 06, 2017 04:29 PM

    sorry no idea.

     

    seen this meta name operator  ++Symbolic Name ?.

     

    Why do you need to concatenate fields of variables?



  • 5.  Re: Meta Loops and Source Codes

    Posted Jun 07, 2017 05:21 AM

    «++Symbolic Name

     

    It's an idea. We probably could use this in conjunction with reflection and access the field dynamically.

     

    «Why do you need to concatenate fields of variables?»

     

    We were implementing a function prototype that would return a hash code of a set of input fields. It would be fairly simple if we could control the way fields are converted to strings, but alas.