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

Table 1. Before
Level Object

0

Composite object

Table 2. After
Level Object

0

bool (true if readable, false otherwise)

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.4. PostScript Level

Level 1 and later

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.6. Common Use Cases

1.6.1. Safe Access

/safe-get {
  2 copy rcheck {
    get
  } {
    pop pop null
  } ifelse
} def

1.6.2. Validation

/validate-readable {
  dup rcheck not {
    /invalidaccess cvx exec
  } if
} def

1.6.3. Permission Checking

dict rcheck {
  % Can read dictionary
  dict { pop = } forall
} {
  % Cannot read
  (Dictionary not readable) print
} ifelse

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)
Confusing rcheck with xcheck - rcheck tests read access, xcheck tests executable attribute.
Check Before Reading - Use rcheck before operations that read object values.

1.8. Error Conditions

Error Condition

[stackunderflow]

No operand on stack

[typecheck]

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

1.10. Implementation Notes

  • Fast operation (checks access bits)

  • Does not modify the object

  • Works only on composite objects and files

  • Simple objects (numbers, booleans) have no access attribute

1.11. See Also

  • wcheck - Test if writable

  • xcheck - Test if executable

  • Access operators: readonly, executeonly, noaccess

  • type - Get object type


Back to top

Copyright © 2025 Ribose. PostScript is a trademark of Adobe. Distributed under the MIT License.