PARMEVAL (RPGLE)Parameter Evaluation
Parameter Evaluation Prototype
Most people are familiar with this concept when it comes to unix / linux / IFS file permissions. Each permission has its own number.
- 1 - Execute
- 2 - Write
- 4 - Read
Now all, some or no permissions can be put — compressed — to one value. For example:
- 0 - no permissions
- 5 - read and execute permissions
- 7 - all (read, write and execute) permissions
# set permissions:
# 7 = all for owner
# 5 = read/execute for group
# 5 = read/execute for other
chmod 755 /tmp/my_file.txt
Passing multiple selections
The i5/OS API Retrieve Job Information can be used to retrieve the library list of the job. The library list is divided in various sections: System, Product, Current, User. If a procedure should return all or only some parts of the library list then multiple selections may be passed to that procedure. These selections could be coded as constants.
Such a procedure call would look like this:
D C 1
D C 2
D C 4
D C 8
listJobLibraryList(qualified_job_name : SYSTEM_LIBS + USER_LIBS);
Much easier to read and understand.
Now that procedure has to know what part of the library list the calling program wants to have retrieved. A data structure with the possible selections is created with an overlay alpha field.
D DS qualified
D system N
D product N
D current N
D user N
D allSections 4A overlay(listSections)
With the procedure evalParm the data structure gets filled with the following call:
// userSelection contains the value SYSTEM + USER = 9
// evalParm returns : '1001'
listSections.allSections = evalParm(userSelection);
Keep in mind that the constants (and parameter for the evalParm procedure) value must be a number of the power of 2 (1, 2, 4, 8, 16, 32, 64, ...).
- Mihael Schmidt
- 1 = 1
- 2 = 0
- 4 = 1
- 8 = 1
numeric (integer) (10) — Combination of power of 2 numbers
- Return value:
character (100) — Evaluated parameter string (as varying)
- Mihael Schmidt