It's true that Omnis doesn't support the C++ concept of a "friend" (in the Omnis context, this would have allowed WindowB to access all the format vars in WindowA).

However, this is not a major deficiency because you RARELY want to provide uncontrolled access to ALL your format vars -- usually just selected ones.

In C++ and Objective C, the way you provide access is by passing pointers to your vars, to other objects.  In addition, C++ also allows you to use references.  Omnis provides both pointer- and reference-type vars.

For example:  Format var fCharA is defined in FormatAFormatB also needs direct access to it.  To set this up, you need to do a one-time call between the two formats.  You can have FormatA call FormatB, or vice versa.

1) A calls B:

In FormatA:

Format variable fCharA  (Character 1000)
Call procedure FormatB/Setup (fCharA)

In FormatB:

; Procedure Setup:
Parameter pTemp (Field name)
Format variable fCharB (Item reference)
Set reference fCharB to pTemp.$ref

fCharB is now equivalent to fCharA. You can read or write the value of fCharA from anywhere within FormatB in all the usual ways, e.g.:

Calculate fCharB as ...
If fCharB = 'abc'; etc ...

In the above example, pTemp is exactly like a C++ reference.  However, since it's a local variable, we have to convert it into a format variable to increase its life span and widen its scope.  fCharB is just like a C/C++ pointer, except that you don't need to use funky syntax to dereference it.

2) B calls A:

In FormatB:

Format variable fCharB (Item reference)
Call procedure FormatA/Setup (fCharB)

In FormatA:

Parameter pTemp (Field name)
Format variable fCharA  (Character 1000)
Set reference pTemp to fCharA.$ref

This technique can be used across libraries, and can also be applied to library vars.

Go to top
JSN Boot template designed by JoomlaShine.com