Resource

This section describes the Natural object of type resource.

This document covers the following topics:


Use of Resources

Natural distinguishes two kinds of resources:

  • Shared Resources
    A shared resource is any non-Natural file that is used in a Natural application and is maintained in the Natural library system. 

  • Private Resources
    A private resource is a file that is assigned to one and only one Natural object and is considered to be part of that object. An object can have at most one private resource file. At the moment, only Natural dialogs have private resources.

Both shared and private resources belonging to a Natural library are maintained in a subdirectory named ..\RES in the directory that represents the Natural library in the file system.

Shared Resources

A shared resource is any non-Natural file that is used in a Natural application and is maintained in the Natural library system. A non-Natural file that is to be used as a shared resource must be contained in the subdirectory named ..\RES of a Natural library.

Example of Using a Shared Resource

The bitmap MYPICTURE.BMP is to be displayed in a bitmap control in a dialog MYDLG, contained in a library MYLIB. First the bitmap is put into the Natural library MYLIB by moving it into the directory ..\MYLIB\RES. The following code snippet from the dialog MYDLG shows how it is then assigned to the bitmap control:

DEFINE DATA LOCAL
01 #BM-1 HANDLE OF BITMAP 
... 
END-DEFINE 
* (Creation of the Bitmap control omitted.) 
... 
#BM-1.BITMAP-FILE-NAME := "MYPICTURE.BMP" ... 

The advantages of using the bitmap as a shared resource are:

  • The file name can be specified in the Natural dialog without a path name.

  • The file can be kept in a Natural library together with the Natural object that uses it.

Note:
In previous Natural versions non-Natural files were usually kept  in a directory that was defined with the environment variable NATGUI_BMP. Existing applications that use this approach will work in the same way as before, because Natural always searches for a shared resource file in this directory, if it was not found in the current library.

Private Resources

Private resources are used internally by Natural to store binary data that is part of Natural objects. These files are recognized by the file name extension NR*, where * is a character that depends on the type of the Natural object. Natural maintains private resource files and their contents automatically. A Natural object can have a maximum of one private resource file.

Currently, only Natural dialogs have a private resource file. This file is used to store the configuration of ActiveX controls that are defined in a dialog and are configured with their own property pages.

For information on how to configure an ActiveX control, see Attributes Windows for Dialogs and Dialog Elements, ActiveX Control Property Pages.

Example of Private Resources

The name of the private resource file of the dialog MYDLG is MYDLG.NR3.

Natural creates, modifies and deletes this file automatically as needed, when the dialog is created, modified, deleted, etc.

The private resource file is used to store binary data related to the dialog MYDLG.

API for Processing Resources

In the library SYSEXT, the following application programming interface (API) exists, which gives user applications access to resources' unique user exit routines:

API Purpose
USR4208N Write, read, delete a resource by using short or long name.