[CONNECT C++] Field validation issue

The maximum LevelCode value is 4294967295. How to add field validation in dialog so it allows values from 0-4294967295?

For example using MDL basic Dialog:

DialogBoxRsc DIALOGID_Basic =
    {
    DIALOGATTR_DEFAULT | DIALOGATTR_SINKABLE,
    25*XC, 7*YC,
    NOHELP, MHELP, HOOKDIALOGID_Basic, NOPARENTID,
    TXT_BasicDialogBox,
{
{{X1,GENY(1),XW,0}, LEVELID,	      LEVELID_Basic, ON, 0, "0", "4294967295"},
{{X1,GENY(2),XW,0}, OptionButton, OPTIONBUTTONID_Basic, ON, 0, "", ""},
{{X2,GENY(4),BTN_WIDTH,0}, PushButton, PUSHBUTTONID_OModal, ON, 0,"",""},

It only works with values 0-2147483647 but if set 2³² as maximum then it allows only negative values and shows message "Field must be between 0 & 4294967295".

LevelID decalared as unsigned int.

Parents
  • The maximum LevelCode value is 4294967295. How to add field validation in dialog so it allows values from 0-4294967295?

    Do you really want a user to know about MicroStation's interval level IDs?  It's better to use mdlLevelList_getLevelNamesListModel() to build a ListModel, then assign that ListModel to a ComboBox or ListBox.

    Or, do you want the user to key-in the user-defined level code (not the internal level ID)?

    {{X1,GENY(1),XW,0}, LEVELID, LEVELID_Basic, ON, 0, "0", "4294967295"},

    That's not how you define the limits of an integer value.  You must define a distinct text item resource that includes the limits.

    {{X1,GENY(1),XW,0}, Text, TEXTID_LevelCode, ON, 0, "", ""},

    Level code text item resource definition...

    DItem_TextRsc TEXTID_LevelCode =
        {
        NOCMD, LCMD, NOSYNONYM, NOHELP, MHELP, NOHOOK, NOARG,
        10, "%ld", "%ld", "0", "4294967295", NOMASK, NOCONCAT,
        TXT_LevelCode,
        "basicGlobals.levelCode"
        };
    

     
    Regards, Jon Summers
    LA Solutions

Reply
  • The maximum LevelCode value is 4294967295. How to add field validation in dialog so it allows values from 0-4294967295?

    Do you really want a user to know about MicroStation's interval level IDs?  It's better to use mdlLevelList_getLevelNamesListModel() to build a ListModel, then assign that ListModel to a ComboBox or ListBox.

    Or, do you want the user to key-in the user-defined level code (not the internal level ID)?

    {{X1,GENY(1),XW,0}, LEVELID, LEVELID_Basic, ON, 0, "0", "4294967295"},

    That's not how you define the limits of an integer value.  You must define a distinct text item resource that includes the limits.

    {{X1,GENY(1),XW,0}, Text, TEXTID_LevelCode, ON, 0, "", ""},

    Level code text item resource definition...

    DItem_TextRsc TEXTID_LevelCode =
        {
        NOCMD, LCMD, NOSYNONYM, NOHELP, MHELP, NOHOOK, NOARG,
        10, "%ld", "%ld", "0", "4294967295", NOMASK, NOCONCAT,
        TXT_LevelCode,
        "basicGlobals.levelCode"
        };
    

     
    Regards, Jon Summers
    LA Solutions

Children