Page 1 of 1

Call Transforms in a controlling job

Posted: Mon Feb 16, 2004 1:48 am
by spracht
I tried to use the transform 'NullToZero' in a controlling job and declared it like this (also tried some other ways):

Deffun NullToZero(A1) Calling "DSX.NULLTOZERO"

Is it possible at all to call transforms? Thanks in advance for any help!

Posted: Mon Feb 16, 2004 2:35 am
by ray.wurlod
It is not possible to call a Transform from any kind of routine, including a job control routine. :cry:

If you use a Transform in a server job (Transformer stage) and examine the code generated by compiling that job, you will see that the Transform is replaced by its defining expression.

In effect, at compile time, the Transform is a compiler instruction to insert the defining expression at that location in the code.

If you want to mimic the effect of a Transform, you can use "literal EQUATE", which you will find in the BASIC manual. However, there is no capability to use placeholder tokens; in a literal EQUATE the definition is substituted literally.

Posted: Mon Feb 16, 2004 7:29 am
by chulett
ray.wurlod wrote:If you want to mimic the effect of a Transform, you can use "literal EQUATE", which you will find in the BASIC manual. However, there is no capability to use placeholder tokens; in a literal EQUATE the definition is substituted literally.
Could you also not drill back to the underlying Routine (if there is one) and call that instead in the same manner the Transform does? Or just use the Transform expression directly in one's code instead of attempting to call it?

Posted: Mon Feb 16, 2004 2:55 pm
by ray.wurlod
Not every Transform invokes a Routine. Certainly you can call Routines from other Routines (probably needing a DEFFUN declaration).

However, if the Transform is simply an encapsulated expression, the answer is definitely no.

And using the Transform's defining expression in your code means that there's now two places where it has to be maintained, which is what I think the OP was trying to avoid.

Consider, for example, all the sdk Transforms that multiply by a constant, for example pints to litres (which I am reliably informed was the most thoroughly tested by the development team :lol: ). The value in these Transforms is that you don't have to remember/research the conversion constants, thereby enhancing your productivity as a developer.