The Program Object


 

The program object runs one concurrent PL/B component program. Once a program completes, the program object cannot run a second program. A new program object must be created. The program object is created in its own thread and exists until any running program finishes and all connections to the owner of the program object are released.

 

Once a program is running in a program object, it continues running until completion, even if all references to the program object are released.

 

A program object is created by using ‘Plbwin.Program’ program identifier or the {4E6D6AA0-6D28-11d4-B417-0000B43D1661} class identifier. The program object may also be created by invoking the CreateProgram method of the PLB Automation Server application object.

 

The program object supports the following properties, methods, and events:

 

Property Name

Return Type

Description

Visible

VT_BOOL

Sets or returns whether the application is visible to the user; read/write. The default is FALSE. This property must be set prior to using the Run method.

ErrorText

VT_BSTR

Returns the text of any error that caused the termination of a running program.

 

Method Name

Return Type

Description

Run

VT_EMPTY

Executes a PL/B program. This method can only be used once per program object. The method takes one required VT_BSTR argument - cmdLine. This argument is the command line required to execute the program without the actual plbwin command name. If a program is executed by the command line:

         plbwin -g400 test1

the cmdLine parameter should be:

         -g400 test1

EventSend

VT_EMPTY

Posts an event to the program's PL/B event stack. The method takes one required VT_I4 parameter - eventId. The parameter specifies the event identifier used when the event is placed on the PL/B runtime event stack. It can also take up to ten (10) optional VARIANT parameters named arg1 to arg10.

 

Event Name

Return Type

Description

UserEventX

VT_EMPTY

This is a series of events (UserEvent1 - UserEvent10) that are sent by the PL/B component back to the client program using the EVENTSEND statement. Each event can have five (5) optional VARIANT parameters.

Exit

VT_EMPTY

This event indicates that the currently running program has exited and is produced by the PLB Automation Server. It has one VT_BOOL argument - exitStatus that is FALSE when the program has been terminated by an error.

 

The Automation Server also supports a ProgID named 'Plbwin.ProgramNE' that does not allow events to be dispatched to a COM/ActiveX component. Any results returned from this object must be performed using the internal VARIANT objects named *ARG1 through *ARG10 or *RESULT as described below. All properties and methods for the 'Plbwin.ProgramNE' ProgID are the same as 'Plbwin.Program' ProgID. These properties and methods are defined as follows:

 

Property Name

Return Type

Description

Visible

VT_BOOL

Sets or returns whether the application is visible to the user; read/write. The default is FALSE. This property must be set prior to using the Run method.

ErrorText

VT_BSTR

Returns the text of any error that caused the termination of a running program.

 

Method Name

Return Type

Description

Run

VT_EMPTY

Executes a PL/B program. This method has one required VT_BSTR argument that is a command line that is sent to a PLBWIN runtime thread that is started by the Automation Server. This method can only be used once for a given program object.

EventSend

VT_EMPTY

This is a method that posts an event to a PL/B program object. This method has one required VT_I4 parameter that is the eventID number. This parameter specifies the event number that must correspond to the event number that is registered in the PL/B program being executed. In addition, this method can accept up to ten optional VARIANT parameters named ARG1 to ARG10.

 

 

See Also: Automation



Compiler and Runtime Options The Application Object The Running Objects Table