To be recognized by AutoCAD, an application must register the name or names that it uses. Application names are saved with the extended data of each entity that uses them, and also in the APPID table. Registration is done with the regapp function, which specifies a string to use as an application name. If it successfully adds the name to APPID, it returns the name of the application; otherwise it returns nil. A result of nil indicates that the name is already present in the symbol table. This is not an actual error condition but an expected return value, because the application name needs to be registered only once per drawing.
To register itself, an application should first check that its name is not already in the APPID table. If the name is not there, the application must register it. Otherwise, it can simply go ahead and use the data, as described later in this section.
The following fragment shows the typical use of regapp. (The tblsearch function is described in Symbol Table and Dictionary Access.)
(setq appname "MYAPP_2356") ; Unique application name.
(if (tblsearch "appid" appname) ; Checks if already registered.
(princ (strcat
"\n" appname " already registered. "))
(if (= (regapp appname) nil) ; Some other problem.
(princ (strcat
"\nCan't register XDATA for " appname ". "))
)
)
The regapp function provides a measure of security, but it cannot guarantee that two separate applications have not chosen the same name. One way of ensuring this is to adopt a naming scheme that uses the company or product name and a unique number (like your telephone number or the current date and time).