# gdx

Definition: | include xpGUI.e gdx identifier [= gDialog/gTreeView/...(...)]
Description: | Type. A non-negative integer, being 0/NULL or an integer index into the private control tables of xpGUI, or a flat sequence of them (which may sometimes contain embedded nulls). Use this to define interface element variables. It is probably unwise to use this to determine whether an object is in fact such, as many things which are clearly not (eg 0, 1, '2', {3,4,5}, {'6'}) may pass, the latter only when 54(==#36=='6') or more interface elements have been defined, it does however check [each element] is a non-negative integer between zero (inclusive) and the current control table length. Some uses of a gdx may prohibit [embedded] nulls, but it is never an inherent error for a variable declared as type gdx to hold such.
pwa/p2js: | Supported, or at least understood by pwa/p2js and mapped to "let /*gdx*/" aka (almost) completely ignored, since JavaScript is a typeless language. As per unwise, xpGUI.js does not even have a fake version, which you should not ever want anyway. Note that on desktop/Phix a gdx is an integer (index to private tables) whereas in JavaScript it is in fact the HtmlElement. Therefore, an application should refrain from printing, comparing (etc) gdx variables, except perhaps during initial debugging. [Equality tests and find() are in fact fine, but `gdxvar1 < gdxvar2` and similar are potentially problematical.]
Example: |
    include xpGUI.e

    gdx quit_bt = gButton("Quit")
See Also: | gButton
Technicalia | Note the pGUI distinctions between IupHandl(e|n)[s] have been dropped in favour of crashing when some element/container cannot be created or attempting to use a NULL or multiple handle[s] inappropriately. One thing in particular is that IupG/SetAttribute(NULL,...) being equivalent to IupG/SetGlobal(...) has been completely dropped, in favour of having gGet/SetAttribute(NULL,...) immediately crash, since that should help catch a few more silly little slip-ups. Also it is now a more routine-specific choice as to whether an [embedded] NULL is ignored or invalid, for instance the parent of a new dialog can be NULL, and gDestroy() [which you might be handling within a try/catch, and initialising things to NULL] skips any that were not needed or some other failure occurred before they were created, but (eg) gSetAttribute() as just said will crash. Likewise the distinction between Ihandle and Ihandles has also been ditched, but you will for instance get an error should you try to specify more than one parent (and in some cases child) when creating a new interface element.