1. cvx

Converts an object to have the executable attribute.

1.1. Syntax

any cvx → any

1.2. Stack Effects

Table 1. Before
Level Object

0

any (any object)

Table 2. After
Level Object

0

any (same object with executable attribute)

1.3. Description

cvx (convert to executable) changes the attribute of the object on top of the operand stack from literal to executable.

The object itself is unchanged - only its executable/literal attribute is modified. This affects how the PostScript interpreter treats the object when it is encountered during execution.

1.4. PostScript Level

Level 1 and later

1.5. Examples

Converting name to executable
/add cvx         % Result: add (executable)
Converting procedure
{ 1 2 add } cvx  % Result: { 1 2 add } (executable)
String to executable
(1 2 add) cvx exec  % Executes string contents
% Result: 3

1.6. Common Use Cases

1.6.1. Dynamic Code Execution

(add mul sub) cvx exec  % Execute string as code

1.6.2. Creating Executable Arrays

[ /moveto /lineto /stroke ] cvx
% Creates executable procedure

1.6.3. File Execution

(filename.ps) (r) file cvx exec
% Read and execute file

1.7. Common Pitfalls

Execution Context - Executable objects are executed when encountered by the interpreter.
/proc { 1 2 add } def
proc              % Executes (pushes 3)
/proc cvlit       % Literal (pushes procedure)
String Security - Converting arbitrary strings to executable and executing them can be dangerous.
Most Procedures Already Executable - Procedures created with { } are already executable.

1.8. Error Conditions

Error Condition

[stackunderflow]

No operand on stack

1.9. Implementation Notes

  • Only changes the executable/literal attribute bit

  • Does not create a new object

  • Works on any object type

  • Complementary to cvlit

1.10. See Also

  • cvlit - Convert to literal

  • xcheck - Test if executable

  • type - Get object type


Back to top

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