Loading...
 

Access function

Access function

In addition to direct access to a data member, InstantView® allows indirect access via a function that is printed on the access label as the last term. The access function must handle data transfer in both directions. A descriptor is passed as the first parameter:

class CXS_VIEW_DESCRIPTOR { public: CXS_VIEW_DESCRIPTOR(ZIL_OBJECTID _type, unsigned int _flags); ZIL_OBJECTID type; // Datentyp short altered; // wurden Daten geändert? union { unsigned int flags; // Flags char *backRef; // Name einer Backreferenz } ctl; union { void *p; // Daten char *s; int *i; CXB_MULTIPLE_STRING *m; } data; };

The following example illustrates this:

C++ code:

class C : public CX_CLASS // a hypothetical class { . . . void Z(CXS_VIEW_DESCRIPTOR *d); int z; . . . }; void C::Z(CXS_VIEW_DESCRIPTOR *d) { if (d->type != IDX_<span class="no_deepl_translate">INTEGER</span>) THROW1(CXE_ACCESS_FUN_CANNOT_HANDLE); // a MA function has not to support // all types given below if (d->data.i) // InstantView® --> object z = abs(*d->data.i); else // object --> InstantView® *d->data.i = z; }

Call in InstantView®:

Integer(C::Z(), 100, 12, 200)

The descriptor describes the type of the parameter and contains a pointer to the value. The type depends on the context in which the function is used:

used with results in type Comment
Window object String IDX_STRING
Window object Prompt IDX_STRING
Window object combobox IDX_STRING
Window object MultipleString IDX_MULTIPLE_STRING
Window object integer IDX_INTEGER
Window object Radio IDX_INTEGER
Window object Checkbox IDX_INTEGER
Windowobject Enumeration IDX_INTEGER
Windowobject ObjectList IDX_COLL with flag SELECT_MULTIPLE or ENTIRE
Windowobject ObjectList IDX_POINTER otherwise
Windowobject ObjectCombobox IDX_POINTER
Windowobject Car IDX_UNKNOWN see *)
Put with string IDX_STRING
Put with integrity IDX_INTEGER
Copy IDX_STRING
Get IDX_CLASS

*) The function is called twice: First, to find out the type according to which the auto widget will turn into a concrete window object; then a second time for the actual data transfer with a type corresponding to the window object resulting from Auto.

In the descriptor the flags of the window object(String, Combobox, ...) or with OboxEdit the flags of the corresponding format element of the ObjektBox are passed. When binding to an ObjektBoxthe back-reference is placed in the descriptor instead. With Put/Copy the value of the flag is always zero.

The first parameter (CXS_VIEW_DESCRIPTOR) does not appear in the InstantView® code. The keyword MA(Member access function) is specified in the MDI for this purpose. Further (normal) parameters may follow:

void C::Z(CXS_VIEW_DESCRIPTOR *d, char *s, int k) { . . . }

Call in InstantView®:

Integer(C::Z("abcdef", 3), 100, 12, 200)

Note: An MA function supports data exchange in a specific context (Window object + FillWindow/DrainWindow or Get, Copy or Put. The context determines what the function should do.
When calling with Call, what is expected from the function remains open.
Therefore: MA functions must not be called with Call!