Access Function

InstantView® permits not only direct access to a data member, but also indirect access using a function, which is the last term in the Access Path. The access function operates data transfer in both directions. The first parameter is a descriptor:

class CXS_VIEW_DESCRIPTOR
{ public:
         CXS_VIEW_DESCRIPTOR(ZIL_OBJECTID _type, unsigned int _flags);

         ZIL_OBJECTID type;  // data type
         short altered;      // any data changes? 
         union { unsigned int flags;  // flags
                 char *backRef;       // back reference name 
               } ctl;
         union { void *p;             // data
                 char *s;
                 int *i;
                 CXB_MULTIPLE_STRING *m;
               } data;
};

Example:

       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_INTEGER) 
           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 parameter type and contains a pointer on the value. The type depends on the context, in which the function is used:

used with results in type Remark
Windowobjekt String IDX_STRING  
Windowobjekt Prompt IDX_STRING  
Windowobjekt Combobox IDX_STRING  
Windowobjekt MultipleString IDX_MULTIPLE_STRING  
Windowobjekt Integer IDX_INTEGER  
Windowobjekt Radio IDX_INTEGER  
Windowobjekt 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 Auto IDX_UNKNOWN see *)
Put with string IDX_STRING  
Put with integer IDX_INTEGER  
Copy IDX_STRING  
Get IDX_CLASS  

 

*) This function is called twice: First to find out the type that makes the auto widget turn into a concrete window object; and after for the actual data transfer with a type according to the window object emenating from auto.

The window object flags (String, Combobox, ...) or the according ObjektBox format elements in OboxEdit are passed in the descriptor. Connecting to an ObjektBox, the back reference is put into the descriptor instead. For Put/Copy, the flag value is always 0.

The first parameter (CXS_VIEW_DESCRIPTOR) does not appear in InstantView® code. In MDI the keyword (Member access function) is specified. Further (normal) parameters can follow:

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

Access in InstantView®:

       . . .

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

       . . .

Information: A MA function supports data exchange in a specific context (window object + FillWindow/DrainWindow / Get, Copy or Put). The context determines, what the function is supposed to achieve.
Access with Call leaves the function purpose open.
MA functions must not be accessed with Call!