Programming Guide



public

Reads JPL modules into memory and makes their procedures available to application

Synopsis

public moduleName[ moduleName]...

Arguments

moduleName
Specifies the module to read into memory (if necessary), where moduleName is a string constant or colon-expanded variable that names a library module or memory-resident module. If Panther cannot find moduleName, it issues an error message.

Note: If the public command is issued in a screen's unnamed procedure and moduleName cannot be found, no error message is issued.


Description

The public command reads the procedures contained in one or more JPL modules. If the modules are not already memory-resident, public compiles them and puts them in memory, making the contents of the module available to the application as a whole. It also executes the first procedure if it is unnamed. All procedures beginning with a proc statement are available until the application exits or you remove their module from memory with an unload statement. public lets you store generic procedures in library modules that are easy to edit and available to any application. For example, these procedures handle user exits:

Example

proc quit
vars ans
ans = sm_message_box \
("Are you ready to quit?", "", SM_MB_YESNO, "")
if ans = SM_IDYES
return 1
else
return 0

proc end
msg emsg 'Program exit.'

Given that these procedures are in library module exit_handler, you can make them available to the application by entering this public command in the opening screen's unnamed procedure (accessed through the screen's JPL Procedures property):

public exit_handler

You can now call quit from any available application hook, for example, from a control string that is associated with the EXIT key:

EXIT=^(0=&nextscreen; 1=^end)quit

You can issue the public command on a module only once. Panther ignores public commands on a module that is already public.

Note: If you test an application that loads a public module, that module remains in memory until you explicitly unload it or Panther exits. If you edit the module after exiting test mode, remember in the next test session to unload the module's earlier version and reload the new one in order to see your changes.

See Also

unload