MicroStation MDL: the "resource" keyword in structure definition?

Hi Experts,

I am looking at some Pure MDL code used in MicroStation V8i SS4. I am trying to learn how the DItem_IconCmdRsc structure work. In both CHM help document and the dlogbox.h file of the SDK, the specification has a conditional definition on "resource". I wasn't able to find the definition of "resource" to understand how it works. Can anybody tell me where I can find the documentation or definition of "resource"?

Thank you! Below is the definition of DItem_IconCmdRsc I found.

typedef struct ditem_iconcmdrsc
    {
    UInt32          helpInfo;
#if defined (resource)
    char            helpTaskId[];
    UInt32          attributes;
    UInt32          commandNumber;
    char            commandTaskId[];
    char            unparsed[];
    char            enabledAccessStr[];
    DialogItemRsc   iconItems[];
#else
    long            helpTaskIdLength;
    char            helpTaskId[1];
#endif
    } DItem_IconCmdRsc;

Parents
  • Hi Robert and Jan,

    Thank you for your explanation, such that I am more clear about general what "resource" is in MicroStation. I also read the "MicroStation Resources" chapter in MDL Programmer Guide CHM file for more understanding.

    Instead of the general concept, the specific information I am trying to find out is about the MDL code keyword "resource". In the MDL Programmer Guide section "MicroStation Resources --> Overview of Resources --> General Resource Definition Format" I found the following description:

    The resource compiler lets an application define structures with variable-sized members. These structures are called "structures of undefined length," or variable sized arrays; arrays without bounds. When a variable sized array is initialized, rcomp generates a hidden long value in front of the array data that defines the number of elements in the array. This is why resource structure definitions in header files contain the #if defined (resource) preprocessor directives to allow the proper structure definition to be included in the resource or MDL source file.

    According to this paragraph, the "if defined (resource)" condition is to handle the variable sized array.

    I am wondering, how can I use each branch of the "if" logic? More specifically for the ditem_iconcmdrsc struc, how can I define an instance with many fields such as "attributes" and "commandNumber"? and how to define an instance without "attributes" and "commandNumber" fields?

    In "Standard Dialog Box Items"-->"Icon Command", there is an example

        

    DItem_IconCmdRsc ICONCMDID_PlaceLineAA= 
    { 
    	NOHELP, MHELP, 0, CMD_PLACE_LINE_ANGLE, MTASKID, "", "", 
    	{ 
    	   {{16*XC, GENY(1), 10*XC, 0}, Text, TEXTID_ActiveAngle,ON,0,"",""}, 
    	} 
    }; 
    

    How can I know which branch it is using?

    Thank you!

    Sui

  • Hi Sui,

    I am trying to find out is about the MDL code keyword "resource".

    It's not the keyword (even when I agree it look like keyword), but it's more like C macro, defined in certain situations (e.g. when a code is compiled by rcomp).

    I am wondering, how can I use each branch of the "if" logic?

    When you work with .r files, that are static definition of resources, you should use what is "not in if" and "in if (resource).

    How can I know which branch it is using?

    Usually it can be distinguished just using member types and number of members in the structure, but technically it's the structure with (resource) defined.

    I guess I will not be able to find out which branch an instance it is going.

    Why not? For .r files, the structure from beginning to #else will be used.

    Regards,

     Jan

    Answer Verified By: Sui Huang 

  • Hi Jan,

    Thank you for your explanation. I am still trying to digest and understand. I just want to ask a question following up part of your explanation now.

    Usually it can be distinguished just using member types and number of members in the structure, but technically it's the structure with (resource) defined.

    I am trying to check the input parameter type of the following definition to tell which branch it is going. Since there are 8 input parameters, it should be using the branch that resource is defined. However, the second input parameter MHELP looks like a constant but not a char array. However, I couldn't find its definition even though I saw it in many examples.

    Can you tell me what this MHELP is? I think it can help me to understand the usage of the struct definition.

    DItem_IconCmdRsc ICONCMDID_PlaceLineAA= 
    { 
    	NOHELP, MHELP, 0, CMD_PLACE_LINE_ANGLE, MTASKID, "", "", 
    	{ 
    	   {{16*XC, GENY(1), 10*XC, 0}, Text, TEXTID_ActiveAngle,ON,0,"",""}, 
    	} 
    };

Reply
  • Hi Jan,

    Thank you for your explanation. I am still trying to digest and understand. I just want to ask a question following up part of your explanation now.

    Usually it can be distinguished just using member types and number of members in the structure, but technically it's the structure with (resource) defined.

    I am trying to check the input parameter type of the following definition to tell which branch it is going. Since there are 8 input parameters, it should be using the branch that resource is defined. However, the second input parameter MHELP looks like a constant but not a char array. However, I couldn't find its definition even though I saw it in many examples.

    Can you tell me what this MHELP is? I think it can help me to understand the usage of the struct definition.

    DItem_IconCmdRsc ICONCMDID_PlaceLineAA= 
    { 
    	NOHELP, MHELP, 0, CMD_PLACE_LINE_ANGLE, MTASKID, "", "", 
    	{ 
    	   {{16*XC, GENY(1), 10*XC, 0}, Text, TEXTID_ActiveAngle,ON,0,"",""}, 
    	} 
    };

Children