Using PL/B as a Client


 

The following simple program accesses the component. First, we create a program object and start running the program.

 

PlbCom

Automation

 

Name

Dim

20

Phone

Dim

20

 

 

 

 

Display

*ES,*HD

 

Create

PlbCom,Class="Plbwin.Program"

 

Now the required events are registered and the program started.

 

 

EventReg

PlbCom,1,ShowData:
ARG1=Name,ARG2=Phone

 

EventReg

PlbCom,2,AllDone

 

EventReg

PlbCom,11,ProgComplete

 

 

 

 

PlbCom.Run

Using "sampsrv"

 

The ShowData routine will display the event information and is as follows:

 

ShowData

 

 

 

Display

"Name: ",Name,:
" Phone: ",Phone

 

Return

 

 

The AllDone routine sends the terminate component event to stop the component.

 

AllDone

 

 

 

Display

"All records read"

 

PlbCom.EventSend

Using 2

 

Return

 

 

The ProgComplete routine indicates that the component has terminated and stops the program.

 

ProgComplete

 

 

 

Display

"Program terminated"

 

Keyin

Name

 

Destroy

PlbCom

 

Stop

 

 

The final code makes a read request of the component then loops waiting for a result.

 

 

PlbCom.EventSend

Using 1,"Smith"

 

Loop

 

 

EventWait

 

 

Repeat

 

 

The entire code is shown below

 

PlbCom

Automation

 

Name

Dim

20

Phone

Dim

20

 

 

 

 

Display

*ES,*HD

 

Create

PlbCom:
Class="Plbwin.Program"

 

EventReg

PlbCom,1,ShowData:
ARG1=Name,ARG2=Phone

 

EventReg

PlbCom,2,AllDone

 

EventReg

PlbCom,11,ProgComplete

 

 

 

 

PlbCom.Run

Using "sampsrv"

 

PlbCom.EventSend

Using 1,"Smith"

 

Loop

 

 

EventWait

 

 

Repeat

 

 

 

 

ShowData

 

 

 

Display

"Name: ",Name:

" Phone: ", Phone

 

Return

 

 

 

 

AllDone

 

 

 

Display

"All records read"

 

PlbCom.EventSend

Using 2

 

Return

 

 

 

 

ProgComplete

 

 

 

Display

"Program terminated"

 

Keyin

Name

 

Destroy

PlbCom

 

Stop

 

 

 

See Also: Automation

 



Compiler and Runtime Options Creating a PL/B Automation Object Using Visual Basic as a Client