# PROGRAM Create or Assign Program File

> Source: https://manual.pvxplus.com/directives/program

## Formats

|  |  |  |
| --- | --- | --- |
| 1\. | *[Create Program File](https://manual.pvxplus.com/directives/program#Mark4):* | **PROGRAM** *filename$*\[,*prog_size*\]\[,**ERR**=*stmtref*\] |
| 2\. | *[Assign Default Program (OOP)](https://manual.pvxplus.com/directives/program#Mark6):* | **PROGRAM** *"interface_prog"* |

***Where***:

|  |  |
| --- | --- |
| *interface_prog* | Name of default program that contains object logic. |
| *filename$* | Name of the program file to create. String expression. |
| *prog_size* | Ignored. Size of a program that can be contained in the file. Numeric expression. |
| *stmtref* | Program line number or statement label to which to transfer control. |

## Description

The **PROGRAM** directive can be used to create a program file or it can be used in **[Object Oriented Programming](https://manual.pvxplus.com/pxplus-user-guide/object-oriented-pxplus/introduction)** (OOP) to define a default program name intended to service an object.

## Format 1

***Create Program File***  

**PROGRAM** *filename$***\[**,*prog\_size*\]\[,**ERR**=*stmtref*\]

This format of the **PROGRAM** directive is used to create a PxPlus program file. The file size is for documentation purposes only and is ignored by the system.

***Example:***

```
0010 program "CSTUPD",1024,err=1200
```

Program files have a special header format indicating that the file contains PxPlus object code. Program files should only be used with the **SAVE** or **LOAD** commands. Any attempt to use **READ** or **WRITE** directives with this type of file can yield unpredictable results when the program file is subsequently loaded.

If a given filename already exists, PxPlus returns an Error #12: File does not exist (or already exists).

Note:  
WindX in PxPlus supports the use of this directive via the \[WDX\] or \[LCL\] tags; e.g. PROGRAM "\[WDX\]somefile.ext". Non-PxPlus versions require you to encapsulate the command in an EXECUTE directive with a \[WDX\] tag (i.e. EXECUTE "\[WDX\]..."). See [\[WDX\] Direct Action to Client Machine](https://manual.pvxplus.com/command-tags/wdx) or [\[LCL\] Access to Users Local Machine](https://manual.pvxplus.com/command-tags/lcl).

## Format 2

***Assign Default Program in Object-Oriented Programming***  

**PROGRAM** *"interface_prog"*  

In Object Oriented Programming, the **PROGRAM** directive is used to define the default program name that is going to service an object. This can be used to override the program that contains the **DEF CLASS**.

If this clause is specified for an object class:

- Whenever an object is created, the system will attempt to call the specified program at the label ON_CREATE.
- Whenever an object of this class is deleted, the system will attempt to call the specified program at the label ON_DELETE.

No error is reported if the label does not exist. In addition, any references to program logic in a property read/write or a method definition can contain a leading **;** (*semi-colon*).

***Example:***

The following class definitions are effectively the same:

```
program "Cust"
function Find(X$)"LookupByName"
```

## See Also

**[DEF CLASS Define Object Class](https://manual.pvxplus.com/directives/def-class)**  
**[DROP CLASS Delete Class Definition](https://manual.pvxplus.com/directives/drop-class)**  
**[DROP OBJECT Delete Object](https://manual.pvxplus.com/directives/drop-object)**  
**[FUNCTION Declare Object Method](https://manual.pvxplus.com/directives/function)**  
**[LIKE Inherit Properties](https://manual.pvxplus.com/directives/like)**  
**[LOAD CLASS Pre-Load Class Definition](https://manual.pvxplus.com/directives/load-class)**  
**[LOCAL Designation of Local Data](https://manual.pvxplus.com/directives/local)**  
**[PROPERTY Declare Object Properties](https://manual.pvxplus.com/directives/property)**  
**[RENAME CLASS Change Name of Class](https://manual.pvxplus.com/directives/rename-class)**  
**[STATIC Add Local Properties at Runtime](https://manual.pvxplus.com/directives/static)**  
**[NEW( ) Create New Object](https://manual.pvxplus.com/functions/new)**  
**[REF( ) Control Reference Count](https://manual.pvxplus.com/functions/ref)**
