ZNorQ 0 Posted September 24, 2007 Is it possible to re-use constant definitions declared in description.ext (by #define keyword) in ordinary (sqs/sqf) scripts? I was thinking of declaring alot of IDC/IDD constants in the description.ext, and re-use those in the script. My intention is to declare the idc's and idd's once in the description.ext, and then use those to manipulate the controls using scripts. This would let me declare the variables at one place only. Description.ext; <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#define DLG_IDD 100 #define DLG_IDC_BTN_CLOSE 101 #define DLG_IDC_LBL_PICKLIST 102 #define DLG_IDC_CMB_PICKLIST 103 class dlgMyDialog { idd = DLG_IDD; controls[]={lblPicklist, btnClose, cmbPicklist}; class lblPicklist { idc = DLG_IDC_LBL_PICKLIST; ... etc... }; class cmbPicklist { idc = DLG_IDC_CMB_PICKLIST; ...etc... }; }; Some script manipulating the content; <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_lbOK = lbAdd[DLG_IDC_CMB_PICKLIST, "My choice"]; ctrlSetText[DLG_IDC_LBL_PICKLIST, "Select command:"]; PS! I know this doesn't work, but I was hoping that some sort of script function could extract the values.. If I could extract those values into my script, I wouldn't have to redeclare the same variables, AND make sure they match with the description.ext declarations. This way, if I where to add additional controls, I would just insert it in the description.ext file using another #define, and make sure it doesn't come in conflict with other IDC/IDD numbers. I'm pretty new to dialogs, so I might have misunderstood the whole concept, in which case please have me excused.. ZNorQ Share this post Link to post Share on other sites
sbsmac 0 Posted September 24, 2007 I think this should work (though haven't tested it very thoroughly)... 1)Create a file called "dialog.h" and cut and paste all your #defines into it. 2) In description.ext, just add a line #include "dialog.h" It would be kind of useful if this works for someone to put together a complete set of such header files and make them available from the Biki. Share this post Link to post Share on other sites
ZNorQ 0 Posted September 24, 2007 I think this should work (though haven't tested it very thoroughly)...1)Create a file called "dialog.h" and cut and paste all your #defines into it. 2) In description.ext, just add a line #include "dialog.h" It would be kind of useful if this works for someone to put together a complete set of such header files and make them available from the Biki. Not quite what I had in mind (if I understand you correctly). I've kinda already did what you proposed, in order to reduce the description.ext length. My problem on the other hand, is to use those description.ext defined constant in my scripts (sqf). So instead of having to redeclare the same constants in my scripts (they are supposed to be identical both in name and content), I would access those in description.ext and make use of them for accessing/manipulating controls in dialogs. I'm doing this to make it easier to create new controls and referring to them using constant names instead of constant numericals. ZNorQ Share this post Link to post Share on other sites
Synide 0 Posted September 24, 2007 #include the same file in your scripts as well... Share this post Link to post Share on other sites
ZNorQ 0 Posted September 24, 2007 #include the same file in your scripts as well... Aaah! Gotcha! Didn't know define worked in ordinary scripts.. Thanks folks. ZNorQ Share this post Link to post Share on other sites