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.
will try
How about changing your "%d" to "%u" ?
Oto said:tried with unsigned and the result is the same
Please post your dialog resource (*.r) file. What is the declaration of the access variable in your header (*.h) file?
*.r
*.h
Regards, Jon Summers LA Solutions
tried with unsigned and the result is the same
You can only enter negative values (or zero)? You are using %d format specifier which is for signed integers, which would interpret your maximum value as a minimal signed integer value.
Not sure if my term was correct but problem is that if min is set to 0 and max to 4294967295 then no value except negative can be entered for all positive values it shows message "Field must be between..." which is not expected. It only works if max is set to 2147483647.
Oto said:it doesn't seem to work for field validation
If you specify the max and min values for an unsigned integer, then what is there to validate?
This was just an example as not only LevelID uses 32-bit value but for some reason it doesn't seem to work for field validation.
DItem_TextRsc TEXTID_LevelCode = { NOCMD, LCMD, NOSYNONYM, NOHELP, LHELPCMD, NOHOOK, NOARG, 20, "%d", "%d", "0", "4294967295", NOMASK, TEXT_NOCONCAT, "", "params.descrLevel" };
Oto said: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.
mdlLevelList_getLevelNamesListModel()
ListModel
ComboBox
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" };