Table of Contents
1. rcheck
Tests whether an object’s access attribute permits reading its value.
1.1. Syntax
array rcheck → bool packedarray rcheck → bool dict rcheck → bool file rcheck → bool string rcheck → bool
1.2. Stack Effects
| Level | Object |
|---|---|
0 |
Composite object |
| Level | Object |
|---|---|
0 |
|
1.3. Description
rcheck tests whether the operand’s access attribute permits its value to be read explicitly by PostScript operators.
Returns:
* true if access is unlimited or readonly
* false if access is executeonly or noaccess
1.5. Examples
Readable objects
[1 2 3] rcheck % true (unlimited)
(text) readonly rcheck % true (readonly)
Non-readable objects
{ code } executeonly rcheck % false
{ code } noaccess rcheck % false
File objects
(file.ps) (r) file rcheck % true (read mode)
(file.ps) (w) file rcheck % false (write mode)
1.7. Common Pitfalls
| Execute-Only ≠ No Read - Execute-only objects cannot be read but can be executed. |
{ 1 2 add } executeonly
dup rcheck % false (cannot read)
dup exec % Works! (can execute)
Check Before Reading - Use rcheck before operations that read object values.
|
1.8. Error Conditions
| Error | Condition |
|---|---|
[ |
No operand on stack |
[ |
Operand not a composite object or file |
1.9. Access Attributes
| Attribute | Can Read? | Can Write? | Can Execute? |
|---|---|---|---|
Unlimited |
Yes |
Yes |
Yes |
Readonly |
Yes |
No |
Yes |
Executeonly |
No |
No |
Yes |
Noaccess |
No |
No |
No |