Work Performer Developer'S Guide: Visual Workflo For Windows

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 286

Visual WorkFlo® for Windows®

Work Performer
Developer’s Guide

Release 2.0

302010

December 1996

FileNet, FolderView, OSAR, Revise, ValueNet, Visual WorkFlo,


WorkFlo, and Wor kForce Desktop are registered trademarks of
FileNet Corporation.

FileNet:WorkGroup, AutoForm, COLD, Foundation for Enterprise


Document Management, SMART, WorkFlo/Fax, WorkFlo/Print,
WorkFlo/Scan, and WorkShop are trademarks of FileNet
FileNet Corporation Cor poration.

All other product and brand names are trademarks or registered


3565 Harbor Boulevard trademarks of their respective companies.

Costa Mesa, California 92626 Due to continuing product development, product specifications
and capabilities are subject to change without notice.
7 14 •96 6•3 40 0 Copyright  1996 FileNet Corporation. All Rights Reserved.

9810821-002
Notices
This document contains information proprietary
to FileNet Corporation (FileNet). You may not
disclose or use any proprietary information or
reproduce any part of this document without
written permission from FileNet.

Even though FileNet has tested the hardware


and software and reviewed the documentation,
FileNet makes no warranty or representation,
either express or implied, with respect to the
hardware, software, or documentation, their
quality, performance, merchantability, or fitness
for a particular purpose. FileNet has made every
effort to keep the information in this manual cur-
rent and accurate as of the date of publication or
revision. However, FileNet does not guarantee
or imply that this document is error free or accu-
rate with regard to any particular specification.
As a result, this product is sold as is, and you
the purchaser are assuming the entire risk as to
its quality and performance.

In no event will FileNet be liable for direct, indi-


rect, special, incidental, or consequential dam-
ages resulting from any defect in the hardware,
software, or documentation, even if advised of
the possibility of such damages. In particular,
FileNet shall have no liability for any programs
or data stored in or used with FileNet products,
including the costs of recovering such programs
or data.

Some states do not allow the exclusion or limita-


tions of liability for incidental or consequential
damages, so the above limitation or exclusion
may not apply to your installation. You may also
have other rights that vary from state to state.

No FileNet agent, dealer, or employee is autho-


rized to make any modification, extension, or
addition to the above statements.
Contents

About This Manual xiii

Who Should Read This Manual? xiii

Conventions Used in this Manual xiv

Related Publications xiv

Education xiv

Comments and Suggestions xv

1 Writing Work Performers 1


16-bit Work Performers 1
Passive Work Performers 1
Active Work Performers 2

32-bit Work Performers 2


Passive Work Performers 2
Active Work Performers 3

Work Performer Design Considerations 3


Keeping Track of Operations and Parameters 6
Visual WorkFlo Array Handling 7
Passive Work Performer Executable Files 7

Adaptors 8
VWOLEADP Adaptor 8
VW.INI File 9

Function Sequences 9
Active Work Performer Function Sequences 10

December 1996 Work Performer Developer’s Guide iii


Contents

Passive Work Performer Function Sequences 13


Administration Program Function Sequences 16

API Calls Overview 18


Logon and Logoff API Calls 18
Work Object Creation API Calls 18
Logging Support API Calls 19
Queue Handling API Calls 19
Work Object Access API Calls 21
Work Object Information API Calls 22
Work Object Binding API Calls 23
Data Access API Calls 23
Work Object Location API Calls 24
Error Handling API Calls 25

Debugging Work Performers 25


Message Logging 25
Using NDump 26
Sample NDump Output 27

2 Work Performers that Use OLE Automation 29


Writing Active or Passive Work Performers that Use OLE 29
Writing Passive Work Performers that Use VWOLEADP.DLL 29
Registering OLE Servers 30
Visual Basic OLE Servers 31
Writing Active Work Performers that Use OLE Automation 31

Converting Visual Basic Work Performers to use OLE 31


Converting a Visual Basic Passive Work Performer to be an OLE Server 31
Converting a Visual Basic Active Work Performer or
Visual WorkFlo Aware Program to Use OLE 33

iv Work Performer Developer’s Guide December 1996


Contents

VWAPISRV API Calls 34

Example Work Performer Code 39


VW_BrmSetSortRules() Example 40
An Active Work Performer that Uses OLE 41
Execute_Click Procedure 43
check Procedure 46
Form_Load Procedure 47
Form_Unload Procedure 47
A Passive Work Performer that Uses OLE 48
dataIn Function 49
dataInOut Procedure 50
dataOut Procedure 52
An Active Visual Basic Work Performer that Calls Microsoft Word 53
cmdGetNextLetter_Click Procedure 54
Form_Load Procedure 56
Form_Unload Procedure 56
check Procedure 57
An Example of VW_WobQueryCreate() and related APIs 57
check Procedure 58
BindToUser_Click Procedure 58
Command1_Click Procedure 58
Command11_Click Procedure 59
Command13_Click Procedure 60
Command14_Click Procedure 60
Command16_Click Procedure 61
Command17_Click Procedure 61
Command18_Click Procedure 62
Command19_Click Procedure 62
Command2_Click Procedure 62

December 1996 Work Performer Developer’s Guide v


Contents

Command20_Click Procedure 63
Command21_Click Procedure 64
Command22_Click Procedure 64
Command23_Click Procedure 64
Command27_Click Procedure 65
Command28_Click Procedure 66
Command4_Click Procedure 66
Command5_Click Procedure 71
Command6_Click Procedure 72
Command7_Click Procedure 72
Command8_Click Procedure 73
Command9_Click Procedure 74
Form_Load Procedure 74
Form_Unload Procedure 75
VBDateToFNTime Function 75
GetBindings_Click Procedure 75
GetBindingsButton_Click Procedure 75
GetBindingsButtonLocked_Click Procedure 75
GetBindingsButtonLockedButton_Click Procedure 76
GetBindingsNextWObjButton_Click Procedure 76
GetWobSignature_Click Procedure 77
GetWobSignatureLockedButton_Click Procedure 77
UnbindUser_Click Procedure 77
UnBindUserL_Click Procedure 77
WobSignatureButton_Click Procedure 78
WobSignatureLockedButton_Click Procedure 78
GetWobSignatureNextWobjButton_Click Procedure 78
WobSignatureNextWObjButton_Click Procedure 79

vi Work Performer Developer’s Guide December 1996


Contents

3 DLL Work Performers 81


Using the DLL Adaptor 81

Data Type Conversion 82

Converting 16-bit Work Performers to 32-bits 83

Using VWDLLADP.DLL with Borland 32-bit DLLs 84

DLL Passive Work Performer Example 85

C API Calls 88
VW_AttachToWorkQueue 89
VW_BeginBrowsingWorkQueue 91
VW_BindToUser 93
VW_BrmCreateBrowseModifier 94
VW_BrmFreeBrowseModifier 96
VW_BrmSetPreSelectRule 97
VW_BrmSetSelectRule 99
VW_BrmSetSortRules 101
VW_CheckVersionCompatibility 103
VW_CreateWorkObject 105
VW_CurrentException 107
VW_DetachFromWorkQueue 109
VW_DispatchWorkObject 110
VW_EndBrowsingWorkQueue 111
VW_FreeAccessHandle 112
VW_FreeArrayPtr 114
VW_GetAccessHandle 115
VW_GetArrayPtr 117
VW_GetArraySize 119
VW_GetBoolean 121
VW_GetDataType 123

December 1996 Work Performer Developer’s Guide vii


Contents

VW_GetDataTypeArray 125
VW_GetErrorMessage 127
VW_GetErrorMessageSize 128
VW_GetFieldNames 129
VW_GetFloat 131
VW_GetFPNumber 133
VW_GetInteger 135
VW_GetLoggingState 137
VW_GetOperationName 139
VW_GetOperationNameSize 140
VW_GetString 141
VW_GetStringSize 143
VW_GetTime 145
VW_GetWobSignature 147
VW_GetWorkPerformerHandle 148
VW_LeaveWork 149
VW_LockWorkObject 150
VW_LogMessage 152
VW_Logoff 154
VW_Logon 155
VW_NextWorkObjectToBrowse 157
VW_RaiseException 158
VW_ReportToWork 160
VW_SetArrayPtr 161
VW_SetBoolean 163
VW_SetFloat 165
VW_SetFPNumber 167
VW_SetInteger 169
VW_SetLogCacheFlushLength 171

viii Work Performer Developer’s Guide December 1996


Contents

VW_SetLoggingState 172
VW_SetString 174
VW_SetTime 176
VW_TerminateWorkObject 178
VW_UnBind 180
VW_UnlockAndDispatch 181
VW_UnlockWorkObject 182
VW_WobQueryCreate 183
VW_WobQueryEnd 185
VW_WobQueryExecute 186
VW_WobQueryGetAccessHandle 188
VW_WobQueryInstrSheet 190
VW_WobQueryOperation 192
VW_WobQueryWorkPerformerClass 194

4 WorkFlo Script Work Performers 197


Using the WorkFlo Script Adaptor 197
Data Type Conversion 198

Visual WorkFlo Handles 199

Active or Passive WorkFlo Calls? 199


Parameter Passing 200

WorkFlo Script Example Code 200


Active Work Performer 200
Passive Work Performer Example 217

WorkFlo Script Calls 224


Work Performer Start-up 224
Establish and Terminate a Visual WorkFlo Session 224
Active Work Performers 224

December 1996 Work Performer Developer’s Guide ix


Contents

Passive Work Performers 225


Work Object Creation and Termination 227
Work Object Creation 227
Queue Management 228
Establish a Browse Handle 229
Establish an Object Handle 230
Lock a Work Object 231
Field Manipulation 232
Access Instance Values 233
VW Set Fields 234
VW Get Fields 235
Operation Completion 236
VW Return Work Object 236
Find Matching Work Objects 237
VW Open Object Query Session 237
VW Work Object Query 238
VW Close Object Query 238
Work Object Access 238
VW Open Object Access Session 239
VW Close Object Access Session 239
Complete Work Queue Processing 240
VW Close Browse Session 240
VW Detach From Work Queue 240
VW Close Work Session 241
VW Free Handle 241
Logging and Exception Handling 241
VW Set Attributes 242
VW Set Log Flags 242
VW Get Log Flags 243

x Work Performer Developer’s Guide December 1996


Contents

VW Log Message 243


VW Raise Exception 244
VW Get Current Exception 244
VW Get Error Text 245

Glossary 247

Appendix A—Error Messages 253


Error Category 253

Error Function 254

Error Numbers 255

Index 263

December 1996 Work Performer Developer’s Guide xi


Contents

xii Work Performer Developer’s Guide December 1996


About This Manual

This manual accompanies Release 2.0 of Visual WorkFlo. It describes how to


write Work Performers and how to use Visual WorkFlo API calls with various
programming languages, as well as providing a reference to all of the FileNet-
provided API calls.

Who Should Read This Manual?


You should read this manual if you need to write:

• Work Performers using the OLE adaptor.

• Work Performers using WorkFlo Script Language.

• Active Work Performers using the API calls.

The manual is organized as follows.

Chapter 1—Writing Work Performers

Provides guidelines and general information on writing Work Performers.

Chapter 2—Work Performers that Use OLE Automation

Describes how to write passive Work Performers that are OLE servers.
Also describes how to write active Work Performers and Visual WorkFlo-
aware programs that use OLE Automation.

Chapter 3—DLL Work Performers

Describes requirements for writing a Work Performer that uses the DLL
adaptor. Also provides an alphabetically organized reference of API
functions.

Chapter 4—WorkFlo Script Work Performers

Describes requirements for writing WorkFlo Script Work Performers. Also


describes the WorkFlo script calls that apply to the Visual WorkFlo
environment.

December 1996 Work Performer Developer’s Guide xiii


About This Manual
Conventions Used in this Manual

Appendix A—Error Messages

Provides a brief description of the error messages that correspond to the


error codes that may be returned by the API calls.

Conventions Used in this Manual


The Visual WorkFlo documentation uses a few special conventions.

The first time we describe a new term, you'll see it in bold text. A definition for
every bolded term appears in Appendix A.

Italic type indicates the titles of books or manuals recommended for further
information.

When we refer to a session, we mean a single period of time during which you
are running the Visual WorkFlo product.

Related Publications
For more information on Visual WorkFlo, refer to these manuals:

• Getting Started with Visual WorkFlo

• Visual WorkFlo/Composer Handbook

• Visual WorkFlo/Conductor Handbook

• Visual WorkFlo/Performer Handbook

• Installation Handbook

• Visual WorkFlo Utilities Handbook

Refer to your Microsoft documentation for more information on OLE.

Education
FileNet offers introductory and advanced classes for system administrators,
developers, management, and support personnel. These classes combine
lecture and lab sessions to provide both conceptual understanding of the
FileNet system and practice in its operation. For more information on class
content and schedules, please visit the Education topics in the Services and
Support area of FileNet’s web site (www.filenet.com).

xiv Work Performer Developer’s Guide December 1996


About This Manual
Comments and Suggestions

Comments and Suggestions


FileNet invites all customers to communicate with the Documentation group
on any question or comment related to FileNet manuals and on-line help. Just
fax, phone, mail, or e-mail any question or comment to Mike Calvert at one of
the numbers or addresses listed below. We guarantee a response to each
communication within one week. Your suggestions help us improve the
products we deliver.

Mike Calvert
Director of Documentation
FileNet Corporation
3565 Harbor Boulevard
Costa Mesa, California 92626-1420

Phone: 714.966.2449
Fax: 714.966.7153
E-mail: calvert@filenet.com

December 1996 Work Performer Developer’s Guide xv


About This Manual
Comments and Suggestions

xvi Work Performer Developer’s Guide December 1996


1
1Writing Work Performers

This chapter provides general information about writing Work Performers and
using the API calls. The following topics are discussed:

• 16-bit Work Performers

• 32-bit Work Performers

• Work Performer design considerations

• Passive Work Performer adaptors

• Work Performer function sequences

• API calls overview

16-bit Work Performers


16-bit Work Performers are those compiled to run on Windows 3.1 or
Windows for WorkGroups. Existing 16-bit active and passive Work Performers
can be run on Visual WorkFlo 2.0.

Passive Work Performers


The following table shows the languages and development environments
supported for 16-bit passive Work Performers and the corresponding
adaptors.

Visual Basic 3.0 VBADAPT2


PowerBuilder 3.0 PBADAPT2
Excel 5.0 XLADAPT2
Word for Windows 6.0 WWADAPT2
16-bit passive C/C++ Work Performers must be VWDLLADP
recompiled as 32-bit C/C++ Work Performers

December 1996 Work Performer Developer’s Guide 1


Writing Work Performers
32-bit Work Performers

WorkFlo Script WFLADAPT


16-bit passive Work Performers that expose OLE VWOLEADP
Automation methods

Note Passive Work Performers that use the VWOLEADP adaptor must be OLE-
enabled (i.e. they must be OLE servers).

Active Work Performers


16-bit active Work Performers can be the following:

• Any program that can use the services of an OLE Automation server or
that can interface with a 16-bit C DLL

• C/C++ active Work Performer that uses SVCAPI.DLL

• Visual Basic 3.0 active Work Performer

• PowerBuilder 3.0 active Work Performer

32-bit Work Performers


32-bit Work Performers are those compiled to run on Windows 95 or NT.

Passive Work Performers


32-bit passive Work Performers use the following adaptors:

Language Adaptor
C/C++ VWDLLADP
WorkFlo Script (WFD 5.0) WFLADAPT
Visual Basic 4.0 VWOLEADP
PowerBuilder 5.0 VWOLEADP
Excel 7.0 VWOLEADP

Note that there is no 32-bit adaptor for Microsoft Word; you will need to find a
solution using the languages and adaptors listed above.

2 Work Performer Developer’s Guide December 1996


Writing Work Performers
Work Performer Design Considerations

Note Passive Work Performers that use the VWOLEADP adaptor must be OLE-
enabled (i.e. they must be OLE servers).

Active Work Performers


32-bit Active Work Performers can be the following:

• Any program that can use the services of an OLE Automation server or
interface with a 32-bit C DLL

• C/C++ active Work Performer that uses VWAPI.DLL

• Visual Basic 4.0 active Work Performer

• PowerBuilder 5.0 active Work Performer

Work Performer Design Considerations


Instructions on an Instruction Sheet have a one-to-one correspondence with
Work Performer functions (Operations) and System Instructions. The
functions in Work Performers execute the Operations required by Work
Objects in the Visual WorkFlo queues.

You should consider the following points when designing Work Performers:

• Active or passive Work Performer?

• Number of Work Queues (the number of Work Queues is equal to the


number of Work Performer classes)

• Number of Work Queue fields

• Granularity of Work Performer Operations

• Reusability

• Validation checking of data

• Work Performer Security

December 1996 Work Performer Developer’s Guide 3


Writing Work Performers
Work Performer Design Considerations

Active or Passive Work Performer?


The basic distinction between Work Performers (excluding that of the
language used) is whether a Work Performer is active or passive. Passive
Work Performers are appropriate for unattended tasks or when users are to
be given the next available Work Object to process. Active Work Performers
should be used when users will need to select Work Objects to process or
when very complex selection criteria are used.

Passive Work Performers have the following characteristics:

• Are generally suitable for unattended tasks that do not require interaction
with the user.

• Do not have selective access to Work Queues.

• Are started and stopped by Visual WorkFlo/Performer.

• Have Work Objects dispatched to them by Visual WorkFlo. Passive Work


Performers cannot choose Work Objects to process.

• Use adaptors to communicate with Visual WorkFlo; the conversation is


initiated by Visual WorkFlo via the adaptor.

Active Work Performers have the following characteristics:

• Are usually started and stopped by the user, not Visual WorkFlo/
Performer. Active Work Performers associated with a role are started by
Visual WorkFlo/Performer. See the Visual WorkFlo/Performer Handbook
for more information on roles.

• Initiate and end Visual WorkFlo processing.

• Do not require adaptors to communicate with Visual WorkFlo.

• Can browse queues and select specific Work Objects to be processed.

• Use API calls to obtain the Operation name and Work Object handle.

• Can browse multiple Work Queues. To browse multiple Work Queues, an


active Work Performer must attach to each Work Queue and report to
work for each Work Queue.

4 Work Performer Developer’s Guide December 1996


Writing Work Performers
Work Performer Design Considerations

Number of Work Queues


The number of Visual WorkFlo queues can affect performance. More queues
with few entries is recommended over a few queues with many entries.

Searching for a Work Object or sorting the Work Objects is more efficient
when the queues are shallow because there are fewer entries to search
through or sort.

Number of Work Queue Fields


Having a large number of Work Queue fields (exposed fields) can

• affect performance because there is more data in the queues to process.

• can increase database space usage.

Work Queue fields are copies of Work Object data fields that are used in
entry, pre-selection, selection, and sort rules. They are also used by active
Work Performers for browsing queues.

Granularity of Work Performer Operations


Granularity means the amount of work accomplished within a Work Performer
Operation. A small-grained Operation is one that does very little, such as
displaying a print dialog box for user input. A large-grained Operation is one
that performs a series of logically related business steps, such as providing
input forms for a loan officer to input customer and loan data and then
calculating a payment schedule based on that data.

Because Visual WorkFlo must queue work between execution of each Work
Performer Operation, small-grained Operations can result in poor
performance. However, the larger the granularity of the Operation, the more
specific and less reusable the Operation becomes.

Operations should consist of a business task, such as writing a check or


verifying application information.

Reusability
Whenever possible, Work Performer Operations should be reusable without
sacrificing effectiveness by making them too general. If Operations are
reusable, Work Performers are smaller and easier to maintain and
development of new business processes is faster. Remember to consider
performance implications as mentioned in the previous section.

December 1996 Work Performer Developer’s Guide 5


Writing Work Performers
Work Performer Design Considerations

Validation Checking
Your Work Performer should validate Work Performer data fields, Operation
parameters, and Work Queue fields before using them. Verify that numeric
values are within the acceptable ranges and strings are not unexpectedly null.

Your Work Performer should contain code for exception conditions that might
occur while processing a Work Object. Work Performers might need to call the
Malfunction Instruction Sheet to handle invalid data problems. You might also
need to create new Instruction Sheets to handle specific data errors.

Work Performer Security


Visual WorkFlo provides security management services to control access to
Work Performers. See the “Security Management” section in the Visual
WorkFlo/Composer Handbook for information on specifying Work Performer
access rights.

Keeping Track of Operations and Parameters


When writing Work Performers that contain multiple Operations, it is important
to keep track of the parameters used by each Operation. For each parameter,
the native data type, corresponding Visual WorkFlo data type, and direction
mode should be tracked.

We recommend that you maintain a list of these elements and keep it handy
as you develop your Work Performers. The following example shows a table
used for this purpose.

WP_Name: SampleWP_1
Visual
Parameter WorkFlo
Operation Name Native type type Mode
Operation1 Parameter_1 long integer in
Parameter_2 double float out
Parameter_3 char * string in
Parameter_4 BOOL boolean inout
Operation2 Parameter_1 long integer in
Parameter_2 BOOL boolean inout

6 Work Performer Developer’s Guide December 1996


Writing Work Performers
Work Performer Design Considerations

Parameter_3 char * string in


Parameter_4 double float out

Visual WorkFlo Array Handling


Visual WorkFlo provides array handling for all of the simple data types. Arrays
can only be single-dimensional. The following table provides an overview of
Visual WorkFlo’s array handling capabilities:

Newly–
Passive Active created Work
Work Work Object initial Data
Language Performer Performer values Types
DLLs Yes Yes, via API Yes, via API All
calls calls
WorkFlo Script Yes Yes Yes All
OLE Yes Yes Yes None

Passive Work Performer Executable Files


The following table indicates the location and file extension for passive Work
Performers:

The file extension must


If the executable file is be The executable file must be located in
Excel for Windows .XLM Either of the following:
PowerBuilder .EXE The directory in which the Visual WorkFlo
Visual Basic .EXE software is installed (C:\VW by default)

Any language that can .DLL A directory specified in the path command in
interface with a 32-bit C DLL the AUTOEXEC.BAT file (see your Microsoft
DOS documentation for more information)
WorkFlo Script .WFL A directory designated in the Search Path in
the LOGON.CFG file (see the WorkForce
Coordinator’s Handbook for more information)
OLE server .Class1. The file name The registry is used to locate the executable
is the Work Performer file.
class name for the
OLE server.

December 1996 Work Performer Developer’s Guide 7


Writing Work Performers
Adaptors

On NT systems, the path to OLE server .EXE files (VWAPISRV.EXE or any


OLE-aware passive Work Performers) must be in the system path that is set
via the System dialog in the Control Panel.

Adaptors
Passive Work Performers use adaptors to communicate with Visual WorkFlo.
The following description of adaptors is provided for information purposes
only; it is unlikely that you will need to write an adaptor or know the details of
adaptors.

Adaptors contain four entry points: adaptorType, start, perform, and stop.

The adaptorType entry point establishes the type of this particular adaptor.
Currently, only one type of adaptor is supported: C2.

The start entry point initiates a conversation between the Visual WorkFlo
software and the Work Performer. It is responsible for loading any executable
files, DLLs, etc., necessary to run the Work Performer Operation. Once
running, this conversation continues until the stop entry point is called.

When the Work Object dispatch software determines that a Work Object
needs a particular Work Performer, it calls the perform entry point. The
adaptor can assume responsibility for getting and setting parameters or make
the Work Performer responsible for getting and setting parameters.

The stop entry point terminates the conversation initiated with the start entry
point. It disconnects the Work Performer from Visual WorkFlo and informs the
dispatch software that the Work Performer is no longer available.

VWOLEADP Adaptor
The VWOLEADP adaptor is an OLE Automation controller. The Work
Performers that use VWOLEADP are OLE Automation servers. VWOLEADP
calls the appropriate method exposed by the Work Performer, passing it all of
the required parameters.

8 Work Performer Developer’s Guide December 1996


Writing Work Performers
Function Sequences

VW.INI File
An appropriately named adaptor section is required in the VW.INI file for every
adaptor that uses DDE to communicate with Work Performers.

Each adaptor section specifies a DDE timeout that is the number of seconds
that can elapse before the DDE connection times out. This setting represents
the maximum amount of time during which the Work Performer must complete
processing the Work Object.

Each adaptor section can also specify a connect timeout value. This value
specifies the number of seconds allowed for the Work Performer to start
before failure occurs due to a DDE connection timeout.

See the Installation Handbook for Windows for more information on the
VW.INI file.

Function Sequences
This section provides diagrams showing the order in which the different APIs
must be called. The shaded boxes in the diagrams are shown in more detail in
subsequent diagrams.

The function sequence diagrams are divided into the following three
categories:

• Active Work Performers – process Work Objects, executing Instructions


on Instruction Sheets.

• Passive Work Performers – process Work Objects, executing Instructions


on Instruction Sheets.

• Administration programs – create Work Objects, administer Work Objects,


prepare reports.

December 1996 Work Performer Developer’s Guide 9


Writing Work Performers
Function Sequences

Active Work Performer Function Sequences

VW_Logon()

VW_AttachToWorkQueue()

Browse Queue and


Process Work Objects

VW_DetachFromWorkQueue()

VW_Logoff()

Active Work Performer Function Sequences

10 Work Performer Developer’s Guide December 1996


Writing Work Performers
Function Sequences

Browse Queue and


Process Work Objects

VW_ReportToWork()

VW_BrmCreateBrowseModifier()

VW_GetLoggingState() VW_BrmSetPreSelectRule()
VW_BrmSetSelectRule()
VW_BrmSetSortRules()

VW_LogMessage()

VW_BeginBrowsingWorkQueue()
VW_SetLoggingState()

VW_NextWorkObjectToBrowse()

Process Work Object

VW_GetOperationNameSize()

VW_GetOperationName()

VW_EndBrowsingWorkQueue()

*VW_BrmFreeBrowseModifier()

*Note that you only need to call


VW_LeaveWork() VW_BrmFreeBrowseModifier() if you called
VW_BrmCreateBrowseModifier().

Browse Queue Function Sequences

December 1996 Work Performer Developer’s Guide 11


Writing Work Performers
Function Sequences

Process Work Object

VW_LockWorkObject()

VW_TerminateWorkObject()
VW_CurrentException()

Set data functions


Get data functions VW_RaiseException()
VW_GetWorkPerformerHandle()

VW_UnlockWorkObject()
or
VW_UnlockAndDispatch()

Process Work Object Function Sequence

In any of the active Work Performer function sequence diagrams, the following
APIs can be called at any point:

• VW_GetErrorMessageSize()

• VW_GetErrorMessage()

• VW_CheckVersionCompatibility()

• VW_SetLogCacheFlushLength()

See “Data Access API Calls” on page 23 for a list of set data and get data
functions.

12 Work Performer Developer’s Guide December 1996


Writing Work Performers
Function Sequences

Passive Work Performer Function Sequences


The function sequences for passive Work Performers are divided into two
categories:

• Work Performers that access parameters directly.

• Work Performers that use API calls to get and set parameters.

Adaptor Interface

VW_TerminateWorkObject()

VW_CurrentException()
VW_GetWorkPerformerHandle()

VW_GetLoggingState()

Set data functions VW_LogMessage()


Get data functions

VW_SetLoggingState()
VW_RaiseException()

End of Operation

Function Sequences of Work Performers that access parameters directly

December 1996 Work Performer Developer’s Guide 13


Writing Work Performers
Function Sequences

Operation Handle
from Adaptor

VW_GetOperationNameSize()

VW_GetOperationName()

Log a message
VW_RaiseException()
VW_CurrentException()

Set data functions


Get data functions VW_TerminateWorkObject()

End of Operation

Function Sequences of Work Performers that use API calls to access parameters

14 Work Performer Developer’s Guide December 1996


Writing Work Performers
Function Sequences

Log a message

VW_GetWorkPerformerHandle()

VW_GetLoggingState()

VW_SetLoggingState()

VW_LogMessage()

Log a Message Function Sequence

Note that VW_GetLoggingState() and VW_SetLoggingState() only need to be


called if the user logging bit is not set and you want to change it before logging
a message.

In any of the passive Work Performer function sequence diagrams, the


following APIs can be called at any point:

• VW_GetErrorMessageSize()

• VW_GetErrorMessage()

• VW_CheckVersionCompatibility()

• VW_SetLogCacheFlushLength()

See “Data Access API Calls” on page 23 for a list of set data and get data
functions.

December 1996 Work Performer Developer’s Guide 15


Writing Work Performers
Function Sequences

Administration Program Function Sequences


The following diagram shows the function sequence for creating Work
Objects:

VW_Logon()

VW_CreateWorkObject()

Set data functions

VW_DispatchWorkObject()

VW_Logoff()

Work Object Creation Function Sequence

16 Work Performer Developer’s Guide December 1996


Writing Work Performers
Function Sequences

The next diagram shows the function sequence for locating a Work Object and
obtaining information about a Work Object:

VW_Logon()

VW_WobQueryCreate()

Set data functions

VW_WobQueryExecute()

VW_WobQueryWorkPerformerClass()
VW_WobQueryOperation()
VW_WobQueryInstrSheet()
VW_WobQueryGetAccessHandle()

*VW_FreeAccessHandle()

VW_WobQueryEnd()

VW_Logoff()

* Note that you only need to call


VW_FreeAccessHandle() if you called
VW_WobQueryGetAccessHandle()

Locating a Work Object Function Sequence

Note that you do not have to make calls to all of the query functions; you can
call one or more of the following functions:

• VW_WobQueryWorkPerformerClass()

• VW_WobQueryOperation()

December 1996 Work Performer Developer’s Guide 17


Writing Work Performers
API Calls Overview

• VW_WobQueryInstrSheet()

• VW_WobQueryGetAccessHandle()

If you call VW_WobQueryGetAccessHandle(), you must free the access


handle by calling VW_FreeAccessHandle().

API Calls Overview


The API calls provide Visual WorkFlo services including Work Object creation,
queue handling, and exception handling.

This section provides a brief description of the API calls, organized into usage
categories.

This section also describes the calls in the VBSVCAPI.DLL that can be called
from a 16-bit Visual Basic Work Performer.

Logon and Logoff API Calls


Work Performers must log on before browsing queues, locating Work Objects,
locking Work Objects, or creating Work Objects. Administration programs and
Work Performers can call these APIs.

VW_Logon() should be called once when the Work Performer is started.


VW_Logoff() should be called once when the Work Performer is shut down.

VW_Logon Returns a logon Id used in subsequent calls.


VW_Logoff Invalidates the logon Id returned from VW_Logon() and frees
resources allocated by VW_Logon().

Work Object Creation API Calls


You use these two calls to create a Work Object and dispatch the new Work
Object to the appropriate queue. The data access functions (see “Data
Access API Calls” on page 23) are used to set values in the newly-created
Work Object.

18 Work Performer Developer’s Guide December 1996


Writing Work Performers
API Calls Overview

Administration programs and Work Performers can call these APIs.

VW_CreateWorkObject Creates a Work Object.


VW_DispatchWorkObject Dispatches a newly-created Work Object to a
Work Queue.

Logging Support API Calls


These API calls are useful when developing and debugging Work Performers.
You can log messages to the History Repository to determine what a Work
Performer is doing.

Logging messages might be impractical when Work Performers are in daily


use because log messages require time for processing and space in the
History Repository. You can use VW_SetLoggingState() to change the types
of messages that are logged for a Work Performer.

All Work Performers can call these APIs.

VW_GetLoggingState Returns the ON/OFF state of a particular


bit in the Work Performer’s logging vector.
VW_LogMessage Logs a user-defined message.
VW_SetLogCacheFlushLength Specifies the maximum number of entries
in the PC’s log cache after which the PC’s
log cache entries are transferred to the
History Repository.
VW_SetLoggingState Sets the state of a particular bit in the Work
Performer’s logging vector.

Queue Handling API Calls


You use the queue handling APIs to locate a specific Work Object in a queue
(referred to as browsing a queue), lock a Work Object for processing, or
unlock a Work Object. Only active Work Performers can call these APIs.

VW_AttachToWorkQueue() and VW_ReportToWork() should be called once


when the Work Performer starts. VW_LeaveWork() and
VW_DetachFromWorkQueue() should be called once when the Work
Performer is shut down. If the Work Performer browses multiple Work Queues,
these calls should be made once for each queue when the Work Performer is
started and shut down.

December 1996 Work Performer Developer’s Guide 19


Writing Work Performers
API Calls Overview

VW_BrmCreateBrowseModifier() creates a browse modifier object that can


override the default behavior of a Work Queue’s rules. Call VW_BrmSet-
PreSelectRule(), VW_BrmSetSelectRule(), or VW_BrmSetSortRules() to
specify new rules in the browse modifier object. To apply the new rules to the
queue, call VW_BeginBrowsingWorkQueue(), passing the handle to the
browse modifier object as a parameter.

You must call VW_BrmFreeBrowseModifier() to free the resources associated


with the browse modifier object. You can call this function at any time after
calling VW_BeginBrowsingWorkQueue().

The Work Queue pre-selection rule is processed on the server at the time the
queue is browsed. The selection rule is processed on the client at the time the
queue is browsed, after the server has completed its processing. The sort
rules are processed as follows:

• If there are no Work Performer fields specified in any sort expressions, the
sort rules are evaluated by the client before insertion.

• If there are no Work Performer fields in any expressions and no sort


browse modifier, the sorting is done by the server when browsing.

• If there are Work Performer fields in expressions or sort browse modifiers,


the sort rules are processed by the client during the browse (after the
selection rules are processed).

For more information about pre-selection rules, selection rules, and sort rules,
see the “Specify Work Queue Rules” section in the “Creating and Modifying
Work Performer Classes” chapter of the Visual WorkFlo/Composer
Handbook.

VW_AttachToWorkQueue Identifies the Work Queue that will be


browsed.
VW_BeginBrowsingWorkQueue Starts browsing a Work Queue. Identifies
a browse session on the Work Queue of
the specified Work Performer class.
VW_BrmCreateBrowseModifier Using the returned handle, you can make
subsequent calls to the browse modifying
APIs and override the rules that govern
Work Queue behavior.
VW_BrmSetPreSelectRule Specifies a pre-selection rule.
VW_BrmSetSelectRule Specifies a selection rule.

20 Work Performer Developer’s Guide December 1996


Writing Work Performers
API Calls Overview

VW_BrmSetSortRules Specifies sort rules.


VW_BrmFreeBrowseModifier Frees the resources allocated by
VW_BrmCreateBrowseModifier().
VW_DetachFromWorkQueue Frees the resources allocated by
VW_AttachToWorkQueue().
VW_EndBrowsingWorkQueue Ends the browse session, releases the
specified browse Id and its resources.
VW_LeaveWork Un-registers an active Work Performer
with Visual WorkFlo. Releases the
specified Work Performer Id and its
resources.
VW_LockWorkObject Locks the specified Work Object and
returns a lock Id.
VW_NextWorkObjectToBrowse Retrieves the next Work Object in the
Work Queue. Returns a Work Object Id.
VW_ReportToWork Registers an active Work Performer with
Visual WorkFlo. Returns an Id for the
specified Work Performer.
VW_UnlockWorkObject Unlocks the specified Work Object,
releases the Work Object Id and its
resources. Current Operation processing
is ignored.
VW_UnlockAndDispatch Unlocks the specified Work Object and
dispatches it to the next Work Queue. Also
releases the Work Object Id and its
resources.

Work Object Access API Calls


These API calls are used to get or free a Work Object access handle. The
access handle can be passed to the data access API calls (see “Data Access
API Calls” on page 23). If you call one of the Set data API calls with the
access handle as a parameter, you can make changes to the Work Object.

VW_FreeAccessHandle() can be called by active Work Performers and


administration programs. VW_GetAccessHandle() can be called from active
Work Performers. VW_WobQueryGetAccessHandle() can be called by
administration programs.

December 1996 Work Performer Developer’s Guide 21


Writing Work Performers
API Calls Overview

VW_FreeAccessHandle Frees the handle returned by


VW_GetAccessHandle() or
VW_WobQueryGetAccessHandle().
VW_GetAccessHandle Returns a handle to a Work Object that
can be used in subsequent data access
API calls.
VW_WobQueryGetAccessHandle Returns a handle to a Work Object that
can be used in subsequent data access
API calls. Requires a query handle
returned from VW_WobQueryCreate().

Work Object Information API Calls


The Work Object information APIs are used to obtain the Operation name or
Work Performer handle for a Work Object.

VW_GetOperationName(), VW_GetOperationNameSize(), and VW_Get-


WorkPerformerHandle() can be called by active or passive Work Performers.
VW_GetWobSignature() can be called from active Work Performers.

VW_GetOperationName Returns the name of the next Operation


required by the specified Work Object.
VW_GetOperationNameSize Returns the size (in bytes) of an
Operation name.
VW_GetWorkPerformerHandle Returns the handle of the Work Performer
associated with the specified
VW_OperationHandle. Passive Work
Performers may need to obtain the Work
Performer handle to access Work
Performer data fields.
VW_GetWobSignature Returns a string containing the signature
for the Work Object.

22 Work Performer Developer’s Guide December 1996


Writing Work Performers
API Calls Overview

Work Object Binding API Calls


The Work Object Binding APIs are used to restrict processing of a Work
Object to a specific user and to remove restrictions placed on a Work Object.

These APIs can be called by active Work Performers.

VW_BindToUser Restricts processing of a Work Object to a specific


user.
VW_UnBind Removes restrictions placed on a Work Object.

Data Access API Calls


You use these API calls to get or set the values of Work Object fields,
Operation parameters, Work Queue fields, or Work Performer fields. Both
active and passive Work Performers can call these APIs.

VW_FreeArrayPtr Frees an array returned by VW_GetArrayPtr().


VW_GetArrayPtr Returns either the value of a Work Performer field
or an Operation parameter.
VW_GetArraySize Returns the number of elements in the requested
array.
VW_GetBoolean Returns the boolean value of a specified field
name.
VW_GetDataType Returns the data type of the specified field.
VW_GetDataTypeArray Returns the data type of the elements of the
specified array.
VW_GetFloat Returns the float value of a specified field name.
VW_GetInteger Returns the integer value of a specified field
name.
VW_GetString Returns the string value of a specified field name.
VW_GetStringSize Returns the size (in bytes) of a string field.
VW_GetTime Returns the time value of a specified field name.
VW_SetArrayPtr Sets values into the specified array.
VW_SetBoolean Sets a boolean value in the specified field.
VW_SetFloat Sets a float value in the specified field.

December 1996 Work Performer Developer’s Guide 23


Writing Work Performers
API Calls Overview

VW_SetInteger Sets an integer value in the specified field.


VW_SetString Sets a string value in the specified field.
VW_SetTime Sets a time value in the specified field.

Work Object Location API Calls


You use these calls to allow the user to locate a particular Work Object. These
calls can be called from administration programs that locate Work Objects or
obtain information about Work Objects.

VW_WobQueryCreate Creates a query for the specified


Work Class and returns a handle.
VW_WobQueryExecute Executes the specified query and
returns a count of matching Work
Objects.
VW_WobQueryWorkPerformerClass Returns the name of the Work
Performer class in whose Work
Queue the Work Object identified
by ‘wobQueryHandle’ is located.
VW_WobQueryOperation Returns the name of the next
Operation to process the Work
Object identified by
‘wobQueryHandle.’
VW_WobQueryInstrSheet Returns the name of the Instruction
Sheet through which the Work
Object identified by ‘wobQuery-
Handle’ is currently being
processed.
VW_WobQueryEnd Frees the resources associated
with the query.

24 Work Performer Developer’s Guide December 1996


Writing Work Performers
Debugging Work Performers

Error Handling API Calls


You use these API calls to handle exception conditions that occur when a
Work Performer is executing. Both active and passive Work Performers can
call these APIs.

VW_CheckVersionCompatibility Checks that the Work Performer is


compatible with the currently running
version of Visual WorkFlo.
VW_CurrentException Returns the name and description of the
latest exception in the Work Object’s call
stack.
VW_GetErrorMessageSize Returns the size in bytes of an error
message.
VW_GetErrorMessage Returns the error message string that
corresponds to the specified error code.
VW_RaiseException Causes execution of a specified
exception handling Instruction Sheet.
VW_TerminateWorkObject Terminates the Work Object being
serviced.

Debugging Work Performers


When debugging Work Performers, errors may cause a Work Performer to fail
to call the second API function of paired APIs. Paired API functions are those
that have a second API function that must be called to release resources
allocated by the first API. For example, VW_Logon() and VW_Logoff() or
VW_ReportToWork() and VW_LeaveWork().

Failure to call the second function in an API pair can cause unexpected
behavior. During debugging, you might want to modify your Work Performer to
provide a button on the user interface that, when clicked, will call the
appropriate functions for the API pairs.

Message Logging
The message logging facilities can be used to help debug Work Performers.
VW_LogMessage() writes a user-defined message to the History Repository.
You can log messages to display what your Work Performer is doing or to log
serious errors.

December 1996 Work Performer Developer’s Guide 25


Writing Work Performers
Debugging Work Performers

The message is only written to the History Repository if the specified logging
option is ON (1) in both the Work Performer’s set of logging options and the
client logging vector defined in the VW.INI file. The message only stays in the
active portion of the History Repository until the Work Object is terminated, at
which time it is purged from the active repository. The message may be
moved from the active to the inactive repository depending on the options set
in Visual WorkFlo/Composer. For more information on logging, see the
“Logging Features” section in the “Creating a Visual WorkFlo Application”
chapter of the Visual WorkFlo/Composer Handbook.

You can also have each API call logged to a file. You must turn ON the
LogSvcApiCalls option in the [LogFile] section of the VW.INI file. API calls are
only logged if the LogToFile entry in the [LogFile] section is also ON. Note that
output parameters are not logged for VBSVCAPI calls.

Each API call is logged along with its input parameters when the function is
called. Each API call is also logged when the function exits, along with its
output parameters. API calls are separated by lines of equal signs (“=”) in the
log file.

For more information on logging API calls, see the Installation Handbook for
Windows.

Using NDump
NDump is a Work Performer that dumps the contents of each field in a Work
Object to the file NDUMP.LOG. The NDUMP.LOG file will need to be
periodically removed or truncated to avoid consuming large amounts of disk
space.

Before you can use NDump in an Instruction Sheet, you must create a Work
Performer class with a single Operation. For example, the Work Performer
class could be NDumpWP and the name of the Operation NDump. The
NDump Operation has no parameters.

After you have created the NDumpWP class, you must also specify the
adaptor name (NDUMP.DLL) and the executable script name (also
NDUMP.DLL) in the Properties editor tab.

See the “Creating and Modifying Work Performer Classes” chapter in the
Visual WorkFlo/Composer Handbook for more information on creating a Work
Performer class and specifying an adaptor and executable file.

26 Work Performer Developer’s Guide December 1996


Writing Work Performers
Debugging Work Performers

NDump is a passive WorkPerformer and must be started by Visual WorkFlo/


Performer. See the Visual WorkFlo/Performer Handbook for information on
starting passive Work Performers.

To use NDump, you place the NDump Operation on an Instruction Sheet


before and after the Operation you are debugging. The file will contain the
contents of the Work Object before and after the Operation has processed it,
which allows you to see what the Operation is doing to the Work Object.

Sample NDump Output


NDump outputs the name of the Work Object class, the date and time the
Work Object was processed, and a list of all the fields in the Work Object and
their corresponding values.

The following sample output shows the NDump output for a work object of
type DelayedWO00.

Class Name: DelayedWO00 01/23/96 19:14:49

string1 yes
string2
string3
time1 1/1/1995 00:01:00
boolean1 true
integer1 2
SerialNumber 2001
float1 2
LoggingVector 0

Class Name: DelayedWO00 01/23/96 19:14:53

string1 yes
string2
string3
time1 1/1/1995 00:01:00
boolean1 true
integer1 2
SerialNumber 2002
float1 2
LoggingVector 0

December 1996 Work Performer Developer’s Guide 27


Writing Work Performers
Debugging Work Performers

28 Work Performer Developer’s Guide December 1996


2
2Work Performers that Use
OLE Automation

This chapter describes

• how to write active or passive Work Performers that use OLE

• how to converting existing Visual Basic Work Performers to use OLE

• the syntax for the VWAPISRV API calls

This chapter also shows example code for active and passive Work
Performers.

Writing Active or Passive Work Performers that Use OLE


This section describes how to write passive Work Performers that are OLE
servers (i.e. passive Work Performers that use VWOLEADP.DLL) and how to
write active Work Performers that use OLE Automation.

Writing Passive Work Performers that Use VWOLEADP.DLL


The OLE data types correspond to Visual WorkFlo types as shown in the
following table:

Visual WorkFlo
Parameter Type OLE Data Type
Arrays Variant
String String
Time Long
Integer Long
Float Double
Boolean Boolean

December 1996 Work Performer Developer’s Guide 29


Work Performers that Use OLE Automation
Writing Active or Passive Work Performers that Use OLE

After you have developed an OLE server, you must create a corresponding
Work Performer class with operations defined for each publicly exposed
method of the OLE server. See the Visual WorkFlo/Composer Handbook for
more information on creating a Work Performer Class.

In Visual WorkFlo/Composer, the Operation names in the Work Performer


class must be identical to the method names that are publicly exposed by the
OLE server. The order of the parameters for each Operation must match the
order of the parameters specified for the corresponding publicly exposed
method of the OLE server. The spelling of the parameters for the Operation
and the method do not have to correspond.

The adaptor name must be VWOLEADP.DLL.

The script name must be the ProgId of the OLE server.

The ProgId for an OLE server is used in composer to identify the Work
Performer. The ProgId is generated automatically for most development
environments. Refer to the documentation for your development environment
to determine what the ProgId will be.

Note A passive Work Performer that is an OLE server can be either an In-Process
or Out-of-Process server.

To allow passive Work Performers to cancel an Operation, VWOLEADP


provides support for passive Work Performers to return a boolean value
indicating the success (TRUE) or failure (FALSE) of the operation.

If the Work Performer returns TRUE, the inout and out parameter values are
copied back into the Work Object and the Work Object is dispatched to the
next Instruction.

If the Work Performer returns FALSE, parameter values are not copied to the
Work Object and the Work Object is routed to the Malfunction Instruction
Sheet.

Registering OLE Servers


Passive Work Performers that are OLE servers must be registered. We
recommend that OLE servers be self-registering.

Some development environments, such as Visual Basic, register OLE servers


when they are built. If the development environment you are using does not
do this, you must write code to do the registration. When the OLE server is

30 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Converting Visual Basic Work Performers to use OLE

copied to another work station from the one it was built on, it must be run to
register itself.

Visual Basic OLE Servers


When developing a Visual Basic Work Performer as an OLE Automation
server, you should:

• Set the Public property for the class module to TRUE.

• Set the Instancing property for the class module to 1 (SingleUse) or 2


(Multiuse).

See “A Passive Work Performer that Uses OLE” on page 48 for an example of
a simple passive Work Performer that uses VWOLEADP.DLL.

Writing Active Work Performers that Use OLE Automation


See “An Active Work Performer that Uses OLE” on page 41 for an example of
a simple active Work Performer that uses OLE.

Converting Visual Basic Work Performers to use OLE


This section describes how to convert a Visual Basic passive Work Performer
to be an OLE server and how to convert a Visual Basic active Work Performer
or Visual WorkFlo-aware program to use OLE Automation.

Converting a Visual Basic Passive Work Performer to be an OLE Server


For the image file of the existing Work Performer:

1 In Visual WorkFlo/Composer, open the image file.

2 Change the adaptor name from VBADAPT2.DLL to VWOLEADP.DLL.

3 Change the script name to WP_class_name.Class1, where WP_class_name


is the Work Performer class name for the OLE server.

4 Save to the Authoring repository.

5 Transfer to the On-line repository.

December 1996 Work Performer Developer’s Guide 31


Work Performers that Use OLE Automation
Converting Visual Basic Work Performers to use OLE

To convert a Work Performer from Visual Basic 3.0 to Visual Basic 4.0:

1 In Visual Basic 3.0, save all form files as text.

This allows WorkFlo Controls for Visual Basic VBXs to be converted to the
new OCX controls. Forms saved in binary format cannot be converted. You
must have already loaded WorkFlo Controls for Visual Basic 5.0 to do the
conversion.

2 Load the project into Visual Basic 4.0. Allow Visual Basic to upgrade all VBXs
to OCXs.

3 Answer OK to all at the prompt to save as new format.

4 Don’t add DAO 2.5 Object Library. It isn’t used.

In Visual Basic 4.0:

1 Load the project.

2 Select Options from the Tools Menu, then select the Project tab. Change
StartMode from Standalone to OLE Server. Change Project Name to the
Work Performer class name defined in the image file.

3 Select Class Module in the Insert menu.

4 Select Properties in the View menu. Set the Class1 properties as follows:

Instancing: Createable Multiuse

Name: Class1

Public: True

5 Create Public subroutines in Class1 for each Operation.

The names of the subroutines must be the same as the Operation names.

Parameters must be in the same order as the Visual WorkFlo Operation fields.
In parameters should be ByVal. Out and InOut parameters should be ByRef.

Visual WorkFlo Boolean types are now defined in Visual Basic as Boolean
(instead of Integer). An error will occur if the parameter types do not match.

6 Copy the Operation code from the Visual WorkFlo form.

32 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Converting Visual Basic Work Performers to use OLE

7 Remove Set and Get functions for the Operation parameters.

8 Remove the Visual WorkFlo form.

9 Remove the Load of Visual WorkFlo form from the default form Load
procedure.

10 Define the VWServer object in a standard module file (.BAS file), as follows:

Public VWServer As Object

This is only required if the Work Performer makes Visual WorkFlo API calls.

11 Create the OLE Automation object, as follows:

Set VWServer = CreateObject("VWApi.Srv")

This is only required when the Work Performer makes Visual WorkFlo API
calls. Do not put the CreateObject call in the Startup form or module; this will
hang Visual WorkFlo/Performer.

12 In the current project, replace all occurrences of “= VB_VW” with “= VW_”.


Then replace all occurrences of “= VW” with “= VWServer.VW_”.

13 Save the project.

14 Make a .exe or OLE DLL file.

Converting a Visual Basic Active Work Performer or


Visual WorkFlo Aware Program to Use OLE
To convert a Work Performer from Visual Basic 3.0 to Visual Basic 4.0:

1 In Visual Basic 3.0, save all form files as text.

This allows WorkFlo Controls for Visual Basic VBXs to be converted to the
new OCX controls. Forms saved in binary format cannot be converted. You
must have already loaded WorkFlo Controls for Visual Basic 5.0 to do the
conversion.

2 Load the project into Visual Basic 4.0. Allow Visual Basic to upgrade all VBXs
to OCXs.

3 Answer OK to all at the prompt to save as new format.

4 Don’t add DAO 2.5 Object Library. It isn’t used.

December 1996 Work Performer Developer’s Guide 33


Work Performers that Use OLE Automation
VWAPISRV API Calls

In Visual Basic 4.0:

1 Remove API_DECS.BAS from the project.

2 Define the VWServer object, as follows:

Dim VWServer As Object

3 Create the OLE Automation object in the form Load procedure, as follows:

Set VWServer = CreateObject("VWApi.Srv")

4 In the current project, replace all occurrences of “= VB_VW” with “= VW_”.


Then replace all occurrences of “= VW” with “= VWServer.VW_”.

5 Remove the OLE Automation object in the form Unload procedure, as follows:

Set VWServer = Nothing

6 Save the project.

7 Make the .exe file.

VWAPISRV API Calls


This section shows the syntax of the VWAPISRV API calls. The API calls
exported by the Visual WorkFlo OLE Automation server, VWAPISRV,
correspond to the API calls described in Chapter 3, “DLL Work Performers,”
on page 81 with the following exceptions:

• String parameters are type BSTR. Character arrays or pointers to


character (char[] or char *) are type BSTR. Pointers to char * (char **) are
pointers to BSTR (BSTR *).

• VW_GetArrayPtr() is now VW_GetArray(). VW_SetArrayPtr() is now


VW_SetArray(). VW_FreeArrayPtr() is not implemented in VWAPISRV; it
is the client’s responsibility to manage the SAFEARRAYs returned by
VWAPISRV API calls.

• Arrays must be SAFEARRAYs. Arrays that are passed by reference to an


API call must be passed as a VARIANT.

34 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
VWAPISRV API Calls

• The following API calls that have array parameters no longer have a
parameter that specifies the array length:

VW_BrmSetSortRules()
VW_CurrentException()
VW_GetFieldNames()
VW_GetArray()
VW_SetArray()

The array length is part of the information contained in a SAFEARRAY.

The following function definitions are from the type library source for
VWApiSrv.exe. The calls are listed in alphabetical order.

HRESULT VW_AttachToWorkQueue([in] long logonId, [in] BSTR


workPerformerClassName, [out] long* workQueueId, [out,
retval] long* retval);

HRESULT VW_BeginBrowsingWorkQueue([in] long workPerformerId, [out]


long* browseId, [in] long maxWorkObjectCount, [out] long*
workObjectCount, [in] long browseModHandle, [out, retval]
long* retval);

HRESULT VW_BindToUser([in] long wobHandle, [in] BSTR lpszUserName,


[out, retval] long * retval);

HRESULT VW_BrmCreateBrowseModifier([in] long workQueueId, [out] long*


browseModHandle, [out, retval] long* retval);

HRESULT VW_BrmFreeBrowseModifier([in] long browseModHandle, [out,


retval] long* retval);

HRESULT VW_BrmSetPreSelectRule([in] long browseModHandle, [in] BSTR


preSelectRuleExpr, [out, retval] long* retval);

HRESULT VW_BrmSetSelectRule([in] long browseModHandle, [in] BSTR


selectRuleExpr, [out, retval] long* retval);

HRESULT VW_BrmSetSortRules([in] long browseModHandle, [in] VARIANT


sortRuleExpressions, [in] VARIANT sortRuleLengths, [out,
retval] long* retval);

HRESULT VW_CheckVersionCompatibility([in] int majorVersionNum, [in] int


minorVersionNum, [out] long* curMajorVersionNum, [out]
long* curMinorVersionNum, [out, retval] long* retval);

December 1996 Work Performer Developer’s Guide 35


Work Performers that Use OLE Automation
VWAPISRV API Calls

HRESULT VW_CreateWorkObject([in] long logonId, [in] BSTR


workClassName, [out] long* newWorkObjectId, [out, retval]
long* retval);

HRESULT VW_CurrentException([in] long objectId, [out] BSTR* name, [out]


BSTR* description, [out, retval] long* retval);

HRESULT VW_DetachFromWorkQueue([in] long workQueueId, [out, retval]


long* retval);

HRESULT VW_DispatchWorkObject([in] long newWorkObjectId, [out, retval]


long* retval);

HRESULT VW_EndBrowsingWorkQueue([in] long browseId, [out, retval]


long* retval);

HRESULT VW_FreeAccessHandle([in] long wobAccessHandle, [in] short


saveUpdates, [in] short skipCurrentInstruction, [out, retval]
long* retval);

HRESULT VW_GetAccessHandle([in] long queueElementId, [in] short


lockForUpdate, [out] long* wobAccessHandle, [out, retval]
long* retval);

HRESULT VW_GetArray([in] long objectId, [in] BSTR fieldName, [out]


VARIANT* value, [in] int type, [out, retval] long* retval);

HRESULT VW_GetArraySize([in] long objectId, [in] BSTR fieldName, [out]


long* numElements, [out, retval] long* retval);

HRESULT VW_GetBoolean([in] long objectId, [in] BSTR fieldName, [out]


short* value, [out, retval] long* retval);

HRESULT VW_GetDataType([in] long objectId, [in] BSTR fieldName, [out]


long* fieldType, [out, retval] long* retval);

HRESULT VW_GetDataTypeArray([in] long objectId, [in] BSTR fieldName,


[out] long* fieldType, [out, retval] long* retval);

HRESULT VW_GetErrorMessage([in] long errorCode, [out] BSTR*


errorMessage, [out, retval] int* retval);

HRESULT VW_GetErrorMessageSize([in] long errorCode, [out, retval] int*


retval);

36 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
VWAPISRV API Calls

HRESULT VW_GetFieldNames([in] long objectId, [out] VARIANT*


fieldNames, [out, retval] long* retval);

HRESULT VW_GetFloat([in] long objectId, [in] BSTR fieldName, [out] double*


value, [out, retval] long* retval);

HRESULT VW_GetFPNumber([in] long objectId, [in] BSTR fieldName, [out]


VARIANT* value, [out, retval] long* retval);

HRESULT VW_GetInteger([in] long objectId, [in] BSTR fieldName, [out] long*


value, [out, retval] long* retval);

HRESULT VW_GetLoggingState([in] long objectId, [in] int loggingOption, [out]


short* loggingState, [out, retval] long* retval);

HRESULT VW_GetOperationName([in] long objectId, [out] BSTR*


operationName, [out, retval] long* retval);

HRESULT VW_GetOperationNameSize([in] long objectId, [out] long* size,


[out, retval] long* retval);

HRESULT VW_GetString([in] long objectId, [in] BSTR fieldName, [out] BSTR*


value, [out, retval] long* retval);

HRESULT VW_GetStringSize([in] long objectId, [in] BSTR fieldName, [out]


long* size, [out, retval] long* retval);

HRESULT VW_GetTime([in] long objectId, [in] BSTR fieldName, [out] long*


value, [out, retval] long* retval);

HRESULT VW_GetWobSignature([in] long wobHandle, [out] BSTR


*lpszWobSignature, [out, retval] long *retval);

HRESULT VW_GetWorkPerformerHandle([in] long operationHandle, [out]


long* workerHandle, [out, retval] long* retval);

HRESULT VW_LeaveWork([in] long workPerformerId, [out, retval] long*


retval);

HRESULT VW_LockWorkObject([in] long queueElementId, [out] long*


operationId, [out, retval] long* retval);

HRESULT VW_LogMessage([in] long objectId, [in] BSTR messageType, [in]


int loggingOption, [out, retval] long* retval);

HRESULT VW_Logoff([in] long logonId, [out, retval] long* retval);

December 1996 Work Performer Developer’s Guide 37


Work Performers that Use OLE Automation
VWAPISRV API Calls

HRESULT VW_Logon([out] long* plogonId, [out, retval] long* retval);

HRESULT VW_NextWorkObjectToBrowse([in] long browseId, [out] long*


queueElementId, [out, retval] long* retval);

HRESULT VW_RaiseException([in] long objectId, [in] BSTR exceptionName,


[in] BSTR description, [out, retval] long* retval);

HRESULT VW_ReportToWork([in] long workQueueId, [out] long*


workPerformerId, [out, retval] long* retval);

HRESULT VW_SetArray([in] long objectId, [in] BSTR fieldName, [in]


VARIANT value, [in] int type, [out, retval] long* retval);

HRESULT VW_SetBoolean([in] long objectId, [in] BSTR fieldName, [in] short


value, [out, retval] long* retval);

HRESULT VW_SetFloat([in] long objectId, [in] BSTR fieldName, [in] double


value, [out, retval] long* retval);

HRESULT VW_SetFPNumber([in] long objectId, [in] BSTR fieldName, [in]


VARIANT value, [out, retval] long* retval);

HRESULT VW_SetInteger([in] long objectId, [in] BSTR fieldName, [in] long


value, [out, retval] long* retval);

HRESULT VW_SetLogCacheFlushLength([in] long numberOfLogEntries,


[out, retval] long* retval);

HRESULT VW_SetLoggingState([in] long objectId, [in] int loggingOption, [in]


short loggingState, [out, retval] long* retval);

HRESULT VW_SetString([in] long objectId, [in] BSTR fieldName, [in] BSTR


value, [out, retval] long* retval);

HRESULT VW_SetTime([in] long objectId, [in] BSTR fieldName, [in] long


value, [out, retval] long* retval);

HRESULT VW_TerminateWorkObject([in] long objectId, [out, retval] long*


retval);

HRESULT VW_UnBind([in] long wobHandle, [out, retval] long *retval);

HRESULT VW_UnlockAndDispatch([in] long operationId, [out, retval] long*


retval);

38 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Example Work Performer Code

HRESULT VW_UnlockWorkObject([in] long operationId, [out, retval] long*


retval);

HRESULT VW_WobQueryCreate([in] long logonId, [in] BSTR


workClassName, [out] long* wobQueryHandle, [out, retval]
long* retval);

HRESULT VW_WobQueryEnd([in] long wobQueryHandle, [out, retval] long*


retval);

HRESULT VW_WobQueryExecute([in] long wobQueryHandle, [in] int


maxQueryCount, [out] long* queryCount, [out, retval] long*
retval);

HRESULT VW_WobQueryGetAccessHandle([in] long wobQueryHandle, [in]


int queryIndex, [in] short lockForUpdate, [out] long*
wobAccessHandle, [out, retval] long* retval);

HRESULT VW_WobQueryInstrSheet([in] long wobQueryHandle, [in] int


queryIndex, [out] BSTR* instrSheetName, [out, retval] long*
retval);

HRESULT VW_WobQueryOperation([in] long wobQueryHandle, [in] int


queryIndex, [out] BSTR* operationName, [out, retval] long*
retval);

HRESULT VW_WobQueryWorkPerformerClass([in] long wobQueryHandle,


[in] int queryIndex, [out] BSTR* workerClassName, [out,
retval] long* retval);

Example Work Performer Code


This section contains the following code examples:

• A VW_BrmSetSortRules() example

• An active Work Performer that uses OLE

• A passive Work Performer that uses OLE

• An active Visual Basic Work Performer that calls Microsoft Word

• An example of VW_WobQueryCreate() and related APIs

December 1996 Work Performer Developer’s Guide 39


Work Performers that Use OLE Automation
Example Work Performer Code

VW_BrmSetSortRules() Example
Private Sub Form_Load()

Dim VWApiSrv As Object


Dim SortRules As Variant
Dim SortRuleLengs As Variant
Dim logonId As Long
Dim wqId As Long
Dim wpId As Long
Dim browseId As Long
Dim browseCount As Long
Dim brModHandle As Long
Dim qeId As Long
Dim wpName As String

wpName = "VBCalc"

ReDim SortRules(0) As String


ReDim SortRuleLengs(0) As Integer

SortRules(0) = "SerialNumber"
SortRuleLengs(0) = 40

Set VWApiSrv = CreateObject("VWApi.Srv")

ErrorCode = VWApiSrv.VW_Logon(logonId)
ErrorCode = VWApiSrv.VW_AttachToWorkQueue(logonId, wpName, wqId)
ErrorCode = VWApiSrv.VW_ReportToWork(wqId, wpId)

ErrorCode = VWApiSrv.VW_BrmCreateBrowseModifier(wqId, brModHandle)


ErrorCode = VWApiSrv.VW_BrmSetSortRules(brModHandle, SortRules, SortRuleLengs)
ErrorCode = VWApiSrv.VW_BeginBrowsingWorkQueue(wpId, browseId, 0, browseCount,
➥brModHandle)
ErrorCode = VWApiSrv.VW_NextWorkObjectToBrowse(browseId, qeId)

40 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Example Work Performer Code

ErrorCode = VWApiSrv.VW_EndBrowsingWorkQueue(browseId)

ErrorCode = VWApiSrv.VW_LeaveWork(wpId)
ErrorCode = VWApiSrv.VW_DetachFromWorkQueue(wqId)
ErrorCode = VWApiSrv.VW_VW_Logoff(logonId)

End Sub

An Active Work Performer that Uses OLE


This figure shows the Workflow Instruction Sheet for the OLETest Work Class:

This figure shows the initial screen of the active Work Performer:

December 1996 Work Performer Developer’s Guide 41


Work Performers that Use OLE Automation
Example Work Performer Code

After you click the execute button once, the screen appears as follows:

If you click Execute again, screen appears as follows:

42 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Example Work Performer Code

When you click Execute a third time, the screen appears as follows:

The remainder of this section shows the active Work Performer code,
including the Execute_Click procedure that implements the three Operations.

Execute_Click Procedure
Private Sub Execute_Click()
Call check(anObject.VW_BeginBrowsingWorkQueue(reportId, browseId, 0, numObjects,
➥ browseModHandle), "VW_Logon")

Call check(anObject.VW_NextWorkObjectToBrowse(browseId, wobId),


➥"VW_NextWorkObjectToBrowse")

Call check(anObject.VW_LockWorkObject(wobId, lockId), "VW_LockWorkObject")

Call check(anObject.VW_GetOperationName(lockId, opName), "VW_GetOperationName")

theStatusLine.Caption = opName

theListBox.Clear

If (opName = "dataIn" Or opName = "dataInOut") Then

Call check(anObject.VW_GetInteger(lockId, "anInteger", anInteger), "VW_GetInteger")

December 1996 Work Performer Developer’s Guide 43


Work Performers that Use OLE Automation
Example Work Performer Code

theListBox.AddItem "anInteger: " & anInteger

Call check(anObject.VW_GetBoolean(lockId, "aBoolean", aBoolean), "VW_GetBoolean")


theListBox.AddItem "aBoolean: " & aBoolean

Call check(anObject.VW_GetFloat(lockId, "aFloat", aFloat), "VW_GetFloat")


theListBox.AddItem "aFloat: " & aFloat

Call check(anObject.VW_GetTime(lockId, "aTime", aTime), "VW_GetTime")


theListBox.AddItem "aTime: " & aTime

Call check(anObject.VW_GetString(lockId, "aString", aString), "VW_GetString")


theListBox.AddItem "aString: " & aString

Call check(anObject.VW_GetArray(lockId, "anIntegerArray", anIntegerArray, 0),


➥ "VW_GetArray")
For Index = 0 To UBound(anIntegerArray)
theListBox.AddItem "anIntegerArray[" & Index & "]: " & anIntegerArray(Index)
Next Index

Call check(anObject.VW_GetArray(lockId, "aBooleanArray", aBooleanArray, 3),


➥ "VW_GetArray")
For Index = 0 To UBound(aBooleanArray)
theListBox.AddItem "aBooleanArray[" & Index & "]: " & aBooleanArray(Index)
Next Index

Call check(anObject.VW_GetArray(lockId, "aFloatArray", aFloatArray, 1), "VW_GetArray")


For Index = 0 To UBound(aFloatArray)
theListBox.AddItem "aFloatArray[" & Index & "]: " & aFloatArray(Index)
Next Index

Call check(anObject.VW_GetArray(lockId, "aTimeArray", aTimeArray, 4), "VW_GetArray")


For Index = 0 To UBound(aTimeArray)
theListBox.AddItem "aTimeArray[" & Index & "]: " & aTimeArray(Index)

44 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Example Work Performer Code

Next Index

Call check(anObject.VW_GetArray(lockId, "aStringArray", aStringArray, 2), "VW_GetArray")


For Index = 0 To UBound(aStringArray)
theListBox.AddItem "aStringArray[" & Index & "]: " & aStringArray(Index)
Next Index

End If

If (opName = "dataInOut" Or opName = "dataOut") Then

anInteger = anInteger + 1
Call check(anObject.VW_SetInteger(lockId, "anInteger", anInteger), "VW_SetInteger")

aBoolean = aBoolean + 1
Call check(anObject.VW_SetBoolean(lockId, "aBoolean", aBoolean), "VW_SetBoolean")

aFloat = aFloat + 1
Call check(anObject.VW_SetFloat(lockId, "aFloat", aFloat), "VW_SetFloat")

aTime = aTime + 1
Call check(anObject.VW_SetTime(lockId, "aTime", aTime), "VW_SetTime")

aString = aString + "xxx"


Call check(anObject.VW_SetString(lockId, "aString", aString), "VW_SetString")

ReDim anIntegerArray(0)
anIntegerArray(0) = 9
Call check(anObject.VW_SetArray(lockId, "anIntegerArray", anIntegerArray, 0),
➥ "VW_SetArray")

ReDim aBooleanArray(0)
aBooleanArray(0) = 9
Call check(anObject.VW_SetArray(lockId, "aBooleanArray", aBooleanArray, 3),
➥ "VW_SetArray")

December 1996 Work Performer Developer’s Guide 45


Work Performers that Use OLE Automation
Example Work Performer Code

ReDim aFloatArray(0)
aFloatArray(0) = 9
Call check(anObject.VW_SetArray(lockId, "aFloatArray", aFloatArray, 1), "VW_SetArray")

ReDim aTimeArray(0)
aTimeArray(0) = 9
Call check(anObject.VW_SetArray(lockId, "aTimeArray", aTimeArray, 4), "VW_SetArray")

ReDim aStringArray(0)
aStringArray(0) = "xxx"
Call check(anObject.VW_SetArray(lockId, "aStringArray", aStringArray, 2), "VW_SetArray")

End If

Call check(anObject.VW_UnlockAndDispatch(lockId), "VW_UnlockAndDispatch")

Call check(anObject.VW_EndBrowsingWorkQueue(browseId), "VW_EndBrowsingWorkQueue")

End Sub

check Procedure
Private Sub check(ByVal errorCode As Long, ByVal message As String)
If (errorCode <> 0) Then
'Static errMsg As String * 255
Dim errMsg As String
Dim errorError As Long
errorError = anObject.VW_GetErrorMessage(errorCode, errMsg)
MsgBox message & ", " & Str$(errorCode) & ", " & errMsg
End If
End Sub

46 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Example Work Performer Code

Form_Load Procedure
Private Sub Form_Load()
Set anObject = CreateObject("VWApi.Srv")

Call check(anObject.VW_Logon(logonId), "VW_Logon")

Call check(anObject.VW_AttachToWorkQueue(logonId, "OLEWP", wqId),


➥ "VW_AttachToWorkQueue")

Call check(anObject.VW_ReportToWork(wqId, reportId), "VW_ReportToWork")

End Sub

Form_Unload Procedure
Private Sub Form_Unload( Cancel As Integer)

Call check(anObject.VW_LeaveWork(reportId), "VW_LeaveWork")

Call check(anObject.VW_DetachFromWorkQueue(wqId), "VW_DetachFromWorkQueue")

Call check(anObject.VW_Logoff(logonId), "VW_Logoff")

End Sub

December 1996 Work Performer Developer’s Guide 47


Work Performers that Use OLE Automation
Example Work Performer Code

A Passive Work Performer that Uses OLE


The following figure shows the Properties editor of the OLEWP Work
Performer class:

This figure shows the Workflow Instruction Sheet for the OLETest Work Class:

The remainder of this section shows the code for the three Operations.

48 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Example Work Performer Code

dataIn Function
Public Function dataIn(ByVal anInteger As Long,
➥ByVal aBoolean As Boolean,
➥ByVal aTime As Long,
➥ByVal aFloat As Double,
➥ByVal aString As String,
➥ByVal anIntegerArray As Variant,
➥ByVal aBooleanArray As Variant,
➥ByVal aTimeArray As Variant,
➥ByVal aFloatArray As Variant,
➥ByVal aStringArray As Variant) As Boolean

Form1.theListBox.Clear

Form1.theListBox.AddItem "anInteger: " & anInteger


Form1.theListBox.AddItem "aBoolean: " & aBoolean
Form1.theListBox.AddItem "aTime: " & aTime
Form1.theListBox.AddItem "aFloat: " & aFloat
Form1.theListBox.AddItem "aString: " & aString

For Index = 0 To UBound(anIntegerArray)


Form1.theListBox.AddItem "anIntegerArray[" & Index & "]: " & anIntegerArray(Index)
Next Index

For Index = 0 To UBound(aBooleanArray)


Form1.theListBox.AddItem "aBooleanArray[" & Index & "]: " & aBooleanArray(Index)
Next Index

For Index = 0 To UBound(aTimeArray)


Form1.theListBox.AddItem "aTimeArray[" & Index & "]: " & aTimeArray(Index)
Next Index

For Index = 0 To UBound(aFloatArray)


Form1.theListBox.AddItem "aFloatArray[" & Index & "]: " & aFloatArray(Index)

December 1996 Work Performer Developer’s Guide 49


Work Performers that Use OLE Automation
Example Work Performer Code

Next Index

For Index = 0 To UBound(aStringArray)


Form1.theListBox.AddItem "aStringArray[" & Index & "]: " & aStringArray(Index)
Next Index

dataIn = True

End Function

dataInOut Procedure
Public Sub dataInOut(ByRef anInteger As Long,
➥ByRef aBoolean As Boolean,
➥ByRef aTime As Long,
➥ByRef aFloat As Double,
➥ByRef aString As String,
➥ByRef anIntegerArray As Variant,
➥ByRef aBooleanArray As Variant,
➥ByRef aTimeArray As Variant,
➥ByRef aFloatArray As Variant,
➥ByRef aStringArray As Variant)

Form1.theListBox.Clear

Form1.theListBox.AddItem "anInteger: " & anInteger


anInteger = anInteger + 1

Form1.theListBox.AddItem "aBoolean: " & aBoolean


aBoolean = Not aBoolean

Form1.theListBox.AddItem "aTime: " & aTime


aTime = aTime + 1

Form1.theListBox.AddItem "aFloat: " & aFloat

50 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Example Work Performer Code

aFloat = aFloat + 1

Form1.theListBox.AddItem "aString: " & aString


aString = aString + "abc"

For Index = 0 To UBound(anIntegerArray)


Form1.theListBox.AddItem "anIntegerArray[" & Index & "]: " & anIntegerArray(Index)
anIntegerArray(Index) = anIntegerArray(Index) + 1
Next Index

For Index = 0 To UBound(aBooleanArray)


Form1.theListBox.AddItem "aBooleanArray[" & Index & "]: " & aBooleanArray(Index)
aBooleanArray(Index) = Not aBooleanArray(Index)
Next Index

For Index = 0 To UBound(aTimeArray)


Form1.theListBox.AddItem "aTimeArray[" & Index & "]: " & aTimeArray(Index)
aTimeArray(Index) = aTimeArray(Index) + 1
Next Index

For Index = 0 To UBound(aFloatArray)


Form1.theListBox.AddItem "aFloatArray[" & Index & "]: " & aFloatArray(Index)
aFloatArray(Index) = aFloatArray(Index) + 1
Next Index

For Index = 0 To UBound(aStringArray)


Form1.theListBox.AddItem "aStringArray[" & Index & "]: " & aStringArray(Index)
aStringArray(Index) = aStringArray(Index) + "abc"
Next Index

End Sub

December 1996 Work Performer Developer’s Guide 51


Work Performers that Use OLE Automation
Example Work Performer Code

dataOut Procedure
Public Sub dataOut(ByRef anInteger As Long,
➥ByRef aBoolean As Boolean,
➥ByRef aTime As Long,
➥ByRef aFloat As Double,
➥ByRef aString As String,
➥ByRef anIntegerArray As Variant,
➥ByRef aBooleanArray As Variant,
➥ByRef aTimeArray As Variant,
➥ByRef aFloatArray As Variant,
➥ByRef aStringArray As Variant)

anInteger = anInteger + 1

aBoolean = Not aBoolean

aTime = aTime + 1

aFloat = aFloat + 1

aString = aString + "abc"

ReDim anIntegerArray(1)
For Index = 0 To UBound(anIntegerArray)
anIntegerArray(Index) = 9
Next Index

ReDim aBooleanArray(1)
For Index = 0 To UBound(aBooleanArray)
aBooleanArray(Index) = True
Next Index

ReDim aTimeArray(1)
For Index = 0 To UBound(aTimeArray)

52 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Example Work Performer Code

aTimeArray(Index) = 9
Next Index

ReDim aFloatArray(1)
For Index = 0 To UBound(aFloatArray)
aFloatArray(Index) = 9
Next Index

ReDim aStringArray(1)
For Index = 0 To UBound(aStringArray)
aStringArray(Index) = "xyz"
Next Index

Form1.theListBox.Clear

End Sub

An Active Visual Basic Work Performer that Calls Microsoft Word


Dim logonId As Long
Dim wqId As Long
Dim reportId As Long
Dim browseId As Long
Dim wobId As Long
Dim numObjects As Long
Dim browseModHandle As Long
Dim lockId As Long
Dim opName As String

Dim WordObject As Object


Dim anObject As Object
Dim CustName As String
Dim CustAddress1 As String
Dim CustAddress2 As String
Dim CityStateZip As String

December 1996 Work Performer Developer’s Guide 53


Work Performers that Use OLE Automation
Example Work Performer Code

Dim LoanNum As String


Dim MonthlyPay As Double
Dim DenyReasonCode As Long

cmdGetNextLetter_Click Procedure
Private Sub cmdGetNextLetter_Click()
If lockId <> 0 Then
Call check(anObject.VW_UnlockAndDispatch(lockId), "VW_UnlockAndDispatch")
lockId = 0

Call check(anObject.VW_EndBrowsingWorkQueue(browseId),
➥"VW_EndBrowsingWorkQueue")

WordObject.FileClose 2
End If

Call check(anObject.VW_BeginBrowsingWorkQueue(reportId, browseId, 0, numObjects,


➥browseModHandle), "VW_Logon")

If numObjects > 0 Then


Call check(anObject.VW_NextWorkObjectToBrowse(browseId, wobId),
➥"VW_NextWorkObjectToBrowse")

Call check(anObject.VW_LockWorkObject(wobId, lockId), "VW_LockWorkObject")

Call check(anObject.VW_GetOperationName(lockId, opName), "VW_GetOperationName")


txtOperation.Text = opName
Call check(anObject.VW_GetString(lockId, "soprLoanCustName", CustName),
➥"VW_GetString")
Call check(anObject.VW_GetString(lockId, "soprAddr1", CustAddress1), "VW_GetString")
Call check(anObject.VW_GetString(lockId, "soprAddr2", CustAddress2), "VW_GetString")
Call check(anObject.VW_GetString(lockId, "soprCityStateZip", CityStateZip),
➥"VW_GetString")

54 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Example Work Performer Code

If txtOperation.Text = "Approval" Then


Call check(anObject.VW_GetString(lockId, "soprLoanNum", LoanNum), "VW_GetString")
Call check(anObject.VW_GetFloat(lockId, "foprMonthPayAmt", MonthlyPay),
➥"VW_GetFloat")
WordObject.FileOpen "c:\vw demos\loanapp\workperf\active\winword\apprvltr.doc"

WordObject.EditGoto "CustAddress1"
WordObject.Insert CustAddress1
WordObject.EditGoto "CustAddress2"
WordObject.Insert CustAddress2
WordObject.EditGoto "CityStateZip"
WordObject.Insert CityStateZip
WordObject.EditGoto "LoanNum"
WordObject.Insert LoanNum
WordObject.EditGoto "CustName"
WordObject.Insert CustName
WordObject.EditGoto "MonthlyPay"
WordObject.Insert Str(MonthlyPay)
Else 'txtOperation.Text = "Denial"
Call check(anObject.VW_GetInteger(lockId, "ioprDenyReasonCode", DenyReasonCode),
➥"VW_GetInteger")
WordObject.FileOpen "c:\vw demos\loanapp\workperf\active\winword\rejctltr.doc"

WordObject.EditGoto "CustAddress1"
WordObject.Insert CustAddress1
WordObject.EditGoto "CustAddress2"
WordObject.Insert CustAddress2
WordObject.EditGoto "CityStateZip"
WordObject.Insert CityStateZip
WordObject.EditGoto "CustName"
WordObject.Insert CustName
WordObject.EditGoto "ReasonCode"
WordObject.Insert Str(DenyReasonCode)

End If

December 1996 Work Performer Developer’s Guide 55


Work Performers that Use OLE Automation
Example Work Performer Code

Else
txtOperation.Text = "No letters waiting."
End If
End Sub

Form_Load Procedure
Private Sub Form_Load()
Set anObject = CreateObject("VWApi.Srv")
Call check(anObject.VW_Logon(logonId), "VW_Logon")
Call check(anObject.VW_AttachToWorkQueue(logonId, "Letters", wqId),
➥"VW_AttachToWorkQueue")
Call check(anObject.VW_ReportToWork(wqId, reportId), "VW_ReportToWork")

Set WordObject = CreateObject("Word.Basic")


WordObject.AppActivate "Microsoft Word"
End Sub

Form_Unload Procedure
Private Sub Form_Unload(Cancel As Integer)
If lockId <> 0 Then
Call check(anObject.VW_UnlockAndDispatch(lockId), "VW_UnlockAndDispatch")
lockId = 0
Call check(anObject.VW_EndBrowsingWorkQueue(browseId),
➥"VW_EndBrowsingWorkQueue")
WordObject.FileClose 2
End If

WordObject.AppClose "Microsoft Word"

Call check(anObject.VW_LeaveWork(reportId), "VW_LeaveWork")


Call check(anObject.VW_DetachFromWorkQueue(wqId), "VW_DetachFromWorkQueue")
Call check(anObject.VW_Logoff(logonId), "VW_Logoff")
End
End Sub

56 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Example Work Performer Code

check Procedure
Private Sub check(ByVal errorCode As Long, ByVal message As String)
If (errorCode <> 0) Then
'Static errMsg As String * 255
Dim errMsg As String
Dim errorError As Long
errorError = anObject.VW_GetErrorMessage(errorCode, errMsg)
MsgBox message & ", " & Str$(errorCode) & ", " & errMsg
End If
End Sub

An Example of VW_WobQueryCreate() and related APIs


In this example, the “Command27_Click Procedure” on page 65 calls
VW_WobQueryCreate(), VW_WobQueryExecute(), and VW_WobQuery-
Operation. The “Command11_Click Procedure” on page 59 calls VW_Wob-
QueryGetAccessHandle(). The “Command28_Click Procedure” on page 66
calls VW_WobQueryEnd() to terminate the query.

Dim apisrv As Object


Dim workerId As Long
Dim lockId As Long
Dim browseId As Long
Dim serviceComplete As Integer
Dim workObjectIndex As Integer
Dim workObjectIds(20) As Long
Dim theServiceName As String
Dim loginId As Long
Dim queueId As Long
Dim brModHandle As Long
Dim wobAccessHandle As Long
Dim queryCount As Long
Dim wobQueryHandle As Long
Dim lock_ForUpdate As Integer
Dim save_Updates As Integer
Dim skip_CurrentInstruction As Integer

December 1996 Work Performer Developer’s Guide 57


Work Performers that Use OLE Automation
Example Work Performer Code

check Procedure
Private Sub check(ByVal errorCode As Long, ByVal message As String)
If (errorCode <> 0) Then
Static errMsg As String
Dim errorError As Long
errorError = apisrv.VW_GetErrorMessage(errorCode, errMsg)
MsgBox message & ", " & Str$(errorCode) & ", " & errMsg
'Stop
End If
End Sub

BindToUser_Click Procedure
Private Sub BindToUser_Click()
Dim theUserName As String

theUserName = InputBox("User to bind to", "VBStr (active)")


Call check(apisrv.VW_BindToUser(wobAccessHandle, theUserName),
➥"VW_BindToUser WObjQuery")
End Sub

Command1_Click Procedure
Private Sub Command1_Click()
Command1.Enabled = False
brModHandle = 0
Dim success As Double

Call check(apisrv.VW_Logon(loginId), "VW_Logon")


Call check(apisrv.VW_AttachToWorkQueue(loginId, "VBStr", queueId), "VW_GetWorkQueue")
Call check(apisrv.VW_ReportToWork(queueId, workerId), "VW_ReportToWork")

Command2.Enabled = True
Command7.Enabled = True
Command27.Enabled = True
Command8.Enabled = False

58 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Example Work Performer Code

Command9.Enabled = False
End Sub

Command11_Click Procedure
Private Sub Command11_Click()
Dim success As Double
Dim anInteger As Long
Dim aFloat As Double
Dim theString As String
Dim aString As String
lock_ForUpdate = LockForUpdate.Value

If List1.ListIndex < 0 Then


MsgBox "You must first select a workObject."
Else
workObjectIndex = CLng(List1.ListIndex)
Call check(apisrv.VW_WobQueryGetAccessHandle(wobQueryHandle, workObjectIndex,
➥lock_ForUpdate, wobAccessHandle), "VW_WobQueryGetAccessHandle")
' Command8.Enabled = False
' Command11.Enabled = False
Command13.Enabled = True
Command14.Enabled = True
Command15.Enabled = True
Command16.Enabled = True
Command17.Enabled = True
Command18.Enabled = True
Command19.Enabled = True
Command20.Enabled = True
Command21.Enabled = True
Command22.Enabled = True
Command23.Enabled = True
Command24.Enabled = True
BindToUser.Enabled = True
UnbindUser.Enabled = True

December 1996 Work Performer Developer’s Guide 59


Work Performers that Use OLE Automation
Example Work Performer Code

End If
End Sub

Command13_Click Procedure
Private Sub Command13_Click()
Dim anInteger As Long
Dim aString As String
' Get an Integer Field
Call check(apisrv.VW_GetInteger(wobAccessHandle, "integerA", anInteger), "VW_GetInteger")
aString = Str$(anInteger)
MsgBox "The integer is: " & aString
End Sub

Command14_Click Procedure
Private Sub Command14_Click()
Dim OutputIntegerArray As Variant
' Get an Integer Array Field
ReDim OutputIntegerArray(2) As Long
OutputIntegerArray(0) = 0
OutputIntegerArray(1) = 0
OutputIntegerArray(2) = 0
Call check(apisrv.VW_GetArray(wobAccessHandle, "arrayA", OutputIntegerArray, 0),
➥"VW_GetArray")
Dim intArrayString As String
intArrayString = "{"
Dim i
For i = 0 To 2
intArrayString = intArrayString + Str$(OutputIntegerArray(i)) + " "
Next i
intArrayString = intArrayString + "}"
MsgBox "The integer array is : " & intArrayString
End Sub

60 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Example Work Performer Code

Command16_Click Procedure
Private Sub Command16_Click()
Dim aFloat As Double
Dim aString As String
' Get a Float Field
Call check(apisrv.VW_GetFloat(wobAccessHandle, "floatA", aFloat), "VW_GetFloat")
aString = Str$(aFloat)
MsgBox "The float is: " & aString
End Sub

Command17_Click Procedure
Private Sub Command17_Click()
Dim OutputStringArray As Variant
' Get a string array field
ReDim OutputStringArray(2) As String
OutputStringArray(0) = ""
OutputStringArray(1) = ""
OutputStringArray(2) = ""
Call check(apisrv.VW_GetArray(wobAccessHandle, "stringArray", OutputStringArray, 2),
➥"VW_GetArray")
Dim theArrayString As String
theArrayString = "{"
Dim j
For j = 0 To 2
theArrayString = theArrayString + OutputStringArray(j) + " "
Next j
theArrayString = theArrayString + "}"
MsgBox "The string array is : " & theArrayString
End Sub

December 1996 Work Performer Developer’s Guide 61


Work Performers that Use OLE Automation
Example Work Performer Code

Command18_Click Procedure
Private Sub Command18_Click()
Dim aString As String
' Get a String Field
Call check(apisrv.VW_GetString(wobAccessHandle, "stringA", aString), "VW_GetString")
MsgBox "The string is: " & aString
End Sub

Command19_Click Procedure
Private Sub Command19_Click()
Dim aString As String
Dim anInteger As Integer
Dim success As Double
' Change an integer field
aString = InputBox("Input integer", "VBStr (active)")
anInteger = Val(aString)
success = apisrv.VW_SetInteger(wobAccessHandle, "integerA", anInteger)
If success <> 0 Then
MsgBox "SetInteger failed: error code = " & Str$(success)
End If
End Sub

Command2_Click Procedure
Private Sub Command2_Click()
Dim success As Double
Dim browseCount As Long
Dim more As Double
Dim count As Integer
Dim serviceName As String
Dim strA As String, intA As Long

Call check(apisrv.VW_BeginBrowsingWorkQueue(workerId, browseId, 20, browseCount,


➥brModHandle), "VW_BeginBrowsingWorkQueue")
Command2.Enabled = False

62 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Example Work Performer Code

more = 0
count = 0
While (more = 0) And (count < 10) And (success = 0)
count = count + 1
more = apisrv.VW_NextWorkObjectToBrowse(browseId, workObjectIds(count))
If (more = 0) Then
Call check(apisrv.VW_GetOperationName(workObjectIds(count), serviceName),
➥"GetOperationName")
' Call check(VB_VW_GetString(workObjectIds(count), "stringA", strA),
➥"VB_VW_GetString")
' Call check(VW_GetInteger(workObjectIds(count), "integerA", intA), "VW_GetInteger")
List1.AddItem serviceName
End If
Wend
Command3.Enabled = True '
Command6.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Command11.Enabled = False
Command27.Enabled = False
Command28.Enabled = False
End Sub

Command20_Click Procedure
Private Sub Command20_Click()
Dim theString As String
Dim success As Double
' Change a string field
theString = InputBox("Input string", "VBStr (active)")
Call check(apisrv.VW_SetString(wobAccessHandle, "stringA", theString), "VW_SetString")
End Sub

December 1996 Work Performer Developer’s Guide 63


Work Performers that Use OLE Automation
Example Work Performer Code

Command21_Click Procedure
Private Sub Command21_Click()
Dim aString As String
Dim aFloat As Double
Dim success As Double
' Change a float field
aString = InputBox("Input float", "VBStr (active)")
aFloat = CDbl(aString)
Call check(apisrv.VW_SetFloat(wobAccessHandle, "floatA", aFloat), "VW_SetFloat")
End Sub

Command22_Click Procedure
Private Sub Command22_Click()
Dim InputIntegerArray As Variant
' Change an Integer array
ReDim InputIntegerArray(2) As Long
InputIntegerArray(0) = anInteger
InputIntegerArray(1) = anInteger + 1
InputIntegerArray(2) = anInteger + 12
Call check(apisrv.VW_SetArray(wobAccessHandle, "arrayA", InputIntegerArray, 0),
➥"VW_SetArray")
End Sub

Command23_Click Procedure
Private Sub Command23_Click()
Dim InputStringArray As Variant
' Change a string array
ReDim InputStringArray(2) As String
InputStringArray(0) = Str$(aFloat)
InputStringArray(1) = theString
InputStringArray(2) = Str$(anInteger)
Call check(apisrv.VW_SetArray(wobAccessHandle, "stringArray", InputStringArray, 2),
➥"VW_SetArray")
End Sub

64 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Example Work Performer Code

Command27_Click Procedure
Private Sub Command27_Click()
Dim success As Double
Dim browseCount As Long
Dim count As Long
Dim theOperationName As String * 20

Call check(apisrv.VW_WobQueryCreate(loginId, "SimpleStrings", wobQueryHandle),


➥"VW_WobQueryCreate")
Call check(apisrv.VW_SetString(wobQueryHandle, "", "*"), "VW_SetString")
Call check(apisrv.VW_WobQueryExecute(wobQueryHandle, 0, queryCount),
➥"VW_WobQueryExecute")
Command2.Enabled = False
success = 0
While (count < queryCount) And (success = 0)
success = apisrv.VW_WobQueryOperation(wobQueryHandle, count, theOperationName)
count = count + 1
List1.AddItem theOperationName
Wend
Command9.Enabled = True
Command11.Enabled = True
Command28.Enabled = True
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Command8.Enabled = False
End Sub

December 1996 Work Performer Developer’s Guide 65


Work Performers that Use OLE Automation
Example Work Performer Code

Command28_Click Procedure
Private Sub Command28_Click()
Dim success As Double
Call check(apisrv.VW_WobQueryEnd(wobQueryHandle), "VW_WobQueryEnd")
List1.Clear
Command2.Enabled = True
Command3.Enabled = False
Command6.Enabled = False
Command28.Enabled = False
Command11.Enabled = False
Command8.Enabled = False
'Command9.Enabled = False
End Sub

Command4_Click Procedure
Private Sub Command4_Click()
Dim success As Double

Dim InputIntegerArray As Variant


Dim InputStringArray As Variant
Dim InputFloatArray As Variant
Dim InputTimeArray As Variant

Dim OutputIntegerArray As Variant


Dim OutputStringArray As Variant
Dim OutputFloatArray As Variant
Dim OutputTimeArray As Variant

If theServiceName = "AddStrings" Then


Dim strX As String
Dim strY As String
Dim strSum As String

66 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Example Work Performer Code

success = apisrv.VW_GetString(lockId, "stringX", strX)


If success <> 0 Then
MsgBox "GetString failed : errorcode = " & Str$(success)
GoTo ExitError
End If
success = apisrv.VW_GetString(lockId, "stringY", strY)
If success <> 0 Then
MsgBox "GetString failed : errorcode = " & Str$(success)
GoTo ExitError
End If
strSum = strX & strY
success = apisrv.VW_SetString(lockId, "sum", strSum)
If success <> 0 Then
MsgBox "SetString failed : errorcode = " & Str$(success)
GoTo ExitError
End If

ElseIf theServiceName = "InputString" Then


Dim aString As String
aString = InputBox("Input string", "VBStr (active)")
success = apisrv.VW_SetString(lockId, "aString", aString)
If success <> 0 Then
MsgBox "SetString failed : errorcode = " & Str$(success)
GoTo ExitError
End If

ElseIf theServiceName = "OutputString" Then


Dim outputString As String
Dim arraySize As Long
' Call check(VW_GetArraySize(lockId, "aString", arraySize), "VW_GetArraySize")
success = apisrv.VW_GetString(lockId, "aString", outputString)
If success <> 0 Then
MsgBox "GetString failed : errorcode = " & Str$(success)
GoTo ExitError

December 1996 Work Performer Developer’s Guide 67


Work Performers that Use OLE Automation
Example Work Performer Code

Else
MsgBox "OutputString: " & outputString
End If

ElseIf theServiceName = "InputIntegerArray" Then


ReDim InputIntegerArray(2) As Long
InputIntegerArray(0) = 99
InputIntegerArray(1) = 98
InputIntegerArray(2) = 97
Call check(apisrv.VW_SetArray(lockId, "anIntegerArray", InputIntegerArray, 0),
➥"VW_SetArray")

ElseIf theServiceName = "OutputIntegerArray" Then


ReDim OutputIntegerArray(2) As Long
OutputIntegerArray(0) = 0
OutputIntegerArray(1) = 0
OutputIntegerArray(2) = 0
Call check(apisrv.VW_GetArray(lockId, "anIntegerArray", OutputIntegerArray, 0),
➥"VW_GetArray")
Dim intArrayString As String
intArrayString = "{"
Dim i
For i = 0 To 2
intArrayString = intArrayString + Str$(OutputIntegerArray(i)) + " "
Next i
intArrayString = intArrayString + "}"
MsgBox "The integer array is : " & intArrayString

ElseIf theServiceName = "InputTimeArray" Then


ReDim InputTimeArray(10) As Long
For i = 0 To 9
InputTimeArray(i) = VBDateToFNTime(Now)
Next i
Call check(apisrv.VW_SetArray(lockId, "aTimeArray", InputTimeArray, 4), "VW_SetArray")

68 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Example Work Performer Code

ElseIf theServiceName = "OutputTimeArray" Then


ReDim OutputTimeArray(10) As Long
Call check(apisrv.VW_GetArray(lockId, "aTimeArray", OutputTimeArray, 4), "VW_GetArray")
Dim timeArrayString As String
timeArrayString = "{"
For i = 0 To 9
timeArrayString = timeArrayString + Str$(FNTimeToVBDate(OutputTimeArray(i))) + " "
Next i
timeArrayString = timeArrayString + "}"
MsgBox "The time array is : " & timeArrayString

ElseIf theServiceName = "InputStringArray" Then


ReDim InputStringArray(2) As String
InputStringArray(0) = "peek"
InputStringArray(1) = "a"
InputStringArray(2) = "boo"
Call check(apisrv.VW_SetArray(lockId, "aStringArray", InputStringArray, 2), "VW_SetArray")

ElseIf theServiceName = "OutputStringArray" Then


ReDim OutputStringArray(2) As String
OutputStringArray(0) = "a"
OutputStringArray(1) = "b"
OutputStringArray(2) = "c"
Call check(apisrv.VW_GetArray(lockId, "aStringArray", OutputStringArray, 2), "VW_GetArray")
Dim strArrayString As String
strArrayString = "{"
Dim j
For j = 0 To 2
strArrayString = strArrayString + OutputStringArray(j) + " "
Next j
strArrayString = strArrayString + "}"
MsgBox "The string array is : " & strArrayString

December 1996 Work Performer Developer’s Guide 69


Work Performers that Use OLE Automation
Example Work Performer Code

ElseIf theServiceName = "InputFloatArray" Then


ReDim InputFloatArray(2) As Double
InputFloatArray(0) = 3.1
InputFloatArray(1) = 4.23
InputFloatArray(2) = 7382.483
Call check(apisrv.VW_SetArray(lockId, "aFloatArray", InputFloatArray, 1), "VW_SetArray")

ElseIf theServiceName = "OutputFloatArray" Then


ReDim OutputFloatArray(2) As Double
OutputFloatArray(0) = 0
OutputFloatArray(1) = 0
OutputFloatArray(2) = 0
Call check(apisrv.VW_GetArray(lockId, "aFloatArray", OutputFloatArray, 1), "VW_GetArray")
Dim floatArrayString As String
floatArrayString = "{"
Dim k
For k = 0 To 2
floatArrayString = floatArrayString + Str$(OutputFloatArray(k)) + " "
Next k
floatArrayString = floatArrayString + "}"
MsgBox "The float array is : " & floatArrayString

Else
MsgBox "Unsupported service"
End If
ExitError:
Command4.Enabled = False
End Sub

70 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Example Work Performer Code

Command5_Click Procedure
Private Sub Command5_Click()
Dim success As Double
Dim serviceComplete As Integer
serviceComplete = Check1.Value

If (serviceComplete <> 0) Then


success = apisrv.VW_UnlockAndDispatch(lockId)
Else
success = apisrv.VW_UnlockWorkObject(lockId)
End If
If success = 0 Then
Command3.Enabled = True
Command4.Enabled = False
Command5.Enabled = False
Command8.Enabled = True
Command9.Enabled = True
BindToUserL.Enabled = False
UnBindUserL.Enabled = False
If (serviceComplete <> 0) Then
Dim Index As Integer
Dim numLeft As Integer
numLeft = List1.ListCount
For Index = workObjectIndex To (numLeft - 1)
workObjectIds(Index) = workObjectIds(Index + 1)
Next Index
List1.RemoveItem (workObjectIndex - 1)
End If
Else
MsgBox "UnlockWorkObject failed: error code = " & Str$(success)
End If
End Sub

December 1996 Work Performer Developer’s Guide 71


Work Performers that Use OLE Automation
Example Work Performer Code

Command6_Click Procedure
Private Sub Command6_Click()
Dim success As Double
success = apisrv.VW_EndBrowsingWorkQueue(browseId)

If success = 0 Then
List1.Clear
Command2.Enabled = True
Command27.Enabled = True
Command3.Enabled = False
Command6.Enabled = False
Command8.Enabled = False
'Command9.Enabled = False
Else
MsgBox "EndBrowsingWorkQueue failed: error code = " & Str$(success)
End If
End Sub

Command7_Click Procedure
Private Sub Command7_Click()
Dim success As Double
success = apisrv.VW_LeaveWork(workerId)
If success = 0 Then
List1.Clear
Command1.Enabled = True
Command3.Enabled = False
Command2.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
Command27.Enabled = False

72 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Example Work Performer Code

Else
MsgBox "LeaveWork failed: error code = " & Str$(success)
End If
Call check(apisrv.VW_DetachFromWorkQueue(queueId), "VW_DetachFromWorkQueue")
Call check(apisrv.VW_Logoff(loginId), "VW_Logoff")
End Sub

Command8_Click Procedure
Private Sub Command8_Click()
lock_ForUpdate = LockForUpdate.Value
If List1.ListIndex < 0 Then
MsgBox "You must first select a workObject."
Else
workObjectIndex = CLng(List1.ListIndex + 1)
Call check(apisrv.VW_GetAccessHandle(workObjectIds(workObjectIndex), lock_ForUpdate,
➥wobAccessHandle), "VW_GetAccessHandle")
Command8.Enabled = False
Command11.Enabled = False
Command13.Enabled = True
Command14.Enabled = True
Command15.Enabled = True
Command16.Enabled = True
Command17.Enabled = True
Command18.Enabled = True
Command19.Enabled = True
Command20.Enabled = True
Command21.Enabled = True
Command22.Enabled = True
Command23.Enabled = True
Command24.Enabled = True
BindToUser.Enabled = True
UnbindUser.Enabled = True
End If
End Sub

December 1996 Work Performer Developer’s Guide 73


Work Performers that Use OLE Automation
Example Work Performer Code

Command9_Click Procedure
Private Sub Command9_Click()
save_Updates = SaveUpdates.Value
skip_CurrentInstruction = SkipCurrentInstruction.Value
Call check(apisrv.VW_FreeAccessHandle(wobAccessHandle, save_Updates,
➥skip_CurrentInstruction, "next instr"), "VW_GetAccessHandle")
Command8.Enabled = True
Command9.Enabled = True

Command13.Enabled = False
Command14.Enabled = False
Command15.Enabled = False
Command16.Enabled = False
Command17.Enabled = False
Command18.Enabled = False
Command19.Enabled = False
Command20.Enabled = False
Command21.Enabled = False
Command22.Enabled = False
Command23.Enabled = False
Command24.Enabled = False
BindToUser.Enabled = False
UnbindUser.Enabled = False
End Sub

Form_Load Procedure
Private Sub Form_Load()
Set apisrv = CreateObject("VWApi.Srv")
End Sub

74 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Example Work Performer Code

Form_Unload Procedure
Private Sub Form_Unload(Cancel As Integer)
Set apisrv = Nothing
End
End Sub

VBDateToFNTime Function
Private Function VBDateToFNTime(vbDate)
VBDateToFNTime = DateDiff("s", "1-Jan-70", vbDate)
End Function

GetBindings_Click Procedure
Private Sub GetBindings_Click()
End Sub

GetBindingsButton_Click Procedure
Private Sub GetBindingsButton_Click()
Dim theUserName As String
Dim theMachineId As String

Call check(apisrv.VW_GetBindings(wobAccessHandle, theUserName, theMachineId),


➥"VW_GetBindings")
MsgBox (theUserName)
MsgBox (theMachineId)
End Sub

GetBindingsButtonLocked_Click Procedure
Private Sub GetBindingsButtonLocked_Click()
Dim theUserName As String
Dim theMachineId As String

Call check(apisrv.VW_GetBindings(lockId, theUserName, theMachineId), "VW_GetBindings")


MsgBox (theUserName)

December 1996 Work Performer Developer’s Guide 75


Work Performers that Use OLE Automation
Example Work Performer Code

MsgBox (theMachineId)
End Sub

GetBindingsButtonLockedButton_Click Procedure
Private Sub GetBindingsButtonLockedButton_Click()
Dim theUserName As String
Dim theMachineId As String

Call check(apisrv.VW_GetBindings(lockId, theUserName, theMachineId), "VW_GetBindings")


MsgBox (theUserName)
MsgBox (theMachineId)
End Sub

GetBindingsNextWObjButton_Click Procedure
Private Sub GetBindingsNextWObjButton_Click()
Dim success As Double
Dim exName As String
Dim exDesc As String
Dim theUserName As String
Dim theMachineId As String

If List1.ListIndex < 0 Then


MsgBox "You must first select a workObject."
Else
workObjectIndex = CLng(List1.ListIndex + 1)
Call check(apisrv.VW_GetBindings(workObjectIds(workObjectIndex), theUserName,
➥theMachineId), "VW_GetBindings")
MsgBox (theUserName)
MsgBox (theMachineId)
End If
End Sub

76 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Example Work Performer Code

GetWobSignature_Click Procedure
Private Sub GetWobSignature_Click()
Dim wobSignature As String

wobSignature = "None"
Call check(apisrv.VW_GetWobSignature(wobAccessHandle, wobSignature),
➥"VW_GetWobSignature")
MsgBox (wobSignature)
End Sub

GetWobSignatureLockedButton_Click Procedure
Private Sub GetWobSignatureLockedButton_Click()
Dim wobSignature As String

wobSignature = "None"
Call check(apisrv.VW_GetWobSignature(lockId, wobSignature), "VW_GetWobSignature")
MsgBox (wobSignature)
End Sub

UnbindUser_Click Procedure
Private Sub UnbindUser_Click()
Call check(apisrv.VW_UnBind(wobAccessHandle), "VW_UnBind WObjQuery")
End Sub

UnBindUserL_Click Procedure
Private Sub UnBindUserL_Click()
Call check(apisrv.VW_UnBind(lockId), "VW_UnBind Locked WObj")
End Sub

December 1996 Work Performer Developer’s Guide 77


Work Performers that Use OLE Automation
Example Work Performer Code

WobSignatureButton_Click Procedure
Private Sub WobSignatureButton_Click()
Dim wobSignature As String

wobSignature = "None"
Call check(apisrv.VW_GetWobSignature(wobAccessHandle, wobSignature),
➥"VW_GetWobSignature")
MsgBox (wobSignature)
End Sub

WobSignatureLockedButton_Click Procedure
Private Sub WobSignatureLockedButton_Click()
Dim wobSignature As String

wobSignature = "None"
Call check(apisrv.VW_GetWobSignature(lockId, wobSignature), "VW_GetWobSignature")
MsgBox (wobSignature)
End Sub

GetWobSignatureNextWobjButton_Click Procedure
Private Sub GetWobSignatureNextWobjButton_Click()
Dim success As Double
Dim exName As String
Dim exDesc As String
Dim wobSignature As String
If List1.ListIndex < 0 Then
MsgBox "You must first select a workObject."
Else
workObjectIndex = CLng(List1.ListIndex + 1)
Call check(apisrv.VW_GetWobSignature(workObjectIds(workObjectIndex), wobSignature),
➥"VW_GetWobSignature")
MsgBox (wobSignature)
End If
End Sub

78 Work Performer Developer’s Guide December 1996


Work Performers that Use OLE Automation
Example Work Performer Code

WobSignatureNextWObjButton_Click Procedure
Private Sub WobSignatureNextWObjButton_Click()
Dim success As Double
Dim exName As String
Dim exDesc As String
Dim wobSignature As String

If List1.ListIndex < 0 Then


MsgBox "You must first select a workObject."
Else
workObjectIndex = CLng(List1.ListIndex + 1)
Call check(apisrv.VW_GetWobSignature(workObjectIds(workObjectIndex), wobSignature),
➥"VW_GetWobSignature")
MsgBox (wobSignature)
End If
End Sub

December 1996 Work Performer Developer’s Guide 79


Work Performers that Use OLE Automation
Example Work Performer Code

80 Work Performer Developer’s Guide December 1996


3
3DLL Work Performers

This chapter describes

• how to write Work Performers that use the DLL adaptor.

• the data conversion that occurs between ‘C’ data types and Visual
WorkFlo data types.

• how to convert a 16-bit Work Performer that uses DLLADAPT to a 32-bit


Work Performer that uses VWDLLADP.

• the API calls that can be used in a DLL Work Performer.

We assume you are familiar with the ‘C’ programming language. We also
assume you have a basic understanding of the Visual WorkFlo concepts
relating to Work Performers and their Operations.

Note SVCAPI.LIB files are provided for Microsoft C and Borland C compilers. If you
are using a different compiler, refer to the user guide for your compiler to
determine how to create a compatible .LIB file from the Borland DLLs.

Using the DLL Adaptor


This section contains the information you need to successfully create a DLL
that can be called by the DLL adaptor.

The cdecl calling convention is used. All functions called return no value (that
is, have “void” results). All callable functions must be exported and have
proper Windows pre- and post-ambles. All parameters are passed in the order
declared during authoring; the names of the parameters are not used in the
actual call, so can be anything that the author wishes. Your code should
include svcapi.h.

To author calls to a DLL, enter the adaptor name (in the Properties editor of
the Work Performer class browser in Visual WorkFlo/Composer) as
VWDLLADP.DLL.

December 1996 Work Performer Developer’s Guide 81


DLL Work Performers
Data Type Conversion

The script name (entered in the same editor) must be the name of the DLL
that contains the Operations to call. Each Operation name must exactly match
the name of the entry point of the DLL that is to be called.

Data Type Conversion


When a parameter is passed to a Work Performer via this adaptor, the
parameters are converted to ‘C’ data types using the following table:

Visual WorkFlo data type ‘C’ data type


integer long
float double
boolean BOOL (int or long)
string char *, points to null terminated string
time FN_time_typ (long)

Arrays of Visual WorkFlo data types are passed as contiguous, sequential


memory locations of the corresponding ‘C’ data type (packed to 4-byte
alignment). Note that the data for strings is in separate memory areas (not
directly in the array). The array itself is passed as a pointer to the data
followed by an unsigned that contains the number of elements.

When result parameters are returned from the Work Performer to this adaptor,
the parameters passed in are of the following types:

Visual WorkFlo data type ‘C’ data type


integer long *
float double *
boolean BOOL * (int or long *)
string char **
time FN_time_typ * (long *)

The Work Performer must store the result values via the passed in pointers.
Strings must have the data allocated via HeapAlloc using the default process
heap (obtained by a call to GetProcessHeap) and the pointer to the memory
area returned (the string must be null terminated).

82 Work Performer Developer’s Guide December 1996


DLL Work Performers
Converting 16-bit Work Performers to 32-bits

When an array is expected as a result, a “void *” followed by an “unsigned *


(long *)” is passed on the stack. The called routine must allocate the data via
HeapAlloc from the default process heap (and put the pointer in the void * and
the number of elements in the unsigned).

Arrays of the above data items are returned as contiguous, sequential


memory locations of the above input parameters (packed to 4-byte
alignment). Note that the data for strings is in separate memory areas (not
directly in the array).

Inout parameters are passed as result (out) parameters above, except that
the values are all filled in. It is legitimate for strings and arrays to be different
lengths upon return than those that are passed in.

The memory pointed to by all pointers and handles is deallocated by Visual


WorkFlo after the call returns. This means that the called routine should not
deallocate any items passed in (except for inout pointers for which the pointer
itself has been changed). It also means that the called routine should make a
copy of any parameters that it wishes to preserve beyond the length of the
call.

Also, if a passive Work Performer declares an input parameter of type integer


with the name F_OperationHandle, the Operation Id replaces the value
specified in the Instruction (therefore put a zero as the parameter in the
Instruction). This replaces F_ContextID from release 1.0. F_OperationHandle
can be in any position in the parameter list, and gives you access to the
Operation parameters.

To access Work Performer data fields, call VW_GetWorkPerformerHandle() to


retrieve a passive Work Performer handle. You’ll use this handle when making
calls to VW_Set<datatype>, VW_Get<datatype>, VW_GetLoggingState(),
VW_SetLoggingState(), and VW_LogMessage(). Other calls that accepted
F_ContextID in release 1.0 now accept F_OperationHandle.

Converting 16-bit Work Performers to 32-bits


Follow these steps to convert a 16-bit Work Performer that uses DLLADAPT
to a 32-bit Work Performer that uses VWDLLADP:

1 In Visual WorkFlo/Composer, change the adaptor name from DLLADAPT.DLL


to VWDLLADP.DLL.

2 Do all the normal things to convert your DLL to 32-bits; refer to the
documentation from your compiler vendor.

December 1996 Work Performer Developer’s Guide 83


DLL Work Performers
Using VWDLLADP.DLL with Borland 32-bit DLLs

3 Use the cdecl calling convention for all entry points called by the DLL adaptor
(instead of the “far pascal” calling convention).

4 Calls to GlobalAlloc, GlobalFree, and GlobalReAlloc must be replaced by calls


to HeapAlloc, HeapFree, and HeapReAlloc, respectively. For parameters
passed via the DLL adaptor, memory allocation is now done with the Windows
default process heap (obtained by a call to GetProcessHeap) instead of
global memory handles. All calls to GlobalLock and GlobalUnlock should be
removed.

5 Pointers are now used for strings and arrays instead of handles. Strings
should be passed as char * for input parameters and char ** for output
parameters. Arrays should be passed as pointers to the element type for input
parameters and pointers to pointers to the element type for output
parameters. For example, an array of integers would be passed as int * for
input and int ** for output and an array of strings would be passed as char **
for input and char *** for output.

6 All ints are now 4 bytes long which means that all ints and booleans are
passed as 4 bytes, as are the number of elements for arrays. Make sure that
your DLL code is not using shorts for int or boolean parameters.

Using VWDLLADP.DLL with Borland 32-bit DLLs


The Microsoft and Borland compilers do not create names for cdecl in the
same manner. The Microsoft compiler uses the name that you specified
exactly, while Borland prepends an underscore to the name. If you are using
the Borland compiler, you will have to use a .def file for exporting so that you
can make an alias for your exported name which does not start with an
underscore.

You will need to create a .def file and add it to the project (if using the IDE) or
add it to your link line (if using a makefile). See the documentation on the IDE
or tlink32 for more information.

The .def file must have an EXPORTS section with lines similar to the
following:

EXPORTS

MyFunction1=_MyFunction1

MyFunction2=_MyFunction2

84 Work Performer Developer’s Guide December 1996


DLL Work Performers
DLL Passive Work Performer Example

Note the the two sides of the equal sign are identical, except that the right-
hand side has an underscore. This is instead of using __export (or _export) in
the source files.

In addition, the .def file might need the following items in it before the
EXPORTS section:

LIBRARY <library name>

CODE PRELOAD MOVEABLE DISCARDABLE

DATA MOVABLE MULTIPLE

See the Borland documentation on module definition files for more


information on what is needed for these items.

DLL Passive Work Performer Example


This section shows example code for a passive 16-bit Work Performer written
in ‘C’ that uses the DLL adaptor.

This example shows the ShowPayment() and PaymentInfo() functions of a


simple loan demo. The PaymentInfo() function accepts loan information input
by the user. ShowPayment() calculates and displays the monthly payment.

December 1996 Work Performer Developer’s Guide 85


DLL Work Performers
DLL Passive Work Performer Example

void FAR PASCAL _export ShowPayment(double PrincipalAmt, long * LoanDuration,


double *InterestRate, double *MonthlyPayment,
double AdjustableRate, double FixedRate)
{
FARPROC lpProcPaymentInfo;
G_PrincipalAmt = PrincipalAmt;
G_FixedRate = FixedRate;
G_AdjustableRate = AdjustableRate;

lpProcPaymentInfo = MakeProcInstance(PaymentInfo, hInst);


DialogBox(hInst, "PaymentInfoDlg", NULL, lpProcPaymentInfo);

*InterestRate = G_Interest;
G_MonthlyPayment = (double)(((unsigned long)(G_MonthlyPayment *
100 + 0.50)) / 100.00);
*MonthlyPayment = G_MonthlyPayment;
*LoanDuration = G_LoanDuration;
FreeProcInstance(lpProcPaymentInfo);
}

BOOL FAR PASCAL _export PaymentInfo(hDlg, message, wParam, lParam)


HWND hDlg; /* window handle of the dialog box */
UINT message; /* type of message */
WPARAM wParam; /* message-specific information */
LPARAM lParam;
{
HWND hwndList;
LRESULT n;

switch (message) {
case WM_INITDIALOG: /* message: initialize dialog box */
{
sprintf(PrincipalAmtStr, "%.2f", G_PrincipalAmt);
SetWindowText(GetDlgItem(hDlg, IDD_PrincipalAmount),

86 Work Performer Developer’s Guide December 1996


DLL Work Performers
DLL Passive Work Performer Example

(LPSTR) PrincipalAmtStr);
SendMessage(GetDlgItem(hDlg, IDD_Duration30),
BM_SETCHECK, 1, 0L); // default to 30 year
G_LoanDuration = 30;
ShowPayments(hDlg, G_PrincipalAmt);
return (TRUE);
}
case WM_COMMAND: /* message: received a command */
{
if (wParam == IDD_PaymentGrid && HIWORD (lParam) == LBN_SELCHANGE) {
hwndList = GetDlgItem(hDlg, IDD_PaymentGrid);
n = SendMessage (hwndList, LB_GETCURSEL, 0, 0L) ;
if (SendDlgItemMessage(hDlg, IDD_Duration30, BM_GETCHECK, 0, 0))
G_LoanDuration = 30;
else
G_LoanDuration = 15;
if (G_LoanDuration == 30)
G_MonthlyPayment = MonthlyPayments30Array[n+1];
else
G_MonthlyPayment = MonthlyPayments15Array[n+1];
G_Interest = InterestRateArray[n+1];
return (TRUE);
}
else if (wParam == IDD_OKButton3) { /* "OK" box selected? */
hwndList = GetDlgItem(hDlg, IDD_PaymentGrid);
n = SendMessage (hwndList, LB_GETCURSEL, 0, 0L) ;
if (n == LB_ERR) {
MessageBox(hDlg, "Please select an item first", "Error", MB_OK);
SetFocus(hwndList);
return (FALSE);
}
EndDialog(hDlg, TRUE); /* Exits the dialog box */
return (TRUE);
}
else if (wParam == IDD_Duration15) {

December 1996 Work Performer Developer’s Guide 87


DLL Work Performers

SendMessage(GetDlgItem(hDlg, IDD_Duration15), BM_SETCHECK, 1, 0L);


SendMessage(GetDlgItem(hDlg, IDD_Duration30), BM_SETCHECK, 0, 0L);
return (TRUE);
}
else if (wParam == IDD_Duration30) {
SendMessage(GetDlgItem(hDlg, IDD_Duration30), BM_SETCHECK, 1, 0L);
SendMessage(GetDlgItem(hDlg, IDD_Duration15), BM_SETCHECK, 0, 0L);
return (TRUE);
}
else /* Lets Windows process it */
return (DefWindowProc(hDlg, message, wParam, lParam));
} /* case WM_COMMAND */
} /* switch */
return (FALSE); /* Didn't process a message */
}

C API Calls
On the pages that follow, you’ll find detailed descriptions of each call,
including its syntax, each of its parameters, and the return value. The calls are
organized alphabetically.

Note 16-bit active Work Performers use SVCAPI.DLL. 32-bit active Work
Performers use VWAPI.DLL. Do not use DLLs other than SVCAPI.DLL or
VWAPI.DLL; use of other DLLs may cause errors.

88 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_AttachToWorkQueue

VW_AttachToWorkQueue
This function establishes a Work Queue for an active Work Performer.
VW_AttachToWorkQueue() should be called once (for each queue being
browsed) when the Work Performer is started.

Returns a workQueueId that identifies a particular Work Queue. workQueueId


remains valid until VW_DetachFromWorkQueue() is called or the active Work
Performer closes down.

You must call VW_DetachFromWorkQueue() to release resources associated


with workQueueId.

You can only call VW_AttachToWorkQueue() from an active Work Performer.

Syntax:
VW_Error FAR PASCAL VW_AttachToWorkQueue
(VW_LogonHandle logonId,
VW_ClassNameType
lpszWorkPerformerClassName,
VW_QueueHandle *workQueueId);

Input Parameters:
VW_LogonHandle logonId
Logon Id returned from VW_Logon().

VW_ClassNameType lpszWorkPerformerClassName
Supplied by the programmer. Name of the Work Performer
class whose Work Queue is to be browsed.

Output Parameters:
VW_QueueHandle * workQueueId
Identifies a Work Queue in subsequent calls to
VW_ReportToWork().

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

December 1996 Work Performer Developer’s Guide 89


DLL Work Performers
VW_AttachToWorkQueue

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_AttachToWorkQueueProcType)
(VW_LogonHandle,
VW_ClassNameType,
VW_QueueHandle *);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

90 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_BeginBrowsingWorkQueue

VW_BeginBrowsingWorkQueue
This function establishes a browse session of the Work Queue associated
with workPerformerId. The returned browseId remains valid until a call to
VW_EndBrowsingWorkQueue() or VW_LeaveWork().

If browseModHandle is set to zero, default rules for the Work Queue are in
effect, otherwise the modified rules contained in the browse modifier object
associated with browseModHandle are used. For more information, see
“VW_BrmCreateBrowseModifier” on page 94.

Note This call takes a snapshot of the queue contents; any subsequent changes to
the queue are not reflected in results from associated
VW_BeginBrowsingWorkQueue() calls.

When you finish browsing the Work Queue, you must call VW_End-
BrowsingWorkQueue() to free the resources associated with browseId.

You can only call VW_BeginBrowsingWorkQueue() from an active Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_BeginBrowsingWorkQueue
(VW_ActiveWPHandle workPerformerId,
VW_BrowseHandle * browseId,
unsigned long maxWorkObjectCount,
unsigned long * workObjectCount,
VW_BrModHandle browseModHandle);

Input Parameters:
VW_ActiveWPHandle workPerformerId
Identifies the calling Work Performer. Obtained by a call to
VW_ReportToWork().

unsigned long maxWorkObjectCount


Supplied by the programmer. Maximum number of Work
Objects to browse. Use zero for no limit. Judicious use of this
parameter can prevent overrun of system resources.

VW_BrModHandle browseModHandle
Handle to a browse modifier. Obtained by a call to VW_Brm-
CreateBrowseModifier().

December 1996 Work Performer Developer’s Guide 91


DLL Work Performers
VW_BeginBrowsingWorkQueue

Output Parameters:
VW_BrowseHandle * browseId
Identifies the browse session. Used in subsequent calls to
VW_NextWorkObjectToBrowse() and VW_EndBrowsing-
WorkQueue().

unsigned long *workObjectCount


Specifies the number of Work Objects actually available in
this browse session. This value is always less than or equal
to maxWorkObjectCount.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_BeginBrowsingWorkQueueProcType)
(VW_ActiveWPHandle,
VW_BrowseHandle *,
unsigned long,
unsigned long *,
VW_BrModHandle);

92 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_BindToUser

VW_BindToUser
This function restricts processing of the Work Object to the user specified by
the lpszUserName parameter.

You can only call VW_BindToUser() from an active Work Performer.

Syntax:
VW_Error FAR PASCAL VW_BindToUser(VW_Handle wobHandle,
VW_UserNameType lpszUserName);

Input Parameters:
VW_Handle wobHandle
Identifies a Work Object. Can be an operationId returned
from VW_LockWorkObject() or a locked wobAccessHandle
returned from VW_WobQueryGetAccessHandle() or
VW_GetAccessHandle().

VW_UserNameType * lpszUserName
Specifies the three-part NCH user name to which the Work
Object processing is to be restricted.

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_BindToUserProcType)
(VW_Handle,
VW_UserNameType);

December 1996 Work Performer Developer’s Guide 93


DLL Work Performers
VW_BrmCreateBrowseModifier

VW_BrmCreateBrowseModifier
This function creates a browse modifier object. Browse modifier objects are
independent of Work Performers and browse sessions, and can override the
default behavior of a Work Queue’s rules.

After you call VW_BrmCreateBrowseModifier(), call VW_BrmSetPreSelect-


Rule(), VW_BrmSetSelectRule(), or VW_BrmSetSortRules() to specify
overriding behavior. Call VW_BeginBrowsingWorkQueue() to apply the
modified rules.

You must call VW_BrmFreeBrowseModifier() to free the resources allocated


by this function. You can call VW_BrmFreeBrowseModifier() at any time after
calling VW_BeginBrowsingWorkQueue().

You can only call VW_BrmCreateBrowseModifier() from an active Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_BrmCreateBrowseModifier(
VW_QueueHandle workQueueId,
VW_BrModHandle * browseModHandle);

Input Parameters:
VW_QueueHandle workQueueId
Identifies a Work Queue. Obtained by a call to
VW_AttachToWorkQueue().

Output Parameters:
VW_BrModHandle * browseModHandle
Used in subsequent calls to VW_BrmSetPreSelectRule(),
VW_BrmSetSelectRule(), VW_BrmSetSortRules(), and
VW_BrmFreeBrowseModifier().

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

94 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_BrmCreateBrowseModifier

Function Typedef:
typedef VW_Error(FAR PASCAL *VW_BrmCreateBrowseModifierProcType)
(VW_QueueHandle,
VW_BrModHandle *);

December 1996 Work Performer Developer’s Guide 95


DLL Work Performers
VW_BrmFreeBrowseModifier

VW_BrmFreeBrowseModifier
This function frees the resources that were allocated by VW_BrmCreate-
BrowseModifier() for the browse modifier object identified by browseMod-
Handle. This function invalidates browseModHandle and has no effect on
previously started browse sessions using the same modifier object.

You can only call VW_BrmFreeBrowseModifier() from an active Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_BrmFreeBrowseModifier
(VW_BrModHandle browseModHandle);

Input Parameters:
VW_BrModHandle browseModHandle
Handle to a browse modifier object. Obtained by a call to
VW_BrmCreateBrowseModifier().

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error(FAR PASCAL *VW_BrmFreeBrowseModifierProcType)
(VW_BrModHandle browseModHandle);

96 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_BrmSetPreSelectRule

VW_BrmSetPreSelectRule
This function allows you to specify a pre-select rule in the browse modifier
object identified by browseModHandle. You can make this call repeatedly to
overwrite the effect of previous calls. To override the default pre-select rule,
you must call this function against a specific browse modifier object.

For more information about the pre-select rule and allowable expressions, see
the “Specify Work Queue Rules” section in the “Creating and Modifying Work
Performer Classes” chapter of the Visual WorkFlo/Composer Handbook.

You can only call VW_BrmSetPreSelectRule() from an active Work Performer.

Syntax:
VW_Error FAR PASCAL VW_BrmSetPreSelectRule
(VW_BrModHandle browseModHandle,
char * preSelectRuleExpr);

Input Parameters:
VW_BrModHandle browseModHandle
Handle to a browse modifier object. Obtained by a call to
VW_BrmCreateBrowseModifier().

char * preSelectRuleExpr
Supplied by the programmer. The pre-select rule expression
to override the default pre-select rule. If this parameter is an
empty string, it indicates that any authored pre-selection rule
is to be ignored.

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error(FAR PASCAL *VW_BrmSetPreSelectRuleProcType)
(VW_BrModHandle,
char *);

December 1996 Work Performer Developer’s Guide 97


DLL Work Performers
VW_BrmSetPreSelectRule

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

98 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_BrmSetSelectRule

VW_BrmSetSelectRule
This function allows you to specify a select rule in the browse modifier object
identified by browseModHandle. You can make this call repeatedly to
overwrite the effect of previous calls. To override the default select rule, you
must call this function against a specific browse modifier object.

For more information about the select rule and allowable expressions, see the
“Specify Work Queue Rules” section in the “Creating and Modifying Work
Performer Classes” chapter of the Visual WorkFlo/Composer Handbook.

You can only call VW_BrmSetSelectRule() from an active Work Performer.

Syntax:
VW_Error FAR PASCAL VW_BrmSetSelectRule
(VW_BrModHandle browseModHandle,
char * selectRuleExpr);

Input Parameters:
VW_BrModHandle browseModHandle
Handle to a browse modifier object. Obtained by a call to
VW_BrmCreateBrowseModifier().

char * selectRuleExpr
Supplied by the programmer. The select rule expression to
override the default select rule. If this parameter is an empty
string, it indicates that any authored selection rule is to be
ignored.

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error(FAR PASCAL *VW_BrmSetSelectRuleProcType)
(VW_BrModHandle,
char *);

December 1996 Work Performer Developer’s Guide 99


DLL Work Performers
VW_BrmSetSelectRule

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

100 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_BrmSetSortRules

VW_BrmSetSortRules
This function allows you to specify a set of sort rules in the browse modifier
object identified by browseModHandle. You can make this call repeatedly to
overwrite the effect of previous calls. To override the default sort rules, you
must call this function against a specific browse modifier object.

For more information about sort rules and allowable expressions, see the
“Specify Work Queue Rules” section in the “Creating and Modifying Work
Performer Classes” chapter of the Visual WorkFlo/Composer Handbook.

Note In 32-bit Work Performers, the SortRuleExpressions and SortRuleLengths


parameters should be declared as Variants. See “VW_BrmSetSortRules()
Example” on page 40 for example code showing the use of
VW_BrmSetSortRules().

You can only call VW_BrmSetSortRules() from an active Work Performer.

Syntax:
VW_Error FAR PASCAL VW_BrmSetSortRules
(VW_BrModHandle browseModHandle,
unsigned int sortRuleCount,
char * sortRuleExpressions[],
unsigned int sortRuleLengths[]);

Input Parameters:
VW_BrModHandle browseModHandle
Handle to a browse modifier object. Obtained by a call to
VW_BrmCreateBrowseModifier().

unsigned int sortRuleCount


Supplied by the programmer. The number of sort rules being
specified.

char * sortRuleExpressions[]
Supplied by the programmer. Array of sort rule expressions. If
the array is empty, it indicates that any authored sort rules are
to be ignored.

unsigned int sortRuleLengths[]


Supplied by the programmer. Array of sort rule lengths.
sortRuleLengths[] must contain one entry for each entry in
sortRuleExpressions[].

December 1996 Work Performer Developer’s Guide 101


DLL Work Performers
VW_BrmSetSortRules

Note that the lengths refer to sort key lengths, not


sortRuleExpressions[] lengths.

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise returns an error code.

Function Typedef:
typedef VW_Error(FAR PASCAL *VW_BrmSetSortRulesProcType)
(VW_BrModHandle,
unsigned int,
char * [],
unsigned int []);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

102 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_CheckVersionCompatibility

VW_CheckVersionCompatibility
This function checks that the version of the APIs being used is compatible
with the currently running version of the APIs. This function returns the current
major and minor version numbers in curMajorVersionNum and curMinor-
VersionNum respectively.

If majorVersionNum is not the same as the current major version number or


minorVersionNum is greater than the current minor version number, the
versions are incompatible.

Note For comparisons of minor version numbers to work correctly, the minor
version number returned in curMinorVersionNum is a two-digit number. For
example, the minor version number for release 1.21 is 21 and for release 1.3,
it is 30. The value supplied by the programmer in minorVersionNum must be
in the same format.

You can call VW_CheckVersionCompatibility() from either an active or passive


Work Performer.

Syntax:
VW_Error FAR PASCAL VW_CheckVersionCompatibility
(VW_MajorVersionType majorVersionNum,
VW_MinorVersionType minorVersionNum,
VW_MajorVersionType *curMajorVersionNum,
VW_MinorVersionType *curMinorVersionNum);

Input Parameters:
VW_MajorVersionType majorVersionNum
Supplied by the programmer.The major version number in
use by the caller.

VW_MinorVersionType minorVersionNum
Supplied by the programmer. The minor version number in
use by the caller.

Output Parameters:
VW_MajorVersionType *curMajorVersionNum
The current major version number of the API that is running.
It is the caller’s responsibility to allocate sufficient memory at
this location.

December 1996 Work Performer Developer’s Guide 103


DLL Work Performers
VW_CheckVersionCompatibility

VW_MinorVersionType *curMinorVersionNum
The current minor version number of the API that is running.
It is the caller’s responsibility to allocate sufficient memory at
this location.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_CheckVersionCompatibilityProcType
(VW_MajorVersionType,
VW_MinorVersionType,
VW_MajorVersionType *,
VW_MinorVersionType *);

104 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_CreateWorkObject

VW_CreateWorkObject
This function creates a Work Object of the Work Class specified by
lpszWorkClassName using the initial field values set during Work Class
definition. Returns the Id for the newly created Work Object.

Call VW_DispatchWorkObject() to dispatch the new Work Object to the


WorkObjectDispatcher Work Queue.

You must call VW_Logon() to get the logon id (logonId) used in this function.
Note that it’s more efficient to call VW_Logon once, save the returned logonId
and use it in subsequent calls to VW_CreateWorkObject().

When you have made all necessary calls to VW_CreateWorkObject() and


VW_DispatchWorkObject(), you must call VW_Logoff() to release resources
associated with logonId.

You can only call VW_CreateWorkObject() from an active Work Performer or


an administration program that creates Work Objects.

Syntax:
VW_Error FAR PASCAL VW_CreateWorkObject(VW_LogonHandle logonId,
VW_ClassNameType lpszWorkClassName,
VW_NewWorkObjectHandle
*newWorkObjectId);

Input Parameters:
VW_LogonHandle logonId
The logon Id returned by VW_Logon().

VW_ClassNameType lpszWorkClassName
Supplied by the programmer. The Work Class of the Work
Object to be created.

Output Parameters:
VW_NewWorkObjectHandle *newWorkObjectId
The Id of the newly created Work Object.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

December 1996 Work Performer Developer’s Guide 105


DLL Work Performers
VW_CreateWorkObject

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_CreateWorkObjectProcType)
(VW_LogonHandle,
VW_ClassNameType,
VW_NewWorkObjectHandle *);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

106 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_CurrentException

VW_CurrentException
This function returns a structure containing the name of the most recently
raised exception and a text description of the exception condition.

Space for the VW_ExceptionDescriptor structure must be allocated by the


caller.

You can call VW_CurrentException() from either an active or passive Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_CurrentException(VW_Handle objectId,
VW_ExceptionDescriptor * exDesc);

Input Parameters:
VW_Handle objectId
The operationId of a passive or active Work Performer. The
operation Id is returned by VW_LockWorkObject() (active
Work Performer) or is obtained from the adaptor (passive
Work Performer).

Output Parameters:
VW_ExceptionDescriptor * exDesc
Contains the name and description of a Work Object’s current
exception. Structure must be allocated by the caller.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_CurrentExceptionProcType)
(VW_Handle,
VW_ExceptionDescriptor *);

December 1996 Work Performer Developer’s Guide 107


DLL Work Performers
VW_CurrentException

Structure Definition:
#define VW_MAXEXCEPTIONNAMELEN];
#define VW_MAXEXCEPTIONDESCLEN];
typedef struct
{
char Name[VW_MAXEXCEPTIONNAMELEN];
char Desc[VW_MAXEXCEPTIONDESCLEN];
} VW_ExceptionDescriptor;

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

108 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_DetachFromWorkQueue

VW_DetachFromWorkQueue
This function frees any resources allocated to the workQueueId returned from
VW_AttachToWorkQueue(). workQueueId is invalid after this call. Call
VW_DetachFromWorkQueue() once (for each queue being browsed) before
the Work Performer is shut down.

You can only call VW_DetachFromWorkQueue() from an active Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_DetachFromWorkQueue
(VW_QueueHandle workQueueId);

Input Parameters:
VW_QueueHandle workQueueId
Identifies the Work Queue. Returned by
VW_AttachToWorkQueue().

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_DetachFromWorkQueueProcType)
(VW_QueueHandle);

December 1996 Work Performer Developer’s Guide 109


DLL Work Performers
VW_DispatchWorkObject

VW_DispatchWorkObject
This function dispatches the Work Object identified by newWorkObjectId into
the WorkObjectDispatcher Work Queue.

Always call this function after calling VW_CreateWorkObject().

You can only call VW_DispatchWorkObject() from an active Work Performer


or an administration program that creates Work Objects.

Syntax:
VW_Error FAR PASCAL VW_DispatchWorkObject
(VW_NewWorkObjectHandle newWorkObjectId);

Input Parameters:
VW_NewWorkObjectHandle newWorkObjectId
The Work Object Id returned from VW_CreateWorkObject().

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_DispatchWorkObjectProcType)
(VW_NewWorkObjectHandle);

110 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_EndBrowsingWorkQueue

VW_EndBrowsingWorkQueue
This function releases and invalidates all resources allocated to browseId or
any Work Object Ids associated with it.

Call this function to release resources allocated to browseId by VW_Begin-


BrowsingWorkQueue(). This function does not release or invalidate any
operation Ids obtained via the browse session associated with browseId.

You can only call VW_EndBrowsingWorkQueue() from an active Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_EndBrowsingWorkQueue
(VW_BrowseHandle browseId);

Input Parameters:
VW_BrowseHandle browseId
Id of a browse session obtained by a call to VW_Begin-
BrowsingWorkQueue(). browseId is invalid after a call to this
function.

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL * VW_EndBrowsingWorkQueueProcType)
(VW_BrowseHandle);

December 1996 Work Performer Developer’s Guide 111


DLL Work Performers
VW_FreeAccessHandle

VW_FreeAccessHandle
This function frees the access handle returned from VW_WobQueryGet-
AccessHandle() or VW_GetAccessHandle(). If lockForUpdate was set to true
when the access handle was obtained, VW_FreeAccessHandle() unlocks the
Work Object in the Work Queue.

You can only call VW_FreeAccessHandle() from an active Work Performer or


an administration program that locates Work Objects.

Syntax:
VW_Error FAR PASCAL VW_FreeAccessHandle
(VW_WobAccessHandle wobAccessHandle,
VW_Boolean saveUpdates,
VW_Boolean skipCurrentInstruction,
VW_InstrSheetNameType Reserved);

Input Parameters:
VW_WobAccessHandle wobAccessHandle
An access handle obtained by a call to VW_WobQueryGet-
AccessHandle() or VW_GetAccessHandle().

VW_Boolean saveUpdates
Supplied by the programmer. Has no effect if lockForUpdate
was not true when the access handle was obtained. If true, all
updates to the Work Object are saved; otherwise, updates
are discarded.

VW_Boolean skipCurrentInstruction
Supplied by the programmer. Has no effect if lockForUpdate
was not true when the access handle was obtained. If true,
the current Instruction of the Work Object is set to ‘completed’
and the Work Object is routed to the next Instruction.

VW_InstrSheetNameType Reserved
For future use.

Output Parameters:
None.

112 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_FreeAccessHandle

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_FreeAccessHandleProcType)
(VW_WobAccessHandle,
VW_Boolean,
VW_Boolean);

December 1996 Work Performer Developer’s Guide 113


DLL Work Performers
VW_FreeArrayPtr

VW_FreeArrayPtr
This function frees the array pointed to by arrayPtr, which is an array pointer
returned by VW_GetArrayPtr() or VW_GetFieldNames(). If arrayPtr is of type
string, this function frees all string elements in the array.

You can call VW_FreeArrayPtr() from either an active or passive Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_FreeArrayPtr(VW_ArrayPtrType *arrayPtr,
long numElements,
VW_DataType arrayType);

Input Parameters:
VW_ArrayPtrType *arrayPtr
Pointer to the array to be freed. Obtained by a call to
VW_GetArrayPtr() or VW_GetFieldNames().

long numElements
Number of elements in the array. Obtained by a call to
VW_GetArrayPtr() or VW_GetFieldNames().

VW_DataType arrayType
Supplied by the programmer. Identifies the data type of the
array.

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_FreeArrayPtrProcType)
(VW_ArrayPtrType *,
long,
VW_DataType);

114 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_GetAccessHandle

VW_GetAccessHandle
This function returns an access handle for a Work Object that is used in
subsequent calls to the data access functions (such as VW_GetInteger() or
VW_SetFloat()). The access handle can be used to make changes to the
Work Object.

If lockForUpdate is true, subsequent attempts to obtain an access handle for


the same Work Object with the lockForUpdate parameter set to true will fail
until the access handle is freed.

VW_GetAccessHandle() will return a security error if the logged on user does


not have appropriate access rights. If lockForUpdate is true, the user must
have read and write access; otherwise, the user must have read access.

Note After locking a Work Object with VW_GetAccessHandle(), you might want to
verify that it still fits the search criteria you specified when locating the Work
Object. The Work Object could have been changed between the time you
located it and the time you locked it.

You must call VW_FreeAccessHandle() when you finish with the access
handle.

You can only call VW_GetAccessHandle() from an active Work Performer.

Syntax:
VW_Error FAR PASCAL VW_GetAccessHandle
(VW_QueueElementHandle queueElementId,
VW_Boolean lockForUpdate,
VW_WobAccessHandle *wobAccessHandle);

Input Parameters:
VW_QueueElementHandle queueElementId
Identifies a Work Object in the Work Queue. Obtained by a
call to VW_NextWorkObjectToBrowse().

VW_Boolean lockForUpdate
Supplied by the programmer. If true, the Work Object is
locked in the Work Queue. If the Work Object is not locked,
the returned handle can only be used to read fields from the
Work Object.

December 1996 Work Performer Developer’s Guide 115


DLL Work Performers
VW_GetAccessHandle

Output Parameters:
VW_WobAccessHandle *wobAccessHandle
Returned access handle.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_GetAccessHandleProcType)
(VW_QueueElementHandle,
VW_Boolean,
VW_WobAccessHandle *);

116 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_GetArrayPtr

VW_GetArrayPtr
If objectId is the handle of a passive or active Work Performer, this function
returns the value of the Work Performer field identified by lpszFieldName.

If objectId is a Work Object Id returned from VW_NextWorkObjectToBrowse(),


this function returns the value of the Work Queue field identified by
lpszFieldName.

If objectId is an Operation Id, this function returns the value of an Operation


parameter in the Work Object’s current Operation.

If objectId is an access handle returned from VW_GetAccessHandle() or


VW_WobQueryGetAccesshandle(), this function returns the value of the Work
Object field identified by lpszFieldName.

It is not the caller’s responsibility to allocate memory for the array. This
function allocates the necessary memory and returns the array pointer to the
caller. If the returned array is of type string, then the array elements are of
type VW_String.

You must call VW_FreeArrayPtr() to free the returned array.

You can call VW_GetArrayPtr() from either an active or passive Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_GetArrayPtr (VW_Handle objectId,
VW_FieldNameType lpszFieldName,
VW_ArrayPtrType *value,
long *numElements,
VW_DataType type);

Input Parameters:
VW_Handle objectId
Identifies one of the following:
i) A passive or active Work Performer handle. Obtained by a
call to VW_GetWorkPerformerHandle() (passive Work
Performer) or VW_ReportToWork() (active Work Performer).
ii) An enqueued Work Object. Obtained by a call to
VW_NextWorkObjectToBrowse().
iii) The operation Id of a passive or active Work Performer.
Obtained from the adaptor (passive Work Performer) or a call

December 1996 Work Performer Developer’s Guide 117


DLL Work Performers
VW_GetArrayPtr

to VW_LockWorkObject() (active Work Performer).


iv) An access handle obtained by a call to
VW_GetAccessHandle() or
VW_WobQueryGetAccessHandle().

VW_FieldNameType lpszFieldName
Supplied by the programmer. Identifies one of the following:
i) A passive or active Work Performer field name.
ii) A Work Queue field name.
iii) An Operation parameter name.
iv) A Work Object field name.

VW_DataType type
The data type to be returned by VW_GetArrayPtr().

Output Parameters:
VW_ArrayPtrType *value
This value can represent one of the following:
i) A passive or active Work Performer field value.
ii) A Work Queue field value.
iii) An Operation parameter value.
iv) A Work Object field value.

long *numElements
The number of elements in the array.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_GetArrayPtrProcType)
(VW_Handle,
VW_FieldNameType,
VW_ArrayPtrType *,
long *,
VW_DataType);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

118 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_GetArraySize

VW_GetArraySize
Call this function when you need to obtain the size of an array before calling
VW_GetArrayPtr(). In most cases, there is no need to call VW_GetArraySize()
because VW_GetArrayPtr() allocates memory and returns the array size. Use
this call when you need the size of an array before calling a DLL, such as
VBSVCAPI, that uses the data received from VW_GetArrayPtr().

Returns the number of elements in the specified array.

If objectId is the handle of a passive or active Work Performer, this function


returns the number of elements in the Work Performer field identified by
lpszFieldName.

If objectId is a Work Object Id returned from VW_NextWorkObjectToBrowse(),


this function returns the number of elements in the Work Queue field identified
by lpszFieldName.

If objectId is an operationId, this function returns the number of elements in an


Operation parameter in the Work Object’s current Operation.

If objectId is an access handle returned from VW_GetAccessHandle() or


VW_WobQueryGetAccesshandle(), this function returns the value of the Work
Object field identified by lpszFieldName.

You can call VW_GetArraySize() from either an active or passive Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_GetArraySize(VW_Handle objectId,
VW_FieldNameType lpszFieldName,
long *elements);

Input Parameters:
VW_Handle objectId
Identifies one of the following:
i) A passive or active Work Performer handle. Obtained by a
call to VW_GetWorkPerformerHandle() (passive Work
Performer) or VW_ReportToWork() (active Work Performer).
ii) An enqueued Work Object. Obtained by a call to
VW_NextWorkObjectToBrowse().
iii) An operationId of a passive or active Work Performer.
Obtained from the adaptor (passive Work Performer) or a call

December 1996 Work Performer Developer’s Guide 119


DLL Work Performers
VW_GetArraySize

to VW_LockWorkObject() (active Work Performer).


iv) An access handle obtained by a call to
VW_GetAccessHandle() or
VW_WobQueryGetAccessHandle().

VW_FieldNameType lpszFieldName
Supplied by the programmer. Identifies one of the following:
i) A passive or active Work Performer field name.
ii) A Work Queue field name.
iii) An Operation parameter name.
iv) A Work Object field name.

Output Parameters:
long *elements
Returns the number of elements in the array.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_GetArraySizeProcType)
(VW_Handle,
VW_FieldNameType,
long *);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

120 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_GetBoolean

VW_GetBoolean
This function returns a parameter value containing data of type boolean from
a field determined by the objectId parameter.

If objectId is the handle of a passive or active Work Performer, this function


returns the value of the Work Performer field identified by lpszFieldName.

If objectId is a Work Object Id returned by VW_NextWorkObjectToBrowse(),


this function returns the value of the Work Queue field identified by
lpszFieldName.

If objectId is an Operation Id, this function returns the value of an Operation


parameter in the Work Object’s current Operation.

If objectId is an access handle returned from VW_GetAccessHandle() or


VW_WobQueryGetAccesshandle(), this function returns the value of the Work
Object field identified by lpszFieldName.

You can call VW_GetBoolean() from either an active or passive Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_GetBoolean(VW_Handle objectId,
VW_FieldNameType lpszFieldName,
VW_Boolean *value);

Input Parameters:
VW_Handle objectId
Identifies one of the following:
i) A passive or active Work Performer handle. Obtained by a
call to VW_GetWorkPerformerHandle() (passive Work
Performer) or VW_ReportToWork() (active Work Performer).
ii) An enqueued Work Object. Obtained by a call to
VW_NextWorkObjectToBrowse().
iii) The operation Id of a passive or active Work Performer.
Obtained from the adaptor (passive Work Performer) or a call
to VW_LockWorkObject() (active Work Performer).
iv) An access handle obtained by a call to
VW_GetAccessHandle() or
VW_WobQueryGetAccessHandle().

December 1996 Work Performer Developer’s Guide 121


DLL Work Performers
VW_GetBoolean

VW_FieldNameType lpszFieldName
Supplied by the programmer. Identifies one of the following:
i) A passive or active Work Performer field name.
ii) A Work Queue field name.
iii) An Operation parameter name.
iv) A Work Object field name.

Output Parameters:
VW_Boolean *value
Returned value.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_GetBooleanProcType)
(VW_Handle,
VW_FieldNameType,
VW_Boolean *);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

122 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_GetDataType

VW_GetDataType
This function returns the data type of the specified field from an object
determined by objectId.

If objectId is the Id of a passive or active Work Performer, this function returns


the type of the field identified by lpszFieldName in the specified Work
Performer.

If objectId is a Work Object Id returned by VW_NextWorkObjectToBrowse(),


this function returns the type of a Work Queue field identified by
lpszFieldName.

If objectId is an Operation Id, this function returns the type of an Operation


parameter.

If objectId is a Work Object Id obtained from VW_CreateWorkObject(), this


function returns the type of a Work Object field identified by lpszFieldName.

If objectId is an access handle returned from VW_GetAccessHandle() or


VW_WobQueryGetAccesshandle(), this function returns the type of the Work
Object field identified by lpszFieldName.

You can call VW_GetDataType() from either an active or passive Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_GetDataType(VW_Handle objectId,
VW_FieldNameType lpszFieldName,
VW_DataType *type);

Input Parameters:
VW_Handle objectId
Identifies one of the following:
i) A passive or active Work Performer. Obtained by a call to
VW_GetWorkPerformerHandle() (passive Work Performer) or
VW_ReportToWork() (active Work Performer).
ii) An enqueued Work Object. Obtained by a call to
VW_NextWorkObjectToBrowse().
iii) The operation Id of a passive or active Work Performer.
Obtained from the adaptor (passive Work Performer) or a call
to VW_LockWorkObject() (active Work Performer).
iv) A newly-created Work Object. Obtained by a call to

December 1996 Work Performer Developer’s Guide 123


DLL Work Performers
VW_GetDataType

VW_CreateWorkObject().
v) An access handle obtained by a call to
VW_GetAccessHandle() or
VW_WobQueryGetAccessHandle().

VW_FieldNameType lpszFieldName
Supplied by the programmer. Identifies one of the following:
i) A passive or active Work Performer field name.
ii) A Work Queue field name.
iii) An Operation parameter name.
iv) A field name in a newly created Work Object.
v) A Work Object field name.

Output Parameters:
VW_DataType *type
Identifies the data type of the specified field.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_GetDataTypeProcType)
(VW_Handle,
VW_FieldNameType,
VW_DataType *);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

124 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_GetDataTypeArray

VW_GetDataTypeArray
This function returns the data type of the array elements. Use this call when
VW_GetDataType() has returned a type of array.

If objectId is the Id of a passive or active Work Performer, this function returns


the type of the field identified by lpszFieldName in the specified Work
Performer.

If objectId is a Work Object Id returned by VW_NextWorkObjectToBrowse(),


this function returns the type of a Work Queue field identified by
lpszFieldName.

If objectId is an Operation Id, this function returns the value of an Operation


parameter.

If objectId is a Work Object Id returned by VW_CreateWorkObject(), this


function returns the type of a Work Object field identified by lpszFieldName.

If objectId is an access handle returned from VW_GetAccessHandle() or


VW_WobQueryGetAccesshandle(), this function returns the type of the Work
Object field identified by lpszFieldName.

You can call VW_GetDataTypeArray() from either an active or passive Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_GetDataTypeArray(VW_Handle objectId,
VW_FieldNameType lpszFieldName,
VW_DataType *type);

Input Parameters:
VW_Handle objectId
Identifies one of the following:
i) A passive or active Work Performer. Obtained by a call to
VW_GetWorkPerformerHandle() (passive Work Performer) or
VW_ReportToWork() (active Work Performer).
ii) An enqueued Work Object. Obtained by a call to
VW_NextWorkObjectToBrowse().
iii) The operation Id of a passive or active Work Performer.
Obtained from the adaptor (passive Work Performer) or a call
to VW_LockWorkObject() (active Work Performer).
iv) A newly-created Work Object. Obtained by a call to

December 1996 Work Performer Developer’s Guide 125


DLL Work Performers
VW_GetDataTypeArray

VW_CreateWorkObject().
v) An access handle obtained by a call to
VW_GetAccessHandle() or
VW_WobQueryGetAccessHandle().

VW_FieldNameType lpszFieldName
Supplied by the programmer. Identifies one of the following:
i) A passive or active Work Performer field name.
ii) A Work Queue field name.
iii) An Operation parameter name.
iv) A field name in a newly created Work Object.
v) A Work Object field name.

Output Parameters:
VW_DataType *type
Identifies the data type of the array.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_GetDataTypeArrayProcType)
(VW_Handle,
VW_FieldNameType,
VW_DataType *);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

126 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_GetErrorMessage

VW_GetErrorMessage
This function returns the error message text corresponding to errorCode.

It is the caller’s responsibility to allocate sufficient memory for the error


message string. Use VW_GetErrorMessageSize() to determine the amount of
memory needed.

You can call VW_GetErrorMessage() from either an active or passive Work


Performer.

Syntax:
unsigned FAR PASCAL VW_GetErrorMessage(VW_Error errorCode,
VW_MessageType lpszMessage);

Input Parameters:
VW_Error errorCode
Specifies an error code returned by an API call.

Output Parameters:
VW_MessageType lpszMessage
Identifies the error message string. This parameter is a
pointer to a writable location in memory.

Return Value:
Returns the number of bytes copied to lpszMessage excluding the NULL
character. Returns zero if errorCode is invalid.

Function Typedef:
typedef unsigned (FAR PASCAL *VW_GetErrorMessageProcType)
(VW_Error,
VW_MessageType);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

December 1996 Work Performer Developer’s Guide 127


DLL Work Performers
VW_GetErrorMessageSize

VW_GetErrorMessageSize
This function returns the size (in bytes) of the error message string
corresponding to errorCode. Call VW_GetErrorMessageSize() to determine
the amount of memory you need to allocate before calling VW_GetError-
Message().

You can call VW_GetErrorMessageSize() from either an active or passive


Work Performer.

Syntax:
unsigned FAR PASCAL VW_GetErrorMessageSize(VW_Error errorCode);

Input Parameters:
VW_Error errorCode
Specifies an error code returned by an API call.

Output Parameters:
None.

Return Value:
Returns the size of the error message string, excluding the NULL character.
Returns zero if errorCode is invalid.

Function Typedef:
typedef unsigned (FAR PASCAL * VW_GetErrorMessageSizeProcType)
(VW_Error);

128 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_GetFieldNames

VW_GetFieldNames
This function returns a string array that contains the names of all fields in the
object identified by objectId.

The caller is not responsible for allocating memory for the array. This function
allocates the necessary memory and returns a pointer to the array.

The caller must free the returned array by calling VW_FreeArrayPtr(). The
array elements are of type VW_String.

VW_GetFieldNames() can only be called from adaptors. Work Performers


cannot call this function.

Syntax:
VW_Error FAR PASCAL VW_GetFieldNames(VW_Handle objectId,
VW_ArrayPtrType *value,
long *numElements);

Input Parameters:
VW_Handle objectId
Identifies the operationId of a passive Work Performer.

Output Parameters:
VW_ArrayPtrType *value
The list of parameters within an Operation.

long *numElements
The number of elements in the array.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_GetFieldNamesProcType)
(VW_Handle,
VW_ArrayPtrType *,
long *);

December 1996 Work Performer Developer’s Guide 129


DLL Work Performers
VW_GetFieldNames

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

130 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_GetFloat

VW_GetFloat
This function returns data of type double from a field determined by the
objectId parameter. The returned data type is in a 16-byte decimal floating
point number format.

If objectId is the handle of a passive or active Work Performer, this function


returns the value of the Work Performer field identified by lpszFieldName.

If objectId is a Work Object Id returned by VW_NextWorkObjectToBrowse(),


this function returns the value of the Work Queue field identified by
lpszFieldName.

If objectId is an Operation Id, this function returns the value of an Operation


parameter in the Work Object’s current Operation.

If objectId is an access handle returned from VW_GetAccessHandle() or


VW_WobQueryGetAccesshandle(), this function returns the value of the Work
Object field identified by lpszFieldName.

You can call VW_GetFloat() from either an active or passive Work Performer.

Syntax:
VW_Error FAR PASCAL VW_GetFloat (VW_Handle objectId,
VW_FieldNameType lpszFieldName,
VW_Float *value);

Input Parameters:
VW_Handle objectId
Identifies one of the following:
i) A passive or active Work Performer handle. Obtained by a
call to VW_GetWorkPerformerHandle() (passive Work
Performer) or VW_ReportToWork() (active Work Performer).
ii) An enqueued Work Object. Obtained by a call to
VW_NextWorkObjectToBrowse().
iii) The operation Id of a passive or active Work Performer.
Obtained from the adaptor (passive Work Performer) or a call
to VW_LockWorkObject() (active Work Performer).
iv) An access handle obtained by a call to
VW_GetAccessHandle() or
VW_WobQueryGetAccessHandle().

December 1996 Work Performer Developer’s Guide 131


DLL Work Performers
VW_GetFloat

VW_FieldNameType lpszFieldName
Supplied by the programmer. Identifies one of the following:
i) A passive or active Work Performer field name.
ii) A Work Queue field name.
iii) An Operation parameter name.
iv) A Work Object field name.

Output Parameters:
VW_Float *value
Returned value.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL VW_GetFloatProcType)
(VW_Handle,
VW_FieldNameType,
VW_Float *);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

132 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_GetFPNumber

VW_GetFPNumber
This function returns a parameter value containing data from a field
determined by the objectId parameter. The returned data type is in a 16-byte
decimal floating point number format.

Note You need the WorkFlo Application Libraries to use this call.

If objectId is the handle of a passive or active Work Performer, this function


returns the value of the Work Performer field identified by lpszFieldName.

If objectId is a Work Object Id returned by VW_NextWorkObjectToBrowse(),


this function returns the value of the Work Queue field identified by
lpszFieldName.

If objectId is an Operation Id, this function returns the value of an Operation


parameter in the Work Object’s current Operation.

If objectId is an access handle returned from VW_GetAccessHandle() or


VW_WobQueryGetAccesshandle(), this function returns the value of the Work
Object field identified by lpszFieldName.

You can call VW_GetFPNumber() from either an active or passive Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_GetFPNumber(VW_Handle objectId,
VW_FieldNameType lpszFieldName,
VW_FPNumber value);

Input Parameters:
VW_Handle objectId
Identifies one of the following:
i) A passive or active Work Performer handle. Obtained by a
call to VW_GetWorkPerformerHandle() (passive Work
Performer) or VW_ReportToWork() (active Work Performer).
ii) An enqueued Work Object. Obtained by a call to
VW_NextWorkObjectToBrowse().
iii) The operation Id of a passive or active Work Performer.
Obtained from the adaptor (passive Work Performer) or a call
to VW_LockWorkObject() (active Work Performer).
iv) An access handle obtained by a call to

December 1996 Work Performer Developer’s Guide 133


DLL Work Performers
VW_GetFPNumber

VW_GetAccessHandle() or
VW_WobQueryGetAccessHandle().

VW_FieldNameType lpszFieldName
Supplied by the programmer. Identifies one of the following:
i) A passive or active Work Performer field name.
ii) A Work Queue field name.
iii) An Operation parameter name.
iv) A Work Object field name.

Output Parameters:
VW_FPNumber value
Returned value.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_GetFPNumberProcType)
(VW_Handle,
VW_FieldNameType,
VW_FPNumber);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

134 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_GetInteger

VW_GetInteger
This function returns data of type integer from a field determined by the
objectId parameter.

If objectId is the handle of a passive or active Work Performer, this function


returns the value of the Work Performer field identified by lpszFieldName.

If objectId is a Work Object Id returned by VW_NextWorkObjectToBrowse(),


this function returns the value of the Work Queue field identified by
lpszFieldName.

If objectId is an Operation Id, this function returns the value of an Operation


parameter in the Work Object’s current Operation.

If objectId is an access handle returned from VW_GetAccessHandle() or


VW_WobQueryGetAccesshandle(), this function returns the value of the Work
Object field identified by lpszFieldName.

You can call VW_GetInteger() from either an active or passive Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_GetInteger(VW_Handle objectId,
VW_FieldNameType lpszFieldName,
VW_Integer *value);

Input Parameters:
VW_Handle objectId
Identifies one of the following:
i) A passive or active Work Performer handle. Obtained by a
call to VW_GetWorkPerformerHandle() (passive Work
Performer) or VW_ReportToWork() (active Work Performer).
ii) An enqueued Work Object. Obtained by a call to
VW_NextWorkObjectToBrowse().
iii) The operation Id of a passive or active Work Performer.
Obtained from the adaptor (passive Work Performer) or a call
to VW_LockWorkObject().
iv) An access handle for a Work Object obtained by a call to
VW_GetAccessHandle() or
VW_WobQueryGetAccessHandle().

December 1996 Work Performer Developer’s Guide 135


DLL Work Performers
VW_GetInteger

VW_FieldNameType lpszFieldName
Supplied by the programmer. Identifies one of the following:
i) A passive or active Work Performer field name.
ii) A Work Queue field name.
iii) An Operation parameter name.
iv) A Work Object field name.

Output Parameters:
VW_Integer *value
Returned value.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL * VW_GetIntegerProcType)
(VW_Handle,
VW_FieldNameType,
VW_Integer *);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

136 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_GetLoggingState

VW_GetLoggingState
This function returns the state of the specified logging option of the active or
passive Work Performer identified by objectId. If loggingOption contains zero,
this function does nothing and returns zero.

You can call VW_GetLoggingState() from either an active or passive Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_GetLoggingState(VW_Handle objectId,
VW_LogOption loggingOption,
VW_Boolean *loggingState);

Input Parameters:
VW_Handle objectId
Identifies the handle of a passive or active Work Performer.
Obtained by a call to VW_ReportToWork() (active Work
Performer) or VW_GetWorkPerformerHandle() (passive Work
Performer).

VW_LogOption loggingOption
Supplied by the programmer. Specifies which Work Performer
logging option to retrieve. Valid values are as follows:

1 WorkPerformer Creation
2 WorkPerformer Terminate
3 WorkPerformer Debugging
4 WorkPerformer System Message
5 WorkPerformer General Message
Options 6 - 8 are unavailable
9 WorkObject Creation
10 WorkObject Terminate
11 WorkObject Exceptions
12 WorkObject Debugging
13 WorkObject System Message
14 WorkObject General Message

December 1996 Work Performer Developer’s Guide 137


DLL Work Performers
VW_GetLoggingState

15 WorkObject Abnormal Termination


Options 16 - 20 are unavailable
21 WO/WP Begin Operation
22 WO/WP Request Next Operation
23 WP/WO Service Complete
Options 24 - 30 are unavailable
31 WP/WO User Defined
32 WP/WO User Defined

Output Parameters:
VW_Boolean *loggingState
Identifies the state of the specified logging option. This
parameter can contain one of the following values:

>0 Indicates logging is on.


=0 Indicates logging is off.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_GetLoggingStateProcType)
(VW_Handle,
VW_LogOption,
VW_Boolean *);

138 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_GetOperationName

VW_GetOperationName
This function returns the name of the next Operation required by the Work
Object identified by objectId.

You must allocate sufficient space for the operation name before calling this
function. Call VW_GetOperationNameSize() to determine the amount of
memory required.

You can call VW_GetOperationName() from either an active or passive Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_GetOperationName(VW_Handle objectId,
VW_OperationNameType lpszOperationName);

Input Parameters:
VW_Handle objectId
Identifies a VW_QueueElementHandle or a
VW_OperationHandle.

Output Parameters:
VW_OperationNameType FAR lpszOperationName
Identifies the read only name of the next Operation required
by the specified Work Object. It points to a writable location in
memory.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_GetOperationNameProcType)
(VW_Handle,
VW_OperationNameType);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

December 1996 Work Performer Developer’s Guide 139


DLL Work Performers
VW_GetOperationNameSize

VW_GetOperationNameSize
This function returns the size (in bytes) of the Operation name of the Work
Object identified by objectId. Call this function before calling VW_Get-
OperationName().

You can call VW_GetOperationNameSize() from either an active or passive


Work Performer.

Syntax:
VW_Error FAR PASCAL VW_GetOperationNameSize(VW_Handle objectId,
unsigned int *size);

Input Parameters:
VW_Handle objectId
Identifies a VW_QueueElementHandle or a
VW_OperationHandle.

Output Parameters:
unsigned int *size
The size of the string (in bytes).

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_GetOperationNameSizeProcType)
(VW_Handle,
unsigned int *);

140 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_GetString

VW_GetString
This function returns a parameter value containing data of type string from a
field determined by the objectId parameter.

If objectId is the handle of a passive or active Work Performer, this function


returns the value of the Work Performer field identified by lpszFieldName.

If objectId is a Work Object Id returned by VW_NextWorkObjectToBrowse(),


this function returns the value of the Work Queue field identified by
lpszFieldName.

If objectId is an Operation Id, this function returns the value of an Operation


parameter in the Work Object’s current Operation.

If objectId is an access handle returned from VW_GetAccessHandle() or


VW_WobQueryGetAccesshandle(), this function returns the value of the Work
Object field identified by lpszFieldName.

The value parameter points to a writable location in memory. You must


allocate sufficient memory at this location. Call VW_GetStringSize() to obtain
the string size.

You can call VW_GetString() from either an active or passive Work Performer.

Syntax:
VW_Error FAR PASCAL VW_GetString (VW_Handle objectId,
VW_FieldNameType lpszFieldName,
char *value);

Input Parameters:
VW_Handle objectId
Identifies one of the following:
i) A passive or active Work Performer handle. Obtained by a
call to VW_GetWorkPerformerHandle() (passive Work
Performer) or VW_ReportToWork() active Work Performer).
ii) An enqueued Work Object. Obtained by a call to
VW_NextWorkObjectToBrowse().
iii) The operation Id of a passive or active Work Performer.
Obtained from the adaptor (passive Work Performer) or
VW_LockWorkObject() (active Work Performer).
iv) An access handle obtained by a call to

December 1996 Work Performer Developer’s Guide 141


DLL Work Performers
VW_GetString

VW_GetAccessHandle() or
VW_WobQueryGetAccessHandle().

VW_FieldNameType lpszFieldName
Supplied by the programmer. Identifies one of the following:
i) A passive or active Work Performer field name.
ii) A Work Queue field name.
iii) An Operation parameter name.
iv) A Work Object field name.

Output Parameters:
char * value
Returned value.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_GetStringProcType)
(VW_Handle,
VW_FieldNameType,
char *);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

142 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_GetStringSize

VW_GetStringSize
This function returns the length in bytes of the specified string field. Call this
function before calling VW_GetString().

If objectId is the handle of a passive or active Work Performer, this function


returns the length of the Work Performer field identified by lpszFieldName.

If objectId is a Work Object Id returned by VW_NextWorkObjectToBrowse(),


this function returns the length of the Work Queue field identified by
lpszFieldName.

If objectId is an Operation Id, this function returns the length of an Operation


parameter in the Work Object’s current Operation.

If objectId is an access handle returned from VW_GetAccessHandle() or


VW_WobQueryGetAccesshandle(), this function returns the length of the
Work Object field identified by lpszFieldName.

You can call VW_GetStringSize() from either an active or passive Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_GetStringSize(VW_Handle objectId,
VW_FieldNameType lpszFieldName,
unsigned int *size);

Input Parameters:
VW_Handle objectId
Identifies one of the following:
i) A passive or active Work Performer handle. Obtained by a
call to VW_GetWorkPerformerHandle() (passive Work
Performer) or VW_ReportToWork() (active Work Performer).
ii) An enqueued Work Object. Obtained by a call to
VW_NextWorkObjectToBrowse().
iii) The operation Id of a passive or active Work Performer.
Obtained from the adaptor (passive Work Performer) or a call
to VW_LockWorkObject() (active Work Performer).
iv) An access handle obtained by a call to
VW_GetAccessHandle() or
VW_WobQueryGetAccessHandle().

December 1996 Work Performer Developer’s Guide 143


DLL Work Performers
VW_GetStringSize

VW_FieldNameType lpszFieldName
Supplied by the programmer. Identifies one of the following:
i) A passive or active Work Performer field name.
ii) A Work Queue field name.
iii) An Operation parameter name.
iv) A Work Object field name.

Output Parameters:
unsigned int * size
Indicates the size, in bytes, of the string.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL VW_GetStringSizeProcType)
(VW_Handle,
VW_FieldNameType,
unsigned int *);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

144 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_GetTime

VW_GetTime
This function returns data of type time from a field determined by the objectId
parameter. The time specifies the number of seconds since midnight, January
1, 1970 Coordinated Universal Time (UTC, formerly Greenwich Mean Time).

Note Time values are stored as 32-bit longs. Therefore, a time value can specify a
time from 1970 to 2060.

If objectId is the handle of a passive or active Work Performer, this function


returns the value of the Work Performer field identified by lpszFieldName.

If objectId is a Work Object Id returned by VW_NextWorkObjectToBrowse(),


this function returns the value of the Work Queue field identified by
lpszFieldName.

If objectId is an Operation Id, this function returns the value of an Operation


parameter in the Work Object’s current Operation.

If objectId is an access handle returned from VW_GetAccessHandle() or


VW_WobQueryGetAccesshandle(), this function returns the value of the Work
Object field identified by lpszFieldName.

You can call VW_GetTime() from either an active or passive Work Performer.

Syntax:
VW_Error FAR PASCAL VW_GetTime(VW_Handle objectId,
VW_FieldNameType lpszFieldName,
VW_Time *value);

Input Parameters:
VW_Handle objectId
Identifies one of the following:
i) A passive or active Work Performer handle. Obtained by a
call to VW_GetWorkPerformerHandle() (passive Work
Performer) or VW_ReportToWork() (active Work Performer).
ii) An enqueued Work Object. Obtained by a call to
VW_NextWorkObjectToBrowse().
iii) The operation Id of a passive or active Work Performer.
Obtained from the adaptor (passive Work Performer) or a call
to VW_LockWorkObject() (active Work Performer).
iv) An access handle obtained by a call to

December 1996 Work Performer Developer’s Guide 145


DLL Work Performers
VW_GetTime

VW_GetAccessHandle() or
VW_WobQueryGetAccessHandle().

VW_FieldNameType lpszFieldName
Supplied by the programmer. Identifies one of the following:
i) A passive or active Work Performer field name.
ii) A Work Queue field name.
iii) An Operation parameter name.
iv) A Work Object field name.

Output Parameters:
VW_Time *value
Returned value. The number of seconds since midnight
January 1, 1970 Coordinated Universal Time.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_GetTimeProcType)
(VW_Handle,
VW_FieldNameType,
VW_Time *);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

146 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_GetWobSignature

VW_GetWobSignature
This function returns a string containing the signature for the Work Object.
The signature uniquely identifies the Work Object in this WorkFlo system.

You can only call VW_GetWobSignature() from an active Work Performer.

Syntax:
VW_Error FAR PASCAL VW_GetWobSignature(VW_Handle wobHandle,
VW_WobSignatureType lpszWobSignature);

Input Parameters:
VW_Handle wobHandle
Identifies a Work Object. Can be a queueElementId returned
from VW_NextWorkObjectToBrowse(), an operationId
returned from VW_LockWorkObject(), or a wobAccess-
Handle returned from VW_GetAccessHandle() or
VW_WobQueryGetAccessHandle().

Output Parameters:
VW_WobSignatureType lpszWobSignature
The signature of the Work Object specified by wobHandle.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
VW_Error (FAR PASCAL *VW_GetWobSignatureProcType)
(VW_Handle,
VW_WobSignatureType);

December 1996 Work Performer Developer’s Guide 147


DLL Work Performers
VW_GetWorkPerformerHandle

VW_GetWorkPerformerHandle
This function returns the handle of the Work Performer associated with the
specified VW_OperationHandle. The handle can be from either a passive or
an active Work Performer.

You can call VW_GetWorkPerformerHandle() from either an active or passive


Work Performer.

Syntax:
VW_Error FAR PASCAL VW_GetWorkPerformerHandle
(VW_OperationHandle operationHandle,
VW_Handle *workerHandle);

Input Parameters:
VW_OperationHandle operationHandle
Identifies a locked Work Object.

Output Parameters:
VW_Handle *workerHandle
Identifies a Work Performer for purposes of calling APIs that
can accept a VW_PassiveWPHandle or a VW_ActiveWP-
Handle.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_GetWorkPerformerHandleProcType)
(VW_OperationHandle,
VW_Handle *);

148 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_LeaveWork

VW_LeaveWork
This function releases the caller as an active Work Performer. Frees any
resources allocated to workPerformerId and any associated browseIds,
queueElementIds, and operationIds. This function invalidates all such Ids. You
must call this function to free resources allocated by VW_ReportToWork().

VW_LeaveWork() should be called once (for each queue being browsed)


before the Work Performer is shut down.

You can only call VW_LeaveWork() from an active Work Performer.

Syntax:
VW_Error FAR PASCAL VW_LeaveWork
(VW_ActiveWPHandle workPerformerId);

Input Parameters:
VW_ActiveWPHandle workPerformerId
Identifies the calling Work Performer. Obtained by a call to
VW_ReportToWork().

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_LeaveWorkProcType)
(VW_ActiveWPHandle);

December 1996 Work Performer Developer’s Guide 149


DLL Work Performers
VW_LockWorkObject

VW_LockWorkObject
This function locks the Work Object identified by queueElementId. Once
locked, its current Operation can be performed. The OperationHandle can be
used in subsequent calls to data access functions, such as VW_GetInteger()
or VW_SetInteger(), as well as calls to VW_UnlockWorkObject() and
VW_UnlockAndDispatch().

The Work Object cannot be locked again until a successful call to


VW_UnlockWorkObject() or VW_UnlockAndDispatch() is made.

The returned operationId remains valid until a call to VW_UnlockWork-


Object(), VW_UnlockAndDispatch(), or VW_LeaveWork() is made.

You must call VW_UnlockAndDispatch() or VW_UnlockWorkObject() when


you are finished processing the Work Object.

You can only call VW_LockWorkObject() from an active Work Performer.

Syntax:
VW_Error FAR PASCAL VW_LockWorkObject
(VW_QueueElementHandle queueElementId,
VW_OperationHandle *operationId);

Input Parameters:
VW_QueueElementHandle queueElementId
Identifies a Work Object in the Work Queue from a browse
session. Obtained by a call to
VW_NextWorkObjectToBrowse().

Output Parameters:
VW_OperationHandle *operationId
Identifies a locked Work Object whose current Operation is to
be performed by the caller.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

150 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_LockWorkObject

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_LockWorkObjectProcType)
(VW_QueueElementHandle,
VW_OperationHandle *);

December 1996 Work Performer Developer’s Guide 151


DLL Work Performers
VW_LogMessage

VW_LogMessage
This function logs a user-defined message lpszMessage to the History
Repository. The specified logging option must be ON (1) in both the Work
Performer’s set of logging options and the logging vector defined in the VW.INI
file.

You can call VW_LogMessage() from either an active or passive Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_LogMessage(VW_Handle objectId,
VW_MessageType lpszMessage,
VW_LogOption loggingOption);

Input Parameters:
VW_Handle objectId
Identifies the handle of a passive or active Work Performer.
Obtained by a call to VW_ReportToWork() (active Work
Performer) or VW_GetWorkPerformerHandle() (passive Work
Performer).

VW_MessageType lpszMessage
Supplied by the programmer. Specifies the user-defined
message, which must not exceed VW_MAXMESSAGELEN
bytes (defined in the SVCAPI.H file).

VW_LogOption loggingOption
Supplied by the programmer. Specifies the logging option for
which lpszMessage will be logged.

Only the following logging options are valid:

3 VW_WPDebugOption
4 VW_WPSystemOption
5 VW_WPMiscOption
12 VW_WODebugOption
13 VW_WOSystemOption
14 VW_WOMiscOption

152 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_LogMessage

31 VW_USER1Option
32 VW_USER2Option

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_LogMessageProcType)
(VW_Handle,
VW_MessageType,
VW_LogOption);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

December 1996 Work Performer Developer’s Guide 153


DLL Work Performers
VW_Logoff

VW_Logoff
This function invalidates the logonId returned from VW_Logon(). You must call
this function to release resources allocated by VW_Logon(). VW_Logoff()
should be called once before the Work Performer is shut down.

If you need to call VW_DispatchWorkObject(), make that call before calling


VW_Logoff().

You can only call VW_Logoff() from an active Work Performer or an


administration program that creates or locates Work Objects.

Syntax:
VW_Error FAR PASCAL VW_Logoff(VW_LogonHandle logonId);

Input Parameters:
VW_LogonHandle logonId
The logon Id returned by VW_Logon().

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_LogoffProcType)
(VW_LogonHandle);

154 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_Logon

VW_Logon
This function returns a logon Id used in subsequent API calls. VW_Logon()
should be called once when the Work Performer is started.

You must call VW_Logoff() to free the resources associated with logonId.

You can only call VW_Logon() from an active Work Performer or an


administration program that creates or locates Work Objects.

Note For 32-bit Work Performers, the Visual WorkFlo API calls are now provided by
an OLE server. The OLE server is loaded when the first API call is made (i.e.
when VW_Logon() is called); Visual WorkFlo is also loaded at this time. You
might notice that the VW_Logon() call is a little slower due to Visual WorkFlo
being loaded, but the initial loading of the application will be faster because
Visual WorkFlo is not loaded at that time.

The OLE server is also unloaded when the last call to VW_Logoff() is made. If
you call VW_Logon(), VW_Logoff(), and then VW_Logon() again, there will
also be a delay with the second VW_Logon() call because the OLE server
was unloaded when VW_Logoff() was called and must be reloaded. We
recommend that you call VW_Logon() once at the beginning of your Work
Performer and call VW_Logoff() once at the end.

Syntax:
VW_Error FAR PASCAL VW_Logon(VW_LogonHandle *logonId);

Input Parameters:
None.

Output Parameters:
VW_LogonHandle *logonId
A unique logon Id. logonId must be properly allocated by the
caller prior to being passed to this function. The caller must
also free logonId. If an error occurs, this parameter will
contain zero.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

December 1996 Work Performer Developer’s Guide 155


DLL Work Performers
VW_Logon

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_LogonProcType)
(VW_LogonHandle *);

156 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_NextWorkObjectToBrowse

VW_NextWorkObjectToBrowse
This function returns a queueElementId, used to reference a Work Object in
the Work Queue being browsed. queueElementId remains valid until a call to
VW_EndBrowsingWorkQueue() or VW_LeaveWork() is made.

The queueElementId also becomes invalid under certain circumstances after


a call to VW_UnlockWorkObject() (for more information, see
“VW_UnlockWorkObject” on page 182).

You can only call VW_NextWorkObjectToBrowse() from an active Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_NextWorkObjectToBrowse
(VW_BrowseHandle browseId,
VW_QueueElementHandle *queueElementId);

Input Parameters:
VW_BrowseHandle browseId
Identifies a browse session. Obtained by a call to
VW_BeginBrowsingWorkQueue().

Output Parameters:
VW_QueueElementHandle *queueElementId
Identifies an enqueued Work Object. Used in subsequent
calls to VW_LockWorkObject() and data access functions
such as VW_GetInteger() or VW_GetFloat().

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL * VW_NextWorkObjectToBrowseProcType)
(VW_BrowseHandle,
VW_QueueElementHandle *);

December 1996 Work Performer Developer’s Guide 157


DLL Work Performers
VW_RaiseException

VW_RaiseException
This function calls an exception handling Instruction Sheet for the Work
Object identified by objectId.

If objectId is the operationId of a passive Work Performer, the exception


handling Instruction Sheet is called after the Work Performer has completed
the current Operation.

If objectId is an operation Id of an active Work Performer (obtained from a call


to VW_LockWorkObject()), the exception handling Instruction Sheet is called
immediately, thus invalidating the Operation Id.

In either case, any changes to out or inout parameters of the current


Operation are discarded.

You can call VW_RaiseException() from either an active or passive Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_RaiseException(VW_Handle objectId,
VW_ExceptionNameType lpszExceptionName,
VW_MessageType lpszDescription);

Input Parameters:
VW_Handle objectId
Identifies an operation Id of a passive or active Work
Performer. Obtained by a call to VW_LockWorkObject()
(active Work Performer) or from the adaptor (passive Work
Performer).

VW_ExceptionNameType lpszExceptionName
Supplied by the programmer. Name of the Instruction Sheet
to call.

VW_MessageType lpszDescription
Supplied by the programmer. Description of the exception.

Output Parameters:
None.

158 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_RaiseException

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_RaiseExceptionProcType)
(VW_Handle,
VW_ExceptionNameType,
VW_MessageType);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

December 1996 Work Performer Developer’s Guide 159


DLL Work Performers
VW_ReportToWork

VW_ReportToWork
This function establishes the caller as an active Work Performer. The returned
workPerformerId remains valid until a call to VW_LeaveWork() is made. You
must call VW_LeaveWork() to free resources associated with workPer-
formerId.

VW_ReportToWork() should be called once (for each queue being browsed)


after the Work Performer is started.

You can only call VW_ReportToWork() from an active Work Performer.

Syntax:
VW_Error FAR PASCAL VW_ReportToWork
(VW_QueueHandle workQueueId,
VW_ActiveWPHandle *workPerformerId);

Input Parameters:
VW_QueueHandle workQueueId
Identifies the workQueueId. Obtained by a call to VW_Attach-
ToWorkQueue().

Output Parameters:
VW_ActiveWPHandle * workPerformerId
Identifies a Work Performer. Used in subsequent calls to
VW_BeginBrowsingWorkQueue() and VW_LeaveWork().

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_ReportToWorkProcType)
(VW_QueueHandle,
VW_ActiveWPHandle *);

160 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_SetArrayPtr

VW_SetArrayPtr
This function sets field values into an array determined by the objectId
parameter.

If objectId is the Id of a passive or active Work Performer, this function sets the
value in the field identified by lpszFieldName in the specified Work Performer.

If objectId is an Operation Id, this function sets the value of an Operation


parameter in the Work Object’s current Operation.

If objectId is a Work Object Id returned by VW_CreateWorkObject(), this


function sets the initial value in a Work Object field, identified by
lpszFieldName.

If objectId is an access handle of a Work Object obtained by a call to VW_Get-


AccessHandle() or VW_WobQueryGetAccessHandle(), this function sets the
value of the field identified by lpszFieldName.

objectId cannot be an unlocked Work Object (queueElementId).

You can call VW_SetArrayPtr() from either an active or passive Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_SetArrayPtr (VW_Handle objectId,
VW_FieldNameType lpszFieldName,
VW_ArrayPtrType value,
long numElements,
VW_DataType type);

Input Parameters:
VW_Handle objectId
Identifies one of the following:
i) A passive or active Work Performer handle. Obtained by a
call to VW_GetWorkPerformerHandle() (passive Work
Performer) or VW_ReportToWork) (active Work Performer).
ii) The Operation Id of a passive or active Work Performer.
Obtained from the adaptor (passive Work Performer) or a call
to VW_LockWorkObject() (active Work Performer).
iii) A newly-created Work Object. Obtained by a call to
VW_CreateWorkObject().
iv) An access handle obtained by a call to

December 1996 Work Performer Developer’s Guide 161


DLL Work Performers
VW_SetArrayPtr

VW_GetAccessHandle() or
VW_WobQueryGetAccessHandle().

VW_FieldNameType lpszFieldName
Supplied by the programmer. Identifies one of the following:
i) A passive or active Work Performer field name.
ii) An Operation parameter name.
iii) A field name in the newly-created Work Object.
iv) A Work Object field name.

VW_ArrayPtrType value
Supplied by the programmer. Points to the caller’s allocated
memory location that contains the array, or an array pointer
returned from VW_GetArrayPtr(). It is the caller’s
responsibility to free this array pointer.

long numElements
Supplied by the programmer. Specifies the number of array
elements. Elements might be fewer than the number of
elements in the Visual WorkFlo array.

VW_DataType type
Supplied by the programmer. Data type of the array.

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_SetArrayPtrProcType)
(VW_Handle,
VW_FieldNameType,
VW_ArrayPtrType,
long,
VW_DataType);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

162 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_SetBoolean

VW_SetBoolean
This function sets a value of type boolean into a field determined by the
objectId parameter.

If objectId is the Id of a passive or active Work Performer, this function sets the
value in the field identified by lpszFieldName in the specified Work Performer.

If objectId is an Operation Id, this function sets the value of an Operation


parameter in the Work Object’s current Operation.

If objectId is a Work Object Id returned by VW_CreateWorkObject(), this


function sets the initial value in a Work Object field, identified by
lpszFieldName.

If objectId is an access handle of a Work Object obtained by a call to


VW_GetAccessHandle() or VW_WobQueryGetAccessHandle(), this function
sets the value of the field identified by lpszFieldName.

objectId cannot be an unlocked Work Object (queueElementId). This function


cannot set a value into a Work Queue field.

You can call VW_SetBoolean() from either an active or passive Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_SetBoolean(VW_Handle objectId,
VW_FieldNameType lpszFieldName,
VW_Boolean value);

Input Parameters:
VW_Handle objectId
Identifies one of the following:
i) A passive or active Work Performer handle. Obtained by a
call to VW_GetWorkPerformerHandle() (passive Work
Performer) or VW_ReportToWork() (active Work Performer).
ii) The Operation Id of a passive or active Work Performer.
Obtained from the adaptor (passive Work Performer) or a call
to VW_LockWorkObject() (active Work Performer).
iii) A newly-created Work Object. Obtained by a call to
VW_CreateWorkObject().
iv) An access handle obtained by a call to

December 1996 Work Performer Developer’s Guide 163


DLL Work Performers
VW_SetBoolean

VW_GetAccessHandle() or
VW_WobQueryGetAccessHandle().

VW_FieldNameType lpszFieldName
Supplied by the programmer. Identifies one of the following:
i) A passive or active Work Performer field name.
ii) An Operation parameter name.
iii) A field name in the newly-created Work Object.
iv) A Work Object field name.

VW_Boolean value
Supplied by the programmer. A non-zero value represents
true; a zero value represents false.

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_SetBooleanProcType)
(VW_Handle,
VW_FieldNameType,
VW_Time);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

164 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_SetFloat

VW_SetFloat
This function sets a value of type double into a field determined by the
objectId parameter.

If objectId is the Id of a passive or active Work Performer, this function sets the
value in the field identified by lpszFieldName in the specified Work Performer.

If objectId is an Operation Id, this function sets the value of an Operation


parameter in the Work Object’s current Operation.

If objectId is a Work Object Id returned by VW_CreateWorkObject(), this


function sets the initial value in a Work Object field identified by
lpszFieldName.

If objectId is an access handle of a Work Object obtained by a call to VW_Get-


AccessHandle() or VW_WobQueryGetAccessHandle(), this function sets the
value of the field identified by lpszFieldName.

objectId cannot be an unlocked Work Object (queueElementId). This function


cannot set a value into a Work Queue field.

You can call VW_SetFloat() from either an active or passive Work Performer.

Syntax:
VW_Error FAR PASCAL VW_SetFloat (VW_Handle objectId,
VW_FieldNameType lpszFieldName,
VW_Float value);

Input Parameters:
VW_Handle objectId
Identifies one of the following:
i) A passive or active Work Performer handle. Obtained by a
call to VW_GetWorkPerformerHandle() (passive Work
Performer) or VW_ReportToWork() (active Work Performer).
ii) The Operation Id of a passive or active Work Performer.
Obtained from the adaptor (passive Work Performer) or a call
to VW_LockWorkObject() (active Work Performer).
iii) A newly-created Work Object. Obtained by a call to
VW_CreateWorkObject().
iv) An access handle for a Work Object obtained by a call to
VW_GetAccessHandle() or
VW_WobQueryGetAccessHandle().

December 1996 Work Performer Developer’s Guide 165


DLL Work Performers
VW_SetFloat

VW_FieldNameType lpszFieldName
Supplied by the programmer. Identifies one of the following:
i) A passive or active Work Performer field name.
ii) An Operation parameter name.
iii) A field name in the newly-created Work Object.
iv) A Work Object field name.

VW_Float value
Supplied by the programmer. The new value.

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_SetFloatProcType)
(VW_Handle,
VW_FieldNameType,
VW_Float);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

166 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_SetFPNumber

VW_SetFPNumber
This function sets a value of type floating point into a field determined by the
objectId parameter. The returned data type is in a 16-byte decimal floating
point number format.

Note You need the WorkFlo Application Libraries to use this call.

If objectId is the Id of a passive or active Work Performer, this function sets the
value in the field identified by lpszFieldName in the specified Work Performer.

If objectId is an Operation Id, this function sets the value of an Operation


parameter in the Work Object’s current Operation.

If objectId is a Work Object Id returned by VW_CreateWorkObject(), this


function sets the initial value in a Work Object field, identified by
lpszFieldName.

If objectId is an access handle of a Work Object obtained by a call to VW_Get-


AccessHandle() or VW_WobQueryGetAccessHandle(), this function sets the
value of the field identified by lpszFieldName.

objectId cannot be an unlocked Work Object (queueElementId). This function


cannot set a value into a Work Queue field.

You can call VW_SetFPNumber() from either an active or passive Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_SetFPNumber(VW_Handle objectId,
VW_FieldNameType lpszFieldName,
VW_FPNumber value);

Input Parameters:
VW_Handle objectId
Identifies one of the following:
i) A passive or active Work Performer handle. Obtained by a
call to VW_GetWorkPerformerHandle() (passive Work
Performer) or VW_ReportToWork() (active Work Performer).
ii) The Operation Id of a passive or active Work Performer.
Obtained from the adaptor (passive Work Performer) or a call
to VW_LockWorkObject() (active Work Performer).
iii) A newly-created Work Object. Obtained by a call to

December 1996 Work Performer Developer’s Guide 167


DLL Work Performers
VW_SetFPNumber

VW_CreateWorkObject().
iv) An access handle obtained by a call to
VW_GetAccessHandle() or
VW_WobQueryGetAccessHandle().

VW_FieldNameType lpszFieldName
Supplied by the programmer. Identifies one of the following:
i) A passive or active Work Performer field name.
ii) An Operation parameter name.
iii) A field name in the newly-created Work Object.
iv) A Work Object field name.

VW_FPNumber value
Supplied by the programmer. The new value.

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_SetFPNumberProcType)
(VW_Handle,
VW_FieldNameType,
VW_FPNumber);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

168 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_SetInteger

VW_SetInteger
This function sets a value of type integer into a field determined by the
objectId parameter.

If objectId is the Id of a passive or active Work Performer, this function sets the
value in the field identified by lpszFieldName in the specified Work Performer.

If objectId is an Operation Id, this function sets the value of an Operation


parameter in the Work Object’s current Operation.

If objectId is a Work Object Id returned by VW_CreateWorkObject(), this


function sets the initial value in a Work Object field, identified by
lpszFieldName.

If objectId is an access handle of a Work Object obtained by a call to VW_Get-


AccessHandle() or VW_WobQueryGetAccessHandle(), this function sets the
value of the field identified by lpszFieldName.

objectId cannot be an unlocked Work Object (queueElementId). This function


cannot set a value into a Work Queue field.

You can call VW_SetInteger() from either an active or passive Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_SetInteger(VW_Handle objectId,
VW_FieldNameType lpszFieldName,
VW_Integer value);

Input Parameters:
VW_Handle objectId
Identifies one of the following:
i) A passive or active Work Performer handle. Obtained by a
call to VW_GetWorkPerformerHandle() (passive Work
Performer) or VW_ReportToWork() (active Work Performer).
ii) The Operation Id of a passive or active Work Performer.
Obtained from the adaptor (passive Work Performer) or a call
to VW_LockWorkObject() (active Work Performer).
iii) A newly-created Work Object. Obtained by a call to
VW_CreateWorkObject().
iv) An access handle for a Work Object obtained by a call to

December 1996 Work Performer Developer’s Guide 169


DLL Work Performers
VW_SetInteger

VW_GetAccessHandle() or
VW_WobQueryGetAccessHandle().

VW_FieldNameType lpszFieldName
Supplied by the programmer. Identifies one of the following:
i) A passive or active Work Performer field name.
ii) An Operation parameter name.
iii) A field name in the newly-created Work Object.
iv) A Work Object field name.

VW_Integer value
Supplied by the programmer. The new value.

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_SetIntegerProcType)
(VW_Handle,
VW_FieldNameType,
VW_Integer);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

170 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_SetLogCacheFlushLength

VW_SetLogCacheFlushLength
This function sets the number of entries in the Log Cache that trigger a flush.
A flush occurs when the number of entries in the PC’s Log Cache is greater
than or equal to the number in numberOfLogEntries.

For more information on logging, see the “Logging Features” section in the
“Creating a Visual WorkFlo Application” chapter of the Visual WorkFlo/
Composer Handbook.

You can call VW_SetLogCacheFlushLength() from either an active or passive


Work Performer.

Syntax:
VW_LogCacheSize FAR PASCAL VW_SetLogCacheFlushLength
(VW_LogCacheSize numberOfLogEntries);

Input Parameters:
VW_LogCacheSize numberOfLogEntries
Supplied by the programmer. Specifies the new maximum
number of entries allowed in the Log Cache.

Output Parameters:
None.

Return Value:
Returns the previous maximum number of cache entries.

Function Typedef:
typedef VW_LogCacheSize (FAR PASCAL
*VW_SetLogCacheFlushLengthProcType)
(VW_LogCacheSize);

December 1996 Work Performer Developer’s Guide 171


DLL Work Performers
VW_SetLoggingState

VW_SetLoggingState
This function sets the value of loggingState in the specified loggingOption of
the Work Performer identified by objectId.

Note that Visual WorkFlo reserves logging option zero for its exclusive use. If
loggingOption is zero, this function returns success (zero).

The new logging state is AND-ed with the logging vector in the VW.INI file.
Therefore, if the logging option is set to OFF in the VW.INI file, setting the
logging option to ON with VW_SetLoggingState() has no effect.

You can call VW_SetLoggingState() from either an active or passive Work


Performer.

Syntax:
VW_Error FAR PASCAL VW_SetLoggingState(VW_Handle objectId,
VW_LogOption loggingOption,
VW_Boolean loggingState);

Input Parameters:
VW_Handle objectId
Identifies the handle of a passive or active Work Performer.
Obtained by a call to VW_ReportToWork() (active Work
Performer) or VW_GetWorkPerformerHandle() (passive Work
Performer).

VW_LogOption loggingOption
Supplied by the programmer. Specifies which Work Performer
logging option to set. The following logging options are valid:

1 WorkPerformer Creation
2 WorkPerformer Terminate
3 WorkPerformer Debugging
4 WorkPerformer System Message
5 WorkPerformer General Message
Options 6 - 8 are unavailable
9 WorkObject Creation
10 WorkObject Terminate

172 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_SetLoggingState

11 WorkObject Exceptions
12 WorkObject Debugging
13 WorkObject System Message
14 WorkObject General Message
15 WorkObject Abnormal Termination
Options 16 - 20 are unavailable
21 WO/WP Begin Operation
22 WO/WP Request Next Operation
23 WP/WO Service Complete
Options 24 - 30 are unavailable
31 WP/WO User Defined
32 WP/WO User Defined

VW_Boolean loggingState
Supplied by the programmer. Specifies whether the new
logging state is ON (1) or OFF (0).

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_SetLoggingStateProcType)
(VW_Handle,
VW_LogOption,
VW_Boolean);

December 1996 Work Performer Developer’s Guide 173


DLL Work Performers
VW_SetString

VW_SetString
This function sets a value of type string into a field determined by the objectId
parameter.

If objectId is the Id of a passive or active Work Performer, this function sets the
value in the field identified by lpszFieldName in the specified Work Performer.

If objectId is an Operation Id, this function sets the value of an Operation


parameter in the Work Object’s current Operation.

If objectId is a Work Object Id returned by VW_CreateWorkObject(), this


function sets the initial value in a Work Object field, identified by
lpszFieldName.

If objectId is an access handle of a Work Object obtained by a call to VW_Get-


AccessHandle() or VW_WobQueryGetAccessHandle(), this function sets the
value of the field identified by lpszFieldName.

objectId cannot be an unlocked Work Object (queueElementId). This function


cannot set a value into a Work Queue field.

You can call VW_SetString() from either an active or passive Work Performer.

Syntax:
VW_Error FAR PASCAL VW_SetString (VW_Handle objectId,
VW_FieldNameType lpszFieldName,
VW_String value);

Input Parameters:
VW_Handle objectId
Identifies one of the following:
i) A passive or active Work Performer handle. Obtained by a
call to VW_GetWorkPerformerHandle() (passive Work
Performer) or VW_ReportToWork() (active Work Performer).
ii) The Operation Id of a passive or active Work Performer.
Obtained from the adaptor (passive Work Performer) or a call
to VW_LockWorkObject() (active Work Performer).
iii) A newly-created Work Object. Obtained by a call to
VW_CreateWorkObject().
iv) An access handle for a Work Object obtained by a call to
VW_GetAccessHandle() or
VW_WobQueryGetAccessHandle().

174 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_SetString

VW_FieldNameType lpszFieldName
Supplied by the programmer. Identifies one of the following:
i) A passive or active Work Performer field name.
ii) An Operation parameter name.
iii) A field name in the newly-created Work Object.
iv) A Work Object field name.

VW_String value
Supplied by the programmer. The new value.

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_SetStringProcType)
(VW_Handle,
VW_FieldNameType,
VW_String);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

December 1996 Work Performer Developer’s Guide 175


DLL Work Performers
VW_SetTime

VW_SetTime
This function sets a value of type time into a field determined by the objectId
parameter. A time is specified as the number of seconds since midnight
January 1, 1970 Coordinated Universal Time (UTC).

Note Time values are stored as 32-bit longs. Therefore, a time value can specify a
time from 1970 to 2060.

If objectId is the Id of a passive or active Work Performer, this function sets the
value in the field identified by lpszFieldName in the specified Work Performer.

If objectId is an Operation Id, this function sets the value of an Operation


parameter in the Work Object’s current Operation.

If objectId is a Work Object Id returned by VW_CreateWorkObject(), this


function sets the initial value in a Work Object field, identified by
lpszFieldName.

If objectId is an access handle of a Work Object obtained by a call to VW_Get-


AccessHandle() or VW_WobQueryGetAccessHandle(), this function sets the
value of the field identified by lpszFieldName.

objectId cannot be an unlocked Work Object (queueElementId). This function


cannot set a value into a Work Queue field.

You can call VW_SetTime() from either an active or passive Work Performer.

Syntax:
VW_Error FAR PASCAL VW_SetTime(VW_Handle objectId,
VW_FieldNameType lpszFieldName,
VW_Time value);

Input Parameters:
VW_Handle objectId
Identifies one of the following:
i) A passive or active Work Performer handle. Obtained by a
call to VW_GetWorkPerformerHandle() (passive Work
Performer) or VW_ReportToWork() (active Work Performer).
ii) The Operation Id of a passive or active Work Performer.
Obtained from the adaptor (passive Work Performer) or a call
to VW_LockWorkObject() (active Work Performer).
iii) A newly-created Work Object. Obtained by a call to

176 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_SetTime

VW_CreateWorkObject().
iv) An access handle for a Work Object obtained by a call to
VW_GetAccessHandle() or
VW_WobQueryGetAccessHandle().

VW_FieldNameType lpszFieldName
Supplied by the programmer. Identifies one of the following:
i) A passive or active Work Performer field name.
ii) An Operation parameter name.
iii) A field name in the newly-created Work Object.
iv) A Work Object field name.

VW_Time value
Supplied by the programmer. The new value. The number of
seconds since midnight January 1, 1970 Coordinated
Universal Time (UTC).

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_SetTimeProcType)
(VW_Handle,
VW_FieldNameType,
VW_Time);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

December 1996 Work Performer Developer’s Guide 177


DLL Work Performers
VW_TerminateWorkObject

VW_TerminateWorkObject
This function terminates the Work Object being processed by the Work
Performer identified by objectId.

Termination of a Work Object results in the execution of the Terminate


Instruction Sheet, followed by removal of the Work Object from the On-line
repository.

If you terminate a Work Object a second time before completion of the


Terminate Instruction Sheet, the Work Object is removed immediately from
the On-line repository, without waiting for completion of the Terminate
Instruction Sheet.

If objectId identifies a passive Work Performer, the Work Object’s Terminate


Instruction Sheet is called after the Work Performer has completed the current
Operation.

If objectId identifies an active Work Performer, the Work Object is re-routed


immediately and the Operation Id becomes invalid.

You can call VW_TerminateWorkObject() from either an active or passive


Work Performer.

Syntax:
VW_Error FAR PASCAL VW_TerminateWorkObject(VW_Handle objectId);

Input Parameters:
VW_Handle objectId
Identifies the operationId of an active or passive Work
Performer. Obtained by a call to VW_LockWorkObject()
(active Work Performer) or from the adaptor (passive Work
Performer).

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

178 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_TerminateWorkObject

Function Typedef:
typedef VW_Error (FAR PASCAL * VW_TerminateWorkObjectProcType)
(VW_Handle);

December 1996 Work Performer Developer’s Guide 179


DLL Work Performers
VW_UnBind

VW_UnBind
This function ends any restrictions on the Work Object identified by
wobHandle.

You can only call VW_UnBind() from an active Work Performer.

Syntax:
VW_Error FAR PASCAL VW_UnBind(VW_Handle wobHandle);

Input Parameters:
VW_Handle wobHandle
Identifies a Work Object. Can be an operationId returned
from VW_LockWorkObject() or a locked wobAccessHandle
returned from VW_WobQueryGetAccessHandle() or
VW_GetAccessHandle().

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_UnBindProcType) (VW_Handle);

180 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_UnlockAndDispatch

VW_UnlockAndDispatch
This function unlocks the Work Object identified by operationId. It also
updates the Work Object with any Operation parameters returned via data
access functions, and dispatches the Work Object to the next Work Queue
indicated by its Instruction Sheet. Call this function when you finish
processing a Work Object locked by a call to VW_LockWorkObject().

If operationId identifies a passive Work Performer, you’ll see an error


message.

You can only call VW_UnlockAndDispatch() from an active Work Performer.

Syntax:
VW_Error FAR PASCAL VW_UnlockAndDispatch
(VW_OperationHandle operationId);

Input Parameters:
VW_OperationHandle operationId
Identifies a locked Work Object. Obtained by a call to
VW_LockWorkObject(). operationId is invalid after a call to
this function.

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_UnlockAndDispatchProcType)
(VW_OperationHandle);

December 1996 Work Performer Developer’s Guide 181


DLL Work Performers
VW_UnlockWorkObject

VW_UnlockWorkObject
This function unlocks the Work Object identified by operationId. The Work
Object is unlocked and remains in the Work Queue. operationId is invalid after
a call to this function. Any Operation parameters returned via data access
functions are discarded (i.e., any changes made to the Operation parameters
are discarded). Call this function to unlock and leave unchanged a Work
Object locked by a call to VW_LockWorkObject().

If operationId identifies a passive Work Performer, you’ll see an error


message.

You can only call VW_UnlockWorkObject() from an active Work Performer.

Syntax:
VW_Error FAR PASCAL VW_UnlockWorkObject
(VW_OperationHandle operationId);

Input Parameters:
VW_OperationHandle operationId
Identifies a locked Work Object. Obtained by all call to
VW_LockWorkObject().

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_UnlockWorkObjectProcType)
(VW_OperationHandle);

182 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_WobQueryCreate

VW_WobQueryCreate
This function creates a WorkObjectQuery object for the Work Class specified
by workClassName. WorkObjectQuery objects are used to access information
about Work Objects of a specific Work Class and Work Object ID.

The Work Object ID to be searched for is specified by a subsequent call to


one of the data access functions, such as VW_SetInteger(), passing in
WobQueryHandle, the empty string ("") for the Work Object ID field name, and
the ID value to search for. You specify an empty string for the Work Object ID
field name because the Work Object ID for the Work Class is specified in the
Properties editor of Visual WorkFlo/Composer.

It is the caller’s responsibility to call the data access function that corresponds
to the data type of the Work Object ID field name. Note that VW_SetFP-
Number() is not supported for Work Object queries.

After the name has been specified as described, call VW_WobQuery-


Execute() to execute the query. See “VW_WobQueryExecute” on page 186
for more information.

You must call VW_WobQueryEnd() to free resources associated with


wobQueryHandle.

VW_WobQueryCreate() is usually called from an administration program that


locates Work Objects or obtains information about Work Objects.

Syntax:
VW_Error FAR PASCAL VW_WobQueryCreate(VW_LogonHandle logonId,
VW_ClassNameType workClassName,
VW_WobQueryHandle *wobQueryHandle);

Input Parameters:
VW_LogonHandle logonId
Logon Id returned from VW_Logon().

VW_ClassNameType workClassName
Supplied by the programmer. Name of the Work Class.

Output Parameters:
VW_WobQueryHandle * wobQueryHandle
The handle to the WorkObjectQuery object.

December 1996 Work Performer Developer’s Guide 183


DLL Work Performers
VW_WobQueryCreate

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error(FAR PASCAL *VW_WobQueryCreateProcType)
(VW_LogonHandle,
VW_ClassNameType,
VW_WobQueryHandle *);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

184 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_WobQueryEnd

VW_WobQueryEnd
This function frees resources associated with the Work Object identified by
wobQueryHandle. It also invalidates wobQueryHandle.

Call this function to release resources allocated by VW_WobQueryCreate().

VW_WobQueryEnd() is usually called from an administration program that


locates Work Objects or obtains information about Work Objects.

Syntax:
VW_Error FAR PASCAL VW_WobQueryEnd
(VW_WobQueryHandle wobQueryHandle);

Input Parameters:
VW_WobQueryHandle wobQueryHandle
Handle to the WorkObjectQuery object. Obtained by a call to
VW_WobQueryCreate().

Output Parameters:
None.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_WobQueryEndProcType)
(VW_WobQueryHandle);

December 1996 Work Performer Developer’s Guide 185


DLL Work Performers
VW_WobQueryExecute

VW_WobQueryExecute
This function executes the Work Object query associated with wobQuery-
Handle. You must call one of the data access functions (such as VW_Set-
Integer()) prior to calling this function for the specified Work Object query.

This function returns a count of matching Work Objects. Use VW_WobQuery-


Operation(), VW_WobQueryWorkPerformerClass(), or VW_WobQueryInstr-
Sheet() to obtain information on each matching Work Object. You can identify
each matching Work Object by its index value (that ranges from 0 to
queryCount - 1).

Before calling VW_WobQueryEnd(), you can call this function repeatedly to


refresh the list of matching Work Objects.

VW_WobQueryExecute() is usually called from an administration program


that locates Work Objects or obtains information about Work Objects.

Syntax:
VW_Error FAR PASCAL VW_WobQueryExecute
(VW_WobQueryHandle wobQueryHandle,
unsigned int maxQueryCount,
unsigned int * queryCount);

Input Parameters:
VW_WobQueryHandle wobQueryHandle
Handle to the WorkObjectQuery object. Obtained by a call to
VW_WobQueryCreate().

unsigned int maxQueryCount


Supplied by the programmer. Maximum number of Work
Objects to find. Specify zero for no limit.

Output Parameters:
unsigned int * queryCount
Count of Work Objects found. This value will be less than or
equal to maxQueryCount.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

186 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_WobQueryExecute

Function Typedef:
typedef VW_Error (FAR PASCAL *VW_WobQueryExecuteProcType)
(VW_WobQueryHandle,
unsigned int,
unsigned int *);

December 1996 Work Performer Developer’s Guide 187


DLL Work Performers
VW_WobQueryGetAccessHandle

VW_WobQueryGetAccessHandle
This function returns an access handle to be used in subsequent calls to the
data access functions (such as VW_GetInteger() or VW_SetFloat()). Use the
access handle when making changes to the Work Object.

If lockForUpdate is true, subsequent attempts to obtain an access handle for


the same Work Object with the lockForUpdate parameter true will fail until the
access handle is freed.

VW_WobQueryGetAccessHandle() will return a security error if the logged on


user does not have appropriate access rights. If lockForUpdate is true, the
user must have read and write access; otherwise, the user must have read
access.

Note After locking a Work Object with VW_WobQueryGetAccessHandle(), you


might want to verify that it still fits the search criteria you specified when
locating the Work Object. The Work Object could have been changed
between the time you located it and the time you locked it.

You must call VW_FreeAccessHandle() when you finish with the access
handle.

VW_WobQueryGetAccessHandle() is usually called from an administration


program that locates Work Objects or obtains information about Work Objects.

Syntax:
VW_Error FAR PASCAL VW_WobQueryGetAccessHandle
(VW_WobQueryHandle wobQueryHandle,
unsigned int queryIndex,
VW_Boolean lockForUpdate,
VW_WobAccessHandle *wobAccessHandle);

Input Parameters:
VW_WobQueryHandle wobQueryHandle
Handle to the WorkObjectQuery object. Obtained by a call to
VW_WobQueryCreate().

unsigned int queryIndex


Supplied by the programmer. Index value returned from
VW_WobQueryExecute() that identifies a specific Work

188 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_WobQueryGetAccessHandle

Object. queryIndex must be in the range 0 to queryCount -1.


queryCount is also returned from VW_WobQueryExecute().

VW_Boolean lockForUpdate
Supplied by the programmer. If true, the Work Object is
locked in the Work Queue. If the Work Object is not locked,
the returned handle can only be used to read fields from the
Work Object.

Output Parameters:
VW_WobAccessHandle *wobAccessHandle
Returned access handle.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error (FAR PASCAL
*VW_WobQueryGetAccessHandleProcType)
(VW_WobQueryHandle,
unsigned int,
VW_Boolean,
VW_WobAccessHandle *);

December 1996 Work Performer Developer’s Guide 189


DLL Work Performers
VW_WobQueryInstrSheet

VW_WobQueryInstrSheet
This function returns the name of the Instruction Sheet that is currently
processing the Work Object identified by wobQueryHandle.

You must call VW_WobQueryExecute() prior to calling this function.

VW_WobQueryInstrSheet() is usually called from an administration program


that locates Work Objects or obtains information about Work Objects.

Syntax:
VW_Error FAR PASCAL VW_WobQueryInstrSheet
(VW_WobQueryHandle wobQueryHandle,
unsigned int queryIndex,
VW_InstrSheetNameType instrSheetName);

Input Parameters:
VW_WobQueryHandle wobQueryHandle
Handle to the WorkObjectQuery object. Obtained by a call to
VW_WobQueryCreate().

unsigned int queryIndex


Supplied by the programmer. Index value that identifies a
specific Work Object returned from VW_WobQueryExecute().
queryIndex must be in the range 0 to queryCount -1.
queryCount is also returned from VW_WobQueryExecute().

Output Parameters:
VW_InstrSheetNameType instrSheetName
The name of the Instruction Sheet currently processing the
Work Object.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error(FAR PASCAL *VW_WobQueryInstrSheetProcType)
(VW_WobQueryHandle,
unsigned int,
VW_InstrSheetNameType);

190 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_WobQueryInstrSheet

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

December 1996 Work Performer Developer’s Guide 191


DLL Work Performers
VW_WobQueryOperation

VW_WobQueryOperation
This function returns the name of the next Operation that will process the
Work Object identified by queryIndex. You must call VW_WobQueryExecute()
before calling this function.

VW_WobQueryOperation() is usually called from an administration program


that locates Work Objects or obtains information about Work Objects.

Syntax:
VW_Error FAR PASCAL VW_WobQueryOperation
(VW_WobQueryHandle wobQueryHandle,
unsigned int queryIndex,
VW_OperationNameType operationName);

Input Parameters:
VW_WobQueryHandle wobQueryHandle
Handle to the WorkObjectQuery object. Obtained by a call to
VW_WobQueryCreate().

unsigned int queryIndex


Supplied by the programmer. Index value that identifies a
specific Work Object returned from VW_WobQueryExecute().
queryIndex must be in the range 0 to queryCount -1.
queryCount is also returned from VW_WobQueryExecute().

Output Parameters:
VW_OperationNameType operationName
Name of the next Operation that will process the specified
Work Object.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error(FAR PASCAL *VW_WobQueryOperationProcType)
(VW_WobQueryHandle,
unsigned int,
VW_OperationNameType);

192 Work Performer Developer’s Guide December 1996


DLL Work Performers
VW_WobQueryOperation

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

December 1996 Work Performer Developer’s Guide 193


DLL Work Performers
VW_WobQueryWorkPerformerClass

VW_WobQueryWorkPerformerClass
This function returns the name of the Work Performer in whose Work Queue
the Work Object identified by queryIndex is located.

You must call VW_WobQueryExecute() prior to calling this function.

VW_WobQueryWorkPerformerClass() is usually called from an administration


program that locates Work Objects or obtains information about Work Objects.

Syntax:
VW_Error FAR PASCAL VW_WobQueryWorkPerformerClass
(VW_WobQueryHandle wobQueryHandle,
unsigned int queryIndex,
VW_ClassNameType workerClassName);

Input Parameters:
VW_WobQueryHandle wobQueryHandle
Handle to the WorkObjectQuery object. Obtained by a call to
VW_WobQueryCreate().

unsigned int queryIndex


Supplied by the programmer. Index value that identifies a
specific Work Object returned from VW_WobQueryExecute().
queryIndex must be in the range 0 to queryCount -1.
queryCount is also returned from VW_WobQueryExecute().

Output Parameters:
VW_ClassNameType workerClassName
Work Performer class name in whose Work Queue the
specified Work Object is located.

Return Value:
Returns VW_Success if successful. Otherwise, returns an error code.

Function Typedef:
typedef VW_Error(FAR PASCAL
*VW_WobQueryWorkPerformerClassProcType)
(VW_WobQueryHandle,

194 Work Performer Developer’s Guide December 1996


DLL Work Performers
C API Calls

unsigned int,
VW_ClassNameType);

See Also:
See “VWAPISRV API Calls” on page 34 for information about parameters to
VWAPISRV API calls.

December 1996 Work Performer Developer’s Guide 195


DLL Work Performers
C API Calls

196 Work Performer Developer’s Guide December 1996


4
4WorkFlo Script Work Performers

This chapter describes how to write Work Performers that use the WorkFlo
Script adaptor, the data conversion that occurs between WorkFlo Script data
types and Visual WorkFlo data types, and the purpose of each of the Visual
WorkFlo handles that are returned by the WorkFlo Script calls.

This chapter also describes the WorkFlo Script Language calls that you can
use with Visual WorkFlo. These calls fall into one of the following categories:

• Work Object Creation

• Work Performer Start-up

• Queue Management

• Field Manipulation

• Logging and Exception Handling

This chapter assumes you are familiar with the WorkFlo Script Language. For
more information refer to the WorkFlo Script Developer’s Guide. We also
assume you have a basic understanding of the Visual WorkFlo concepts
relating to Work Performers and their Operations.

Using the WorkFlo Script Adaptor


This section contains the information you need to successfully create a
WorkFlo program that can be called by the WorkFlo adaptor.

To run passive WorkFlo scripts in a Visual WorkFlo application requires the


FileNet-provided WorkFlo adaptor. The adaptor name must appear in the
required adaptorName table entry. Your script makes no reference to this file,
but you need it for execution purposes. 16-bit WorkFlo Script Work Performers
use the WFLADAPT.DLL adaptor.

You must include the file VW.WFI in any WorkFlo scripts used in conjunction
with Visual WorkFlo.

December 1996 Work Performer Developer’s Guide 197


WorkFlo Script Work Performers
Using the WorkFlo Script Adaptor

To author calls to a WorkFlo program, specify the adaptor name in the


Properties editor of the Work Performer class browser in Visual WorkFlo/
Composer. The script name (entered in the same editor) must be the name of
the WorkFlo program (script) that contains the Operations to call. The name of
each Operation must match exactly the name of the WorkFlo procedure that is
to be called.

All parameters are passed to the Work Performer from Visual WorkFlo using
the names declared during authoring. The mode of the operation parameters
(in, out, inout) must match the input/output declaration of the WorkFlo
procedure’s parameters.

There is no “main” procedure required. Each procedure is called directly from


Visual WorkFlo and corresponds to an Instruction on an Instruction Sheet.

Data Type Conversion


When a parameter is passed to a Work Performer by the adaptor, the
parameter value is converted to WorkFlo data types using the following table:

Visual WorkFlo data WorkFlo Script


type data type
integer number
float number
boolean boolean
string string
time time

Arrays of these types are also supported. The adaptor passes an array of a
Visual WorkFlo data type as an array of the corresponding WorkFlo Script
data type.

Result parameters are converted from the WorkFlo types to the


corresponding Visual WorkFlo types. Binary zero characters in a WorkFlo
string signal the end of the string when passed to a Visual WorkFlo string.
Truncation occurs on any characters following a binary zero, i.e., they do not
get copied into the Visual WorkFlo string. No change occurs to the original
WorkFlo string.

Returned strings and arrays can be different lengths than their original input
length.

198 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
Visual WorkFlo Handles

Note that if a procedure that is to be used as a passive Operation declares an


input parameter of type number and name F_OperationID, the operation Id
will be set into this parameter.

Visual WorkFlo Handles


The following table describes the purpose of each Visual WorkFlo handle.

F_VWLogonHandle Identifies a Visual WorkFlo session.


F_WorkPerformerHandle Identifies an instance of an active or passive
Work Performer.
F_BrowseHandle Identifies a Work Queue browse session.
F_ObjectHandle Identifies a Work Object within a Work Queue.
F_LockHandle Identifies a locked Work Object within a Work
Queue.
F_OperationHandle Identifies an instance of an Operation being
performed by a passive Work Performer.
F_VWHandle A generic handle that can accept any handle
established by a “VW” prefixed call.

Active or Passive WorkFlo Calls?


You can write WorkFlo scripts to behave as either active or passive Work
Performers. You can include most WorkFlo calls described in this chapter in
active Work Performer scripts. Some calls are valid in either active or passive
Work Performers, some are valid only in active Work Performers, and a few
calls can be used in passive Work Performers only. The mode in which you
can use each of the calls is indicated alongside the call name in the following
tables.

Active calls belong in any WorkFlo script that forms an active Work Performer.
These calls typically access Work Queue contents, manipulate data fields,
and log messages. They use F_WorkPerformerHandle.

Passive calls belong in any WorkFlo script that forms a passive Work
Performer. They establish the handle—F_OperationHandle—used in the
exception and termination calls.

December 1996 Work Performer Developer’s Guide 199


WorkFlo Script Work Performers
WorkFlo Script Example Code

Parameter Passing
Regardless of the mode of the Work Performer, parameter values move
between the script and the Work Object. Operation parameters use the
names declared during the definition process (in the Operation Definition
editor of the Work Performer browser). The parameter direction (in, out, inout)
must match that of the WorkFlo procedure’s parameters (input, output, input
output).

WorkFlo Script Example Code


This section shows example code for active and passive Work Performers
from a simple loan demo.

Active Work Performer


In this example, the ShowPaymentProc shows how to get and set Work
Object fields. The VWGetWork procedure shows how to attach to a queue,
open a work session, and browse the Work Queue.

The following diagram shows the Workflow Instruction Sheet associated with
the code sample that follows the diagram. In the code sample, the ShowPay-
mentProc procedure is called from the VWGetWork procedure when the
Operation name for the Work Object is ShowPayment.

200 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Example Code

include system "display.wfi";


include system "form.wfi";
include system "softkey.wfi";
include system "document.wfi";
include system "folder.wfi";
include system “VW.WFI”

-- Constants
DEBUGMODE : const boolean = false; -- set this to true to activate
-- "display popup" debug statements
FORMFILE : const string = "loandemo.frm";
TAB : const string = repeat(" ",5);

-- Global variables
Error : number;
Terminator : selection;
TermShift : number;
i : number;
WorkObjectIDs : handle[];
SelectedWorkObject : number;
VWLogonHandle : handle;

-- Global variables for values to/from the Work Object


AdjustableRate : number;
CustAddress1 : string;
CustAddress2 : string;
CustName : string;
CustPhone : string;
DownPaymentAmount : number;
FixedRate : number;
InterestRate : number;
LoanDuration : number;
MonthlySalary : number;
MonthlyPayment : number;
PrincipalAmount : number;

December 1996 Work Performer Developer’s Guide 201


WorkFlo Script Work Performers
WorkFlo Script Example Code

PurchaseAmount : number;

-------------------------------------------------------------------
-- ShowPaymentProc procedure
--
-- This procedure displays the Payment Information form and prompts
-- the user to select an interest rate and loan term.
-------------------------------------------------------------------
ShowPaymentProc : procedure;
input LockHandle : handle;

MonthlyPaymentSelection : string;
PaymentInfoFormHandle : handle;
PaymentGridSel : number[1];
SelectedRow : number;
i : number;
j : number;
p : number;

Interest : number;
InterestStr : string;
InterestRateArray : number[];
MonthlyPayments15Array : number[];
MonthlyPayments30Array : number[];
MonthlyPaymentsArray : string[];
NumRows : number;
Yrs15Amt : number;
Yrs15RadioBtn : boolean;
Yrs15AmtStr : string;
Yrs30Amt : number;
Yrs30RadioBtn : boolean;
Yrs30AmtStr : string;

beginproc

202 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Example Code

-- for debugging, set the DEBUGMODE constant at the top of the program.
if DEBUGMODE = true
then
display popup "In ShowPaymentProc, about to open form" wait foruser;
endif;

Yrs15Amt := 0;
Yrs30Amt := 0;
Yrs15RadioBtn := false;
Yrs30RadioBtn := false;

Error := call "Open Form"


set (F_FormFile := FORMFILE,
F_FormName := "PaymentInfo")
get (PaymentInfoFormHandle := F_FormHandle);

if Error <> F_Success


then
displayerror Error;
endif;

-- Get values from Work Object


Error := call "VW Get Fields"
set (F_VWHandle := LockHandle)
get (PrincipalAmount := PrincipalAmt,
FixedRate := FixedRate,
AdjustableRate := AdjustableRate);

if Error <> F_Success


then
displayerror Error;
endif;

-- for debugging, set the DEBUGMODE constant at the top of the program.
if DEBUGMODE = true

December 1996 Work Performer Developer’s Guide 203


WorkFlo Script Work Performers
WorkFlo Script Example Code

then
display popup "Got the fields, about to calculate payments" wait foruser;
endif;

-- The code below calculates payments and interest for 15 and 30 years

NumRows := (FixedRate - AdjustableRate) * 4 + 1;


Interest := AdjustableRate;

for i := 1 to NumRows do
Interest := (AdjustableRate + ((i-1) * .25)) / 1200;
p := (1 + Interest);
Yrs15Amt := (1 + Interest);
Yrs30Amt := (1 + Interest);

for j := 1 to 179 do
Yrs15Amt := Yrs15Amt * p;
endfor;
for j := 1 to 359 do
Yrs30Amt := Yrs30Amt * p;
endfor;
MonthlyPayments15Array[i] := PrincipalAmount * (Interest / (1 - (1 / Yrs15Amt)));
MonthlyPayments30Array[i] := PrincipalAmount * (Interest / (1 - (1 / Yrs30Amt)));
InterestRateArray[i] := AdjustableRate + ((i-1) * .25);

InterestStr := numbertostring(InterestRateArray[i] , "##.00");


Yrs15AmtStr := numbertostring(MonthlyPayments15Array[i], "#####.00");
Yrs30AmtStr := numbertostring(MonthlyPayments30Array[i], "#####.00");

MonthlyPaymentsArray[i] := InterestStr+"%"+TAB+Yrs15AmtStr+TAB+Yrs30AmtStr;
endfor;

-- for debugging, set the DEBUGMODE constant at the top of the program.
if DEBUGMODE = true
then

204 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Example Code

display popup "Payments are calculated, about to execute form" wait foruser;
endif;

Error := call "Setup Box"


set (F_FormHandle := PaymentInfoFormHandle,
F_FieldName := "PaymentGrid",
F_ClearEntries := true,
F_AddEntries := MonthlyPaymentsArray);
displayerror Error;

Error := call "Execute Form"


set (F_FormHandle := PaymentInfoFormHandle,
PrincipalAmount := PrincipalAmount,
Yrs30RadioBtn := true,
F_DisableFieldList := "PrincipalAmount")
get (Yrs15RadioBtn := Yrs15RadioBtn,
Yrs30RadioBtn := Yrs30RadioBtn,
PaymentGridSel := PaymentGrid,
Terminator := F_Terminator,
TermShift := F_TerminatorShifts);

if Error <> F_Success


then
if Error = F_Err_user_cancel
then
display popup "User cancelled" wait foruser;
else
display popup "Unexpected Execute Form error" wait foruser;
displayerror Error;

-- If the procedure/Operation WAS NOT completed successfully, you must


-- Return the Work Object to make it available to other users and tell
-- it to repeat the same Operation in the Instruction Sheet (i.e. it was
-- not processed so it must repeat that step in the Instruction Sheet).
-- Set F_Unprocessed = true to specify that the Work Object was not processed,

December 1996 Work Performer Developer’s Guide 205


WorkFlo Script Work Performers
WorkFlo Script Example Code

-- and should repeat the same Operation.

Error := call "VW Return Work Object"


set (F_LockHandle := LockHandle,
F_Unprocessed := true);
if Error <> F_Success
then
displayerror Error;
exitproc;
endif;
exitproc;
endif; -- if Error = F_Err_user_cancel
endif; -- if Error <> F_Success

-- for debugging, set the DEBUGMODE constant at the top of the program.
if DEBUGMODE = true
then
display popup "Selection number is: ", PaymentGridSel[1] wait foruser;
endif;

SelectedRow := PaymentGridSel[1];

InterestRate := InterestRateArray[SelectedRow];

if Yrs15RadioBtn = true
then
MonthlyPayment := MonthlyPayments15Array[SelectedRow];
LoanDuration := 15;
elsif Yrs30RadioBtn = true
then
MonthlyPayment := MonthlyPayments30Array[SelectedRow];
LoanDuration := 30;
endif;

206 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Example Code

MonthlyPayment := int(MonthlyPayment*100+0.5)/100;

-- for debugging, set the DEBUGMODE constant at the top of the program.
if DEBUGMODE = true
then
display popup "Interest Rate: ",InterestRate," Monthly Payment: ",MonthlyPayment,"
Loan Duration: ",LoanDuration wait foruser;
display popup "About to Set Fields in the Work Object." wait foruser;
endif;
-- Use the selected values and set the corresponding data fields in the Work Object.
Error := call "VW Set Fields"
set (F_VWHandle := LockHandle,
LoanDuration := LoanDuration,
InterestRate := InterestRate,
MonthlyPayment := MonthlyPayment);

if Error <> F_Success


then
displayerror Error;

-- If the procedure/Operation WAS NOT completed successfully, you must


-- Return the Work Object to make it available to other users and tell
-- it to repeat the same Operation in the Instruction Sheet (i.e. it was
-- not processed so it must repeat that step in the Instruction Sheet).
-- Set F_Unprocessed = true to specify that the Work Object was not processed,
-- and should repeat the same Operation.

Error := call "VW Return Work Object"


set (F_LockHandle := LockHandle,
F_Unprocessed := true);

if Error <> F_Success


then
displayerror Error;
exitproc;

December 1996 Work Performer Developer’s Guide 207


WorkFlo Script Work Performers
WorkFlo Script Example Code

endif;
exitproc;
endif;

-- for debugging, set the DEBUGMODE constant at the top of the program.
if DEBUGMODE = true
then
display popup "About to Return the Work Object." wait foruser;
endif;

-- If the Operation/procedure WAS completed successfully, you must Return


-- the Work Object to make it available to other users and tell it to continue
-- to the next step in the Instruction Sheet.
-- Set F_Unprocessed = false (this is the default, so it is not even required that
-- you include this in the Set clause) to specify that the Work Object was processed,
-- and should continue to the next Operation in the Instruction Sheet.

Error := call "VW Return Work Object"


set (F_LockHandle := LockHandle,
F_Unprocessed := false); -- default is false, so this parameter
-- is not required in this case.
- -- This call could also be written as
-- Error := call "VW Return Work Object"
-- set (F_LockHandle := LockHandle);

if Error <> F_Success


then
displayerror Error;
endif;

Error := call "Close Form"


set (F_FormHandle := PaymentInfoFormHandle);

displayerror Error;
endproc;

208 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Example Code

-------------------------------------------------------------------
-- VWGetWork procedure
--
--This procedure gets Work Objects from Visual WorkFlo.
-- It handles initiating the conversation with Visual WorkFlo,
--getting the Work Objects out of the queue, and calling a WorkFlo
--procedure based on the Operation to perform.
-------------------------------------------------------------------
VWGetWork : procedure;

BrowseHandle : handle; -- Handle to identify the Browse Session


ExitProgram : boolean; -- Tells if the user wants to exit
LockHandle : handle; -- Handle to identify the Work Object that has been fetched
NumWorkObjects : number; -- Number of Work Objects in the queue
OperationName : string; -- The next Operation a Work Object is queued for
WPHandle : handle; -- Handle to identify this active Work Performer
WorkObjectHandle : handle; -- Handle to each Work Object (put in an array of handles)
WorkObjectList : string[]; -- Used to store list of Work Objects to display
-- in the InBasket
WorkObjectListNull : string[]; -- Used to null out the array of the list of Work Objects
-- so they won't appear in the InBasket again.
QueueHandle : handle; -- Handle to identify the queue

beginproc

-- for debugging, set the DEBUGMODE constant at the top of the program.
if DEBUGMODE = true
then
display popup "In VWGetWork, about to Open Work Session" wait foruser;
endif;

ExitProgram := false; -- this procedure loops until the user selects


-- ExitProgram from the DisplayInBasket procedure form.

-- The active Work Performer must attach to a Work Queue to obtain

December 1996 Work Performer Developer’s Guide 209


WorkFlo Script Work Performers
WorkFlo Script Example Code

-- a handle for the queue.


Error := call "VW Attach To Work Queue"
set (F_VWLogonHandle := VWLogonHandle,
F_WorkPerformerClass := "WflLoanPaymentWP")
get (QueueHandle := F_WorkQueueHandle);

if Error <> F_Success


then
displayerror Error;
exitproc;
endif;

-- After attaching to a Work Queue, the active Work Performer must register
-- with the system as an active Work Performer, specifying the Work Performer class
-- to register as. A handle for the Work Performer is returned.
Error := call "VW Open Work Session"
set (F_WorkQueueHandle := QueueHandle)
get (WPHandle := F_WorkPerformerHandle);

if Error <> F_Success


then
displayerror Error;
exitproc;
endif;

do -- Start a loop until the user selects ExitProgram from the


-- DisplayInBasket procedure form or there is no more work in the queue.

-- for debugging, set the DEBUGMODE constant at the top of the program.
if DEBUGMODE = true
then
display popup "In VWGetWork, about to Open Browse Session and
Browse the Work Queue" wait foruser;
endif;
-- Begin browsing the Work Queue. Pass the handle from "VW Open Work Session" and

210 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Example Code

-- the maximum number of Work Objects that you want to look at (0 indicates all).
-- You get back a handle to the browse session, and also the number of Work
-- Objects in this queue.

Error := call "VW Open Browse Session"


set (F_WorkPerformerHandle := WPHandle,
F_MaxWorkObjectCount := 0)
get (BrowseHandle := F_BrowseHandle,
NumWorkObjects := F_WorkObjectCount);

if Error <> F_Success


then
displayerror Error;
exitproc;
endif;

-- If there are still Work Objects in the queue that can be processed
if NumWorkObjects > 0
then -- proceed with all the code

-- Loop through all the Work Objects in the queue (pass it the browse handle)
-- and get back the next Operation that that Work Object is queued for, get
-- values from the Work Object data fields, and get an object handle for each
-- object and fill some arrays with this information.

for i := 1 to NumWorkObjects do
Error := call "VW Browse Work Queue"
set (F_BrowseHandle := BrowseHandle)
get (OperationName := F_OperationName,
WorkObjectHandle := F_ObjectHandle,
CustName := CustName,
MonthlySalary := MonthlySalary);
if Error <> F_Success
then
displayerror Error;

December 1996 Work Performer Developer’s Guide 211


WorkFlo Script Work Performers
WorkFlo Script Example Code

exitproc;
endif;

WorkObjectList[i] :=
CustName+TAB+convert(MonthlySalary,string)+TAB+OperationName;
WorkObjectIDs[i] := WorkObjectHandle;
endfor;

-- Display the list of Work Objects to the user and get back their selection
-- in the variable SelectedWorkObject.
-- DisplayInBasket also allows the user to click on a button called ExitProgram
-- that is used here to determine if the program should break out of
-- this procedure.

Error := call DisplayInBasket


set (WorkObjectList := WorkObjectList)
get (SelectedWorkObject := SelectedWorkObject,
ExitProgram := ExitProgram);

if Error <> F_Success


then
displayerror Error;
exitproc;
endif;

if ExitProgram = true
then
-- for debugging, set the DEBUGMODE constant at the top of the program.
if DEBUGMODE = true
then
display popup "User selected Exit, about to cleanup and exit program."
wait foruser;
endif;
-- cleanup handles
Error := call "VW Close Browse Session"

212 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Example Code

set (F_BrowseHandle := BrowseHandle);

if Error <> F_Success


then
displayerror Error;
endif;
nextdo; -- get out of loop because the user selected ExitProgram.
endif;

-- for debugging, set the DEBUGMODE constant at the top of the program.
if DEBUGMODE = true
then
display popup "Browsed the Work Queue, about to Fetch the Work Object"
wait foruser;
endif;

-- When you know the Work Object that the user selected, you must "fetch" the
-- Work Object (which marks it as locked in the queue) so nobody else can access it.
-- Up to that point, the list is merely a snapshot of what was in the queue when the
-- browse was performed. Once the object is fetched, you can manipulate its Work
-- Object data field values.

-- Pass the Work Object that was selected by referencing the cell in the array
-- of Work Object Handles (here it is WorkObjectIDs[SelectedWorkObject]).
-- When you fetch the Work Object, you get a LockHandle back that you can use
-- to reference that fetched Work Object until you Return the Work Object.
-- You also get back the next Operation that this Work Object is queued for
-- in OperationName.

Error := call "VW Fetch Work Object"


set (F_ObjectHandle := WorkObjectIDs[SelectedWorkObject])
get (LockHandle := F_LockHandle,
OperationName := F_OperationName);
if Error <> F_Success
then

December 1996 Work Performer Developer’s Guide 213


WorkFlo Script Work Performers
WorkFlo Script Example Code

displayerror Error;
exitproc;
endif;

-- for debugging, set the DEBUGMODE constant at the top of the program.
if DEBUGMODE = true
then
display popup "The Work Object has been fetched successfully and is locked."
wait foruser;
display popup "Operation Name is: ",OperationName wait foruser;
endif;

-- Begin an if/then/else statement to determine which WorkFlo procedure to call


-- based on the Operation name. The procedure name does not have to be the same
-- as the Operation name, but it makes it easier to debug if they are the same name.
-- Pass the LockHandle to your WorkFlo procedure.

if OperationName = "GetCustomerInfo"
then
Error := call GetCustInfoProc
set (LockHandle := LockHandle);
if Error <> F_Success
then
displayerror Error;
endif;
elsif OperationName = "GetLoanInfo"
then
Error := call GetLoanInfoProc
set (LockHandle := LockHandle);
if Error <> F_Success
then
displayerror Error;
endif;
elsif OperationName = "ShowPayment"
then

214 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Example Code

Error := call ShowPaymentProc


set (LockHandle := LockHandle);
if Error <> F_Success
then
displayerror Error;
endif;
else -- No procedure for this operation
display popup "Unknown operation in WorkFlo Loan Active Demo." wait foruser;

-- If the procedure/Operation WAS NOT completed successfully, you must


-- Return the Work Object to make it available to other users and tell
-- it to repeat the same Operation in the Instruction Sheet (i.e. it was
-- not processed so it must repeat that step in the Instruction Sheet).
-- Set F_Unprocessed = true to specify that the Work Object was not processed,
-- and should repeat the same Operation.

Error := call "VW Return Work Object"


set (F_LockHandle := LockHandle,
F_Unprocessed := true);

if Error <> F_Success


then
displayerror Error;
exitproc;
endif;
endif; -- calling the appropriate procedure for the Operation needed.

else -- else there are no more WorkObjects (NumWorkObjects is not > 0)


display popup "There's no more work!" wait foruser;
ExitProgram := true;
endif;

-- End browsing the work queue and free the browse handle.

Error := call "VW Close Browse Session"

December 1996 Work Performer Developer’s Guide 215


WorkFlo Script Work Performers
WorkFlo Script Example Code

set (F_BrowseHandle := BrowseHandle);

if Error <> F_Success


then
displayerror Error;
exitproc;
endif;

-- Cleanup the array (WorkObjectList) so the strings with the list of


-- Work Objects have only the items found in the "VW Browse Queue"
-- and old items in WorkObjectList don't appear in the InBasket again.

WorkObjectList := WorkObjectListNull;

until ExitProgram = true


enddo; -- do loop to continue searching/browsing the queue

-- When the program exits, it must cleanup and let Visual WorkFlo
-- know it is leaving. Call "VW Close Work Session" to free
-- the WorkPerformerHandle (WPHandle in this case) and
--”VW Detach From Work Queue” to free the queue handle.

Error := call "VW Close Work Session"


set (F_WorkPerformerHandle := WPHandle);

if Error <> F_Success


then
displayerror Error;
exitproc;
endif;

Error := call "VW Detach From Work Queue"


set (F_WorkQueueHandle := QueueHandle);

if Error <> F_Success

216 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Example Code

then
displayerror Error;
exitproc;
endif;
endproc;

Passive Work Performer Example


In this example, the ShowPayment procedure shows how to get and set
Operation parameters. The Main procedure is not required; it is included to
make compiling the example easier.

include system "display.wfi";


include system "form.wfi";
include system "softkey.wfi";
include system "document.wfi";
include system "folder.wfi";

-- Constants
DEBUGMODE : const boolean = false; -- set this to true to activate
-- "display popup" debug statements
FORMFILE : const string = "loandemo.frm";
TAB : const string = repeat(" ",5);

-- Global variables
Error : number;
Terminator : selection;
TermShift : number;

-------------------------------------------------------------------
-- ShowPayment procedure
--
-- This procedure displays the Payment Information form and prompts
-- the user to select an interest rate and loan term.
-------------------------------------------------------------------
ShowPayment : procedure;

December 1996 Work Performer Developer’s Guide 217


WorkFlo Script Work Performers
WorkFlo Script Example Code

input PrincipalAmt : number;


input FixedRate : number;
input AdjustableRate : number;
output LoanDuration : number;
output InterestRate : number;
output MonthlyPayment : number;

-- The above are the operation parameters that are passed in or sent out
-- of this procedure from/to the Visual WorkFlo Work Performer Operation
-- parameters which get/set the data fields in the Work Object.

MonthlyPaymentSelection : string;
PaymentInfoFormHandle : handle;
PaymentGridSel : number[1];
SelectedRow : number;
i : number;
j : number;
p : number;

Interest : number;
InterestStr : string;
InterestRateNumArray : number[];
MonthlyPayments15Array : number[];
MonthlyPayments30Array : number[];
MonthlyPaymentsArray : string[];
NumRows : number;
Yrs15Amt : number;
Yrs15RadioBtn : boolean;
Yrs15Str : string;
Yrs30Amt : number;
Yrs30RadioBtn : boolean;
Yrs30Str : string;
TempStr1 : string;

beginproc

218 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Example Code

-- for debugging, set the DEBUGMODE constant at the top of the program.
if DEBUGMODE = true
then
display popup "In ShowPayment, about to open form" wait foruser;
endif;

Yrs15Amt := 0;
Yrs30Amt := 0;
Yrs15RadioBtn := false;
Yrs30RadioBtn := false;

Error := call "Open Form"


set (F_FormFile := FORMFILE,
F_FormName := "PaymentInfo")
get (PaymentInfoFormHandle := F_FormHandle);

if Error <> F_Success


then
displayerror Error;
endif;

-- for debugging, set the DEBUGMODE constant at the top of the program.
if DEBUGMODE = true
then
display popup "About to calculate payments" wait foruser;
endif;

-- The code below calculates payments and interest for 15 and 30 years

NumRows := (FixedRate - AdjustableRate) * 4 + 1;


Interest := AdjustableRate;
for i := 1 to NumRows do
Interest := (AdjustableRate + ((i-1) * .25)) / 1200;
p := (1 + Interest);
Yrs15Amt := (1 + Interest);

December 1996 Work Performer Developer’s Guide 219


WorkFlo Script Work Performers
WorkFlo Script Example Code

Yrs30Amt := (1 + Interest);

for j := 1 to 179 do
Yrs15Amt := Yrs15Amt * p;
endfor;
for j := 1 to 359 do
Yrs30Amt := Yrs30Amt * p;
endfor;
MonthlyPayments15Array[i] := PrincipalAmt * (Interest / (1 - (1 / Yrs15Amt)));
MonthlyPayments30Array[i] := PrincipalAmt * (Interest / (1 - (1 / Yrs30Amt)));
InterestRateNumArray[i] := AdjustableRate + ((i-1) * .25);

InterestStr := numbertostring(InterestRateNumArray[i] , "##.00");


Yrs15Str := numbertostring(MonthlyPayments15Array[i], "#####.00");
Yrs30Str := numbertostring(MonthlyPayments30Array[i], "#####.00");

MonthlyPaymentsArray[i] := InterestStr+"%"+TAB+Yrs15Str+TAB+Yrs30Str;

endfor;

-- for debugging, set the DEBUGMODE constant at the top of the program.
if DEBUGMODE = true
then
display popup "Payments are calculated, about to execute form" wait foruser;
endif;

Error := call "Setup Box"


set (F_FormHandle := PaymentInfoFormHandle,
F_FieldName := "PaymentGrid",
F_ClearEntries := true,
F_AddEntries := MonthlyPaymentsArray);
displayerror Error;

Error := call "Execute Form"


set (F_FormHandle := PaymentInfoFormHandle,

220 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Example Code

PrincipalAmount := PrincipalAmt,
Yrs30RadioBtn := true,
F_DisableFieldList := "PrincipalAmount")
get (Yrs15RadioBtn := Yrs15RadioBtn,
Yrs30RadioBtn := Yrs30RadioBtn,
PaymentGridSel := PaymentGrid,
Terminator := F_Terminator,
TermShift := F_TerminatorShifts);

if Error <> F_Success


then
if Error = F_Err_user_cancel
then
display popup "User cancelled" wait foruser;
else
display popup "Unexpected Execute Form error" wait foruser;
displayerror Error;
-- If the procedure/operation was not completed successfully, you might
-- want to raise an exception here.
exitproc;
endif; -- if Error = F_Err_user_cancel
endif; -- if Error <> F_Success

-- for debugging, set the DEBUGMODE constant at the top of the program.
if DEBUGMODE = true
then
display popup "Selection number is: ", PaymentGridSel[1] wait foruser;
endif;

SelectedRow := PaymentGridSel[1];
-- The next few lines of code set the variables that are output parameters from this
-- WorkFlo procedure. These parameters are returned as Operation parameters to
-- Visual WorkFlo and update the data fields in the Work Object.

-- Sets the InterestRate output parameter.

December 1996 Work Performer Developer’s Guide 221


WorkFlo Script Work Performers
WorkFlo Script Example Code

InterestRate := InterestRateNumArray[SelectedRow];

-- Sets the MonthlyPayment and LoanDuration output parameters.


if Yrs15RadioBtn = true
then
MonthlyPayment := MonthlyPayments15Array[SelectedRow];
LoanDuration := 15;
elsif Yrs30RadioBtn = true
then
MonthlyPayment := MonthlyPayments30Array[SelectedRow];
LoanDuration := 30;
endif;

-- for debugging, set the DEBUGMODE constant at the top of the program.
if DEBUGMODE = true
then
display popup "Interest Rate: ",InterestRate," Monthly Payment: ",MonthlyPayment,"
Loan Duration: ",LoanDuration wait foruser;
endif;

MonthlyPayment := int(MonthlyPayment*100+0.5)/100;

-- for debugging, set the DEBUGMODE constant at the top of the program.
if DEBUGMODE = true
then
display popup "TempStr1: ",TempStr1," Monthly Payment: ",
MonthlyPayment wait foruser;
endif;

Error := call "Close Form"


set (F_FormHandle := PaymentInfoFormHandle);

displayerror Error;

-- for debugging, set the DEBUGMODE constant at the top of the program.

222 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Example Code

if DEBUGMODE = true
then
display popup "When you click on OK, the WorkFlo procedure/operation ends."
wait foruser;
endif;
endproc;

-------------------------------------------------------------------
-- MAIN procedure
-- This is the Main procedure. It has no code to execute. It is here
-- so you can compile this script from the WorkFlo debugger/compiler
-- without having to set Execution Options to Compile Only.
--
-- NOTE: A WorkFlo script written as a Passive Work Performer does
-- not need a "Main" procedure. It does not need to be able
-- to run from the WorkFlo compiler/debugger (it only needs
-- to compile successfully). It's sort of like a .DLL in Windows
-- (a reusable set of subroutines that can be called at runtime).
-- You can't step through procedures called as operations in a
-- Passive Work Performer because the script is in WorkFlo runtime
-- mode. For this reason, there is a constant at the top of this
-- program called DEBUGMODE. If it is set to true, it will display
-- popup messages to tell you which part of the procedure is
-- currently executing. If it is set to false, no display popups
-- will appear.
-- You could have Main call each of the other procedures (you
-- may need to prompt for input before calling some of the
-- procedures) in order to test/debug the calls before using them
-- as WorkPerformer operations.
-------------------------------------------------------------------
Main : procedure;

beginproc
-- Nothing to do, just here to let you compile easier.
endproc;

December 1996 Work Performer Developer’s Guide 223


WorkFlo Script Work Performers
WorkFlo Script Calls

WorkFlo Script Calls


Work Performer Start-up
Passive Work Performers execute when they are called from within Visual
WorkFlo. An active Work Performer must be manually started by the user at
the desktop after Visual WorkFlo has been started. (Active Work Performers
that are part of a role are started by Visual WorkFlo/Performer.)

Establish and Terminate a Visual WorkFlo Session


The “VW Logon” call establishes a unique identifier for the session. This
identifier is used in subsequent Visual WorkFlo calls. The WorkFlo script must
call “VW Logon” once as its first action, and call “VW Logoff” as its last action.

Note that you only need to call “VW Logon” once per WorkFlo script, not once
per Visual WorkFlo call. To terminate a Visual WorkFlo session properly, you
must call “VW Logoff.” Failure to do so will prevent Visual WorkFlo DLLs and
resources from being released.

call “VW Logon” (Active or Passive)


set None.
get F_VWLogonHandle Handle. The unique identifier of a
Visual WorkFlo session.

call “VW Logoff” (Active or Passive)


set F_VWLogonHandle Handle: required. The unique identifier of
a Visual WorkFlo session returned from
“VW Logon”.
get None.

Active Work Performers


Visual WorkFlo only becomes aware of an active WorkFlo Work Performer
when the “VW Open Work Session” call has executed.

Use the “VW Attach To Work Queue” and “VW Open Work Session” calls to
start up and register an active Work Performer. Until the script executes these
calls, the Visual WorkFlo application has no knowledge of the Work
Performer’s existence. The handle returned from “VW Open Work Session”
identifies an active Work Performer instance and is used in many other calls.

224 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Calls

You must call “VW Open Work Session” before attempting to browse through
Work Queues—until you establish F_WorkPerformerHandle, you have no
access to the Work Queues. When finished with Visual WorkFlo processing,
you must call “VW Close Work Session” to release resources.

To establish a handle to the Work Queue you want to browse, call “VW Attach
To Work Queue.” When you are finished with the Work Queue, you must call
“VW Detach From Work Queue” to release resources.

See “Complete Work Queue Processing” on page 240 for information on how
to unregister a Work Performer.

VW Attach To Work Queue

call “VW Attach To Work Queue” (Active)


set F_VWLogonHandle Handle: required. Returned from “VW
Logon.”
F_WorkPerformerClass String: required. Name of the Work
Performer class to use (the Work
Queue name is the same as the Work
Performer class name).
get F_WorkQueueHandle Handle. Identifies a Work Queue.

VW Open Work Session

call “VW Open Work Session” (Active)


set F_WorkQueueHandle Handle: required. Returned from “VW
Attach To Work Queue.”
get F_WorkPerformerHandle Handle. Identifies an instance of an
active Work Performer.

Passive Work Performers


The Visual WorkFlo/Performer user controls when a passive Work Performer
executes. To request services of Visual WorkFlo, a passive Work Performer
must establish a handle to identify the instance of the Work Performer and the
Work Object it processes.

The “VW Get Work Performer Handle” call returns a handle to a passive Work
Performer, used in subsequent calls to access Work Performer fields. The

December 1996 Work Performer Developer’s Guide 225


WorkFlo Script Work Performers
WorkFlo Script Calls

“VW Get Operation Handle” call returns a handle used in subsequent calls to
access Operation parameters.

If your procedure uses any WorkFlo call that uses the F_OperationHandle
(i.e., your procedure uses the services provided for passive Work Performers)
your procedure must include an input variable called F_OperationID of type
number. You’ll notice that the required set parameter in “VW Get Operation
Handle” is also called F_OperationID. The WorkFlo adaptor passes a value
into the variable and you set the parameter equal to the variable.

VW Get Operation Handle

call “VW Get Operation Handle” (Passive)


set F_OperationID Number: required. Provided by the adaptor
to an input variable named F_OperationID.
get F_OperationHandle Handle. Identifies an instance of a passive
Work Performer.

VW Get Work Performer Handle

call “VW Get Work Performer Handle” (Passive)


set F_OperationHandle Handle: required. The Operation
handle of a passive Work Performer.
get F_WorkPerformerHandle Handle. Identifies an instance of a
passive Work Performer.

This is an example of the call to “VW Get OperationHandle.”

input F_OperationID: number;


PassiveHandle: handle;
...
...
call "VW Get Operation Handle"
set (F_OperationID := F_OperationID)
get (PassiveHandle := F_OperationHandle);

226 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Calls

Work Object Creation and Termination


These WorkFlo calls create and terminate Work Objects. Both active and
passive Work Performers can use them.

Work Object Creation


You can use “VW Create Work Object” to create a Work Object of a specified
class, and supply it with data values. Your WorkFlo script might scan and
index incoming loan applications and you would need to pass the applicant’s
information into the Visual WorkFlo loan application for further processing.
Your WorkFlo script can capture the information (from indexing) and provide it
to Visual WorkFlo as Work Object field values.

By specifying the Work Class name, you determine the type of Work Object
created. Any values assigned to the Work Object’s fields override its initial
field values, as specified in the Field Definition of the Work Object class.

Dispatch software sends the newly created Work Object to the Work Queue of
the first Instruction in its “Workflow” Instruction Sheet so that processing can
begin.

VW Create Work Object

call “VW Create Work Object” (Active or Passive)


set F_WorkClassName String: required. Specifies the class of
Work Object to create.
F_VWLogonHandle Handle: required. Specifies the unique
identifier of a Visual WorkFlo session,
returned from the “VW Logon” call.
<Work Object fields> Work Object field names. The values
specified here override the Work Object’s
initial values, and must be compatible
with the Work Object’s data types.
get None.

December 1996 Work Performer Developer’s Guide 227


WorkFlo Script Work Performers
WorkFlo Script Calls

Work Object Termination


“VW Terminate Work Object” deletes a Work Object. When you use this call in
a passive Work Performer, identify the target Work Object by specifying
F_OperationHandle. In an active Work Performer, the target must be a locked
Work Object, identified by F_LockHandle. You must specify one of these
handles.

VW Terminate Work Object

call “VW Terminate Work Object” (Active or Passive)


set F_LockHandle Handle: required in an active Work
Performer. Returned from the “VW Fetch
Work Object” call. Do not use in
conjunction with F_OperationHandle.
F_OperationHandle Handle: required in a passive Work
Performer. Returned from the “VW Get
Operation Handle” call. Do not use in
conjunction with F_LockHandle.
get None.

Queue Management
Each Work Performer class has its own Work Queue. All Work Performers
within the same class share the same Work Queue. Before you can select a
Work Object from the Work Queue, you must do the following in your active
Work Performer WorkFlo script:

• Establish a handle for the browse session and get a snapshot of the
number of Work Objects in the Work Queue (“VW Open Browse
Session”).

• Establish a handle for each Work Object in the Work Queue and see its
contents (“VW Browse Work Queue”).

• Provide an interface for the user to select a Work Object from the Work
Queue, or use another method to determine which Work Object(s) to
select.

• Lock the selected Work Object (“VW Fetch Work Object”).

228 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Calls

Establish a Browse Handle


The “VW Open Browse Session” call establishes a handle for a browse
session (F_BrowseHandle). You can have multiple active browse sessions at
any one time, in which case you would issue the call once per active session.
This call also returns the number of unlocked (i.e., available) Work Objects in
the Work Queue. You can limit the number of Work Objects returned from the
Work Queue, using the parameter F_MaxWorkObjectCount.

VW Open Browse Session


This call establishes a browse session handle and returns the number of
Work Objects in the Work Queue.

Note This call takes a snapshot of the queue contents; any subsequent changes to
the queue are not reflected in results from associated “VW Browse Work
Queue” calls.

When you are finished browsing the Work Queue, you must use the “VW
Close Browse Session” call to release F_BrowseHandle.

call “VW Open Browse Session” (Active)


set F_WorkPerformerHandle Handle: required. Returned from the
“VW Open Work Session” call.
Identifies the Work Queue to browse.
F_MaxWorkObjectCount Number. Specifies the maximum
number of Work Objects to return from
the Work Queue. The default is no
limit.
F_PreSelectionRule String. Specifies the pre-selection rule
expression to be used for this browse
session. Use an empty string to
indicate that any authored pre-
selection rule is to be ignored.
F_SelectionRule String. Specifies the selection rule
expression to be used for this browse
session. Use an empty string to
indicate that any authored selection
rule is to be ignored.

December 1996 Work Performer Developer’s Guide 229


WorkFlo Script Work Performers
WorkFlo Script Calls

set F_SortRuleExpressions String array. Required if F_SortRule-


(cont) Lengths is specified. Specifies the sort
rule expressions to be used for this
browse session. The order of the
expressions in the array is the order in
which the expressions are used for
sorting. Use a null array to indicate that
any authored sort rules are to be
ignored. The number of elements in
this array must match the number in
F_SortRuleLengths.
F_SortRuleLengths Number array. Required if F_SortRule-
Expressions is specified. Specifies the
number and length of the sort rules to
be used for this browse session, and
must match the number of elements in
F_SortRuleExpressions.
The number at any index in this array
indicates the length for the string
expression at the same index in
F_SortRuleExpressions, and is
ignored for all other types of
expressions. Use a null array to
indicate that any authored sort rules
are to be ignored.
get F_BrowseHandle Handle.
F_WorkObjectCount Number. The number of Work Objects
to be browsed.

For more information about pre-selection rules, selection rules, sort rules, and
expressions allowed for each, see the “Specify Work Queue Rules” section in
the “Creating and Modifying Work Performer Classes” chapter of the Visual
WorkFlo/Composer Handbook.

Establish an Object Handle


You must establish a handle for each Work Object in the Work Queue that you
want to access (F_ObjectHandle). The “VW Browse Work Queue” call
establishes F_ObjectHandle. It also returns the values for any specified Work
Object data fields and the name of the next Operation to execute on the Work
Object. Issue this call once for each Work Object you want to access.

230 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Calls

To access multiple Work Objects in the Work Queue, put the “VW Browse
Work Queue” call inside a loop. To see every returned Work Object, limit the
loop by the value of F_WorkObjectCount (returned from “VW Open Browse
Session”). To restrict the number of Work Objects seen, limit the loop by the
desired number. To avoid an error, this number must be less than
F_WorkObjectCount.

VW Browse Work Queue


“VW Browse Work Queue” returns a handle for the Work Object, the values in
the specified Work Queue fields, and the name of the next Operation to run
against the Work Object. Note that to successfully use this call, you must
know the Work Object field names. No WorkFlo call provides you with this
information.

call “VW Browse Work Queue” (Active)


set F_BrowseHandle Handle: required. Returned from
the “VW Open Browse Session”
call. Identifies the browse
session.
get F_ObjectHandle Handle. Identifies a single Work
Object in the Work Queue.
F_OperationName String. The next Operation to be
performed on this Work Object.
<Work Queue fields> Returns the current values in the
specified Work Queue fields.

Lock a Work Object


Before processing a Work Object, you must establish a lock handle for the
Work Object.

VW Fetch Work Object


Use “VW Fetch Work Object” to lock a specific Work Object. It returns the
name of the next Operation to be performed on the Work Object, as well as
the Operation parameters.

Note that only one Work Performer can lock a Work Object at a time. This call
will fail if the Work Object is already locked.

December 1996 Work Performer Developer’s Guide 231


WorkFlo Script Work Performers
WorkFlo Script Calls

When you have finished processing a locked Work Object, call “VW Return
Work Object” to release F_ObjectHandle.

call “VW Fetch Work Object” (Active)


set F_ObjectHandle Handle: required. Returned from the
“VW Browse Work Queue” call.
get F_LockHandle Handle. Identifies a locked Work
Object.
F_OperationName String. The next Operation to be
performed on this Work Object.
<Operation parameters> Returns the current values in the
specified Operation parameters.

Field Manipulation
Using the calls described in this section you can set and get Work Performer
fields and Operation parameters. You can also get Work Queue fields.

You must lock a Work Object to read or write its associated Operation
parameter fields. You can read Work Queue fields, and you can read and write
Work Performer fields.

Note that when you call “VW Set Fields” or “VW Get Fields” from a passive
WorkFlo script, you can access Work Performer fields only.

The direction specified in the Operation Definition editor also affects your
access to the Operation parameters.

• You can get an Operation parameter defined with a direction of in.

• You can set an Operation parameter defined with a direction of out.

• You can set or get an Operation parameter defined with a direction of


inout.

232 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Calls

Summarized as follows:

This script action needs this Operation parameter direction


Get in or inout
Set out or inout

Access Instance Values


You can read and write Operation parameters and Work Performer fields. You
can read Work Queue fields.

You must lock a Work Object to read or write its associated Operation
parameter fields. Use the “VW Fetch Work Object” call, described on
page 231, to establish a lock handle—F_LockHandle. The parameters you
can access belong to the next Operation that will execute against the locked
Work Object.

Before you lock a Work Object you can read its fields, and you can read and
write Work Performer fields.

Note that you cannot set the values of Work Object data fields from within
WorkFlo, except when you initially create a Work Object with the “VW Create
Work Object” call.

This table identifies your access rights depending upon:

• The state of the Work Object (locked or unlocked).

• The handle used in the call.

• The mode of the WorkFlo script (active or passive).

Access Rights

Work Object Handle Used Access


N/A F_WorkPerformerHandle Get Work Performer fields. (Active
or passive.)
N/A F_WorkPerformerHandle Set Work Performer fields. (Active
or passive.)
N/A F_ObjectHandle Get Work Queue fields. (Active.)

December 1996 Work Performer Developer’s Guide 233


WorkFlo Script Work Performers
WorkFlo Script Calls

Work Object Handle Used Access


Locked F_LockHandle Get Operation parameters.
(Active.)
Locked F_LockHandle Set Operation parameters.
(Active.)

VW Set Fields

call “VW Set Fields” (Active or Passive)


set F_VWHandle Handle: required. Set this parameter to
the appropriate handle for the action
required.
<Operation parameters> To set Operation parameters, set
F_VWHandle to a lock handle.
The value(s) for specified parameter(s)
in the next Operation to execute on the
specified Work Object. Use on a locked
Work Object only.
Invalid in a call from a passive Work
Performer.
Performs the same operation as setting
<operation parameters> in the “VW
Return Work Object” call.
<Work Performer fields> To set Work Performer fields, set
F_VWHandle to a Work Performer
handle.
The value(s) of specified field(s) in the
Work Performer identified by
F_VWHandle.
get None.

234 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Calls

VW Get Fields

call “VW Get Fields” (Active or Passive)


set F_VWHandle Handle: required. Set this parameter to
the appropriate handle for the action
required.
get <Operation parameters> To get Operation parameters, set
F_VWHandle to a lock handle.
The value(s) of specified parameter(s) in
the next Operation to execute on the
specified Work Object. Use on a locked
Work Object only.
Invalid in a call from a passive Work
Performer.
Performs the same operation as getting
<Operation parameters> in the “VW
Fetch Work Object” call.
<Work Performer fields> To get Work Performer fields, set
F_VWHandle to a Work Performer
handle.
The value(s) of specified field(s) in the
Work Performer identified by
F_VWHandle.
<Work Queue fields> To get Work Queue fields, set
F_VWHandle to an object handle.
The value(s) of specified Work Queue
field(s).
Invalid in a call from a passive Work
Performer.
Performs the same operation as getting
<Work Queue fields> in the “VW Browse
Work Queue” call.

December 1996 Work Performer Developer’s Guide 235


WorkFlo Script Work Performers
WorkFlo Script Calls

Operation Completion
When you have successfully performed the Operation on a locked Work
Object, call “VW Return Work Object” with F_Unprocessed set to false. This
frees F_ObjectHandle, unlocks the Work Object, and releases it to the next
Instruction in its Instruction Sheet. It also sets parameter values in the
Operation identified by the F_OperationName parameter in the “VW Fetch
Work Object” call and sends the Work Object to its next Instruction.

To undo changes made by a Work Performer to a locked Work Object and


return it to its original state, call “VW Return Work Object”, with F_Un-
processed set to true. This unlocks the Work Object, but does not release
F_ObjectHandle. It returns all Work Object fields back to the values they had
at the start of the Operation. If you choose to, you can then re-lock the Work
Object and try again. If you decide against trying again, call “VW Free Handle”
to release F_ObjectHandle.

VW Return Work Object

call “VW Return Work Object” (Active)


set F_LockHandle Handle: required. Returned from the
“VW Fetch Work Object” call.
F_Unprocessed Boolean. When false, releases the
lock handle and the object handle,
sets Operation parameters, and sends
the Work Object to its next Instruction.
Default is false.
When true, releases the lock handle
but not the object handle, and returns
all fields to their original values.
<Operation parameters> Only valid if F_Unprocessed is false.
get None.

236 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Calls

Find Matching Work Objects


You might need to find information about a particular Work Object, such as the
Work Queue in which it is currently waiting. Call “VW Open Object Query
Session” to establish a session in which you define search criteria and get
back the number of matching Work Objects.

Call “VW Work Object Query” to get information about a specific matching
Work Object.

Call “VW Close Object Query Session” to close the session and release the
handle.

VW Open Object Query Session

call “VW Open Object Query Session” (Active)


set F_VWLogonHandle Handle: required. Returned from the “VW
Logon” call.
F_WorkClassName String: required. The class to which the
matching Work Objects must belong.
F_WorkObjectName The name that the matching Work
Objects must have. The data type of this
parameter must correspond to the data
type of the expression used as the
authored Work Object name for the Work
Class.
F_MaxMatchCount Number. The maximum number of
matching Work Objects to return. 0
returns all matches. Default is 1.
get F_ObjectQueryHandle Handle. Used in subsequent calls to
identify the query session.
F_MatchCount Number. The actual number of matches
found.

December 1996 Work Performer Developer’s Guide 237


WorkFlo Script Work Performers
WorkFlo Script Calls

VW Work Object Query

call “VW Work Object Query” (Active)


set F_ObjectQueryHandle Handle: required. Identifies the query
session.
F_MatchIndex Number. The index of the matching
Work Object about which to return
information. Default is 1. Can range
from 1 to the value returned in
F_MatchCount from “VW Open
Object Query Session.”
get F_WorkPerformerClass String. The name of the Work
Performer class that is currently
processing the Work Object, or in
whose queue the Work Object is
waiting.
F_InstructionSheetName String. The name of the current
Instruction Sheet through which the
Work Object is being processed.
F_OperationName String. The name of the Operation
that is currently being executed by the
Work Object.

VW Close Object Query

call “VW Close Object Query Session” (Active)


set F_ObjectQueryHandle Handle: required. Returned from the
“VW Open Object Query” call.
get None.

Work Object Access


You use the “VW Open Object Access Session” call to initiate a session to
perform Work Object access calls. This call returns a handle that can be used
to examine or change Work Object values by passing the handle to “VW Get
Fields” or “VW Set Fields.” The Work Object is identified by F_ObjectHandle or
by the combination of F_ObjectQueryHandle and F_MatchIndex.

238 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Calls

You can only change Work Object values if F_LockForUpdate was true when
“VW Open Object Access Session” was called. Any changes you make are
saved when you call “VW Close Object Access Session”.

You use the “VW Close Object Access Session” call to save any changes
made with calls to “VW Set Fields”, free the handle returned by “VW Open
Object Access Session,” and terminate the Work Object access session.

VW Open Object Access Session

call “VW Open Object Access Session” (Active)


set F_ObjectHandle Handle. The handle for a Work Object
obtained from a browse session.
Required if F_ObjectQueryHandle is not
supplied.
F_ObjectQueryHandle Handle. The handle for a Work Object
query session. Required if F_Object-
Handle is not supplied.
F_MatchIndex Number. The index of the Work Object
from the Work Object query session.
Can only be supplied if F_Object-
QueryHandle is also supplied. Defaults
to 1.
F_LockForUpdate Boolean. If true, the Work Object will be
locked for updating.
get F_ObjectAccessHandle Handle. Handle used to identify the Work
Object access session.

VW Close Object Access Session

call “VW Close Object Access Session” (Active)


set F_ObjectAccessHandle Handle. Handle returned from “VW
Open Object Access Session.”
F_SaveUpdates Boolean. If true, updates from this
session are saved to the Work Object
and queue.

December 1996 Work Performer Developer’s Guide 239


WorkFlo Script Work Performers
WorkFlo Script Calls

set F_SkipCurrentInstruction Boolean. If true, the current instruction


(cont) is skipped. Defaults to false.
get None.

Complete Work Queue Processing


Call “VW Close Browse Session” when you want to terminate a browse
session. Remember that you can have multiple browse sessions at the same
time. This call releases F_BrowseHandle.

Call “VW Close Work Session” when you want to remove the current active
Work Performer from the Visual WorkFlo application. By calling “VW Open
Work Session” again, the WorkFlo script can subsequently establish a further
session to browse Work Queues. However, be aware that multiple calls to
either “VW Open Work Session” and “VW Close Work Session” can impact
performance.

VW Close Browse Session


“VW Close Browse Session” ends a Work Queue browse session and
releases the F_BrowseHandle, all object handles, and all lock handles from
the session. You must issue this call once for every browse session you
established.

call “VW Close Browse Session” (Active)


set F_BrowseHandle Handle: required. Returned from the “VW
Open Browse Session” call.
get None.

VW Detach From Work Queue


“VW Detach From Work Queue” releases the handle returned by “VW Attach
To Work Queue.” Make this call after calling “VW Close Browse Session,” and
before calling “VW Logoff.” It closes any associated browse sessions.

call “VW Detach From Work Queue” (Active)


set F_WorkQueueHandle Handle: required. Returned from the
“VW Attach To Work Queue” call.
get None.

240 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Calls

VW Close Work Session


Use “VW Close Work Session” to remove an active Work Performer (your
WorkFlo script) from the Visual WorkFlo application. Remember that the script
can continue with other, non-Visual WorkFlo, processing. If appropriate, the
script can call “VW Open Work Session” again to perform more Visual
WorkFlo processing.

call “VW Close Work Session” (Active)


set F_WorkPerformerHandle Handle: required. Returned from the
“VW Open Work Session” call.
get None.

VW Free Handle
“VW Free Handle” releases the handle specified in its set clause. Use this call
to free the handle of an unlocked Work Object (F_ObjectHandle), or a Work
Performer handle (F_WorkPerformerHandle (for a passive Work Performer),
or an Operation handle (F_OperationHandle).

call “VW Free Handle” (Active or passive)


set F_VWHandle Handle: required.
get None.

Logging and Exception Handling


The WorkFlo calls in this section handle logging and exceptions. The calls
related to logging messages require constants defined in the VW.WFI file.

For more information about logging messages, see the “Logging Features”
section in the “Creating a Visual WorkFlo Application” chapter of the Visual
WorkFlo/Composer Handbook.

December 1996 Work Performer Developer’s Guide 241


WorkFlo Script Work Performers
WorkFlo Script Calls

VW Set Attributes
Use “VW Set Attributes” to control the frequency with which the local log
cache flushes its contents. You can change the maximum number of entries
contained in the local log cache by specifying F_LogCacheFlushLength.

call “VW Set Attributes” (Active or Passive)


set F_LogCacheFlushLength Number. Specify the maximum
number of entries in the local log
cache. A flush occurs when the
cache contains this number of
entries.
This parameter is optional.
get F_LogCacheFlushLength Number. The value of the log cache
flush length before any modifications
made by this call.

VW Set Log Flags


Call “VW Set Log Flags” once for each event type you want to log. Each event
type is represented by a bit position, defined as a constant in the VW.WFI file.

call “VW Set Log Flags” (Active or Passive)


set F_WorkPerformerHandle Handle: required. Identifies the active
or passive Work Performer. Returned
from either “VW Open Work Session”
or “VW Get Work Performer Handle.”
F_BitPosition Number: required. Specifies the event
type’s bit position. Refer to VW.WFI
for the constant values.
F_BitLogState Number: required. Specifies the state
of F_BitPosition. Settings are:
F_LogStateOff (don’t log)
F_LogStateOn (do log)
See VW.WFI for the constant
definitions.
get None.

242 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Calls

VW Get Log Flags


“VW Get Log Flags” returns the setting of the specified bit position, indicating
if message logging is enabled for the represented event type.

call “VW Get Log Flags” (Active or Passive)


set F_WorkPerformerHandle Handle: required. Identifies the active
or passive Work Performer. Returned
from either “VW Open Work Session”
or “VW Get Work Performer Handle.”
F_BitPosition Number: required. Specifies the
event type’s bit position. Refer to
VW.WFI for the constant values.
get F_BitLogState Number. Returns the setting of
F_BitPosition.

VW Log Message
Use “VW Log Message” to log a message for the specified event type.

call “VW Log Message” (Active or Passive)


set F_WorkPerformerHandle Handle: required. Identifies the
active or passive Work Performer.
Returned from either “VW Open
Work Session” or “VW Get Work
Performer Handle.”
F_BitPosition Number: required. Specifies the
event type’s bit position. Refer to
VW.WFI for the constant values. Use
either F_USER1 or F_USER2.
F_LogMessage String: required. The text of the
message.
get None.

December 1996 Work Performer Developer’s Guide 243


WorkFlo Script Work Performers
WorkFlo Script Calls

VW Raise Exception
Call “VW Raise Exception” when the script encounters an exception condition.
You can specify the name of an exception handling Instruction Sheet to
process the Work Object. You can also provide a description of the exception,
for example “Account number contained null.”

This call frees the lock handle and the object handle.

call “VW Raise Exception” (Active or Passive)


set F_LockHandle Handle: required in an active Work
Performer. Returned from “VW Fetch
Work Object” call. Do not use in
conjunction with F_OperationHandle.
F_OperationHandle Handle: required in a passive Work
Performer. Returned from the “VW
Get Operation Handle” call. Do not
use in conjunction with F_Lock-
Handle.
F_ExceptionName String: required. Maximum of 79
characters. Specifies the name of the
exception handling Instruction Sheet.
F_ExceptionDescription String: required. Describes the
exception condition. Maximum of
1023 characters.
get None.

VW Get Current Exception


“VW Get Current Exception” can be included in a script that is used in several
exception handling Instruction Sheets. The logic flow might differ for each one.
The call returns the name of the currently running exception handling
Instruction Sheet. If there is no current exception, an error tuple is returned.

call “VW Get Current Exception” (Active or Passive)


set F_LockHandle Handle: required in an active Work
Performer. Returned from “VW Fetch
Work Object” call. Do not use in
conjunction with F_OperationHandle.

244 Work Performer Developer’s Guide December 1996


WorkFlo Script Work Performers
WorkFlo Script Calls

set F_OperationHandle Handle: required in a passive Work


(cont) Performer. Returned from the “VW
Get Operation Handle” call. Do not
use in conjunction with F_Lock-
Handle.
get F_ExceptionName String. Specifies the name of the
exception handling Instruction Sheet.
F_ExceptionDescription String. Describes the exception
condition.

VW Get Error Text


When you want to retrieve the text associated with an error code, use the “VW
Get Error Text” call. This call puts the error message into a variable that you
can subsequently write to a file or display to the user.

You must have installed Visual WorkFlo before you can use this call.

call “VW Get Error Text” (Active or Passive)


set F_ErrorNumber Number: required. The error number returned
from a WorkFlo statement.
get F_ErrorText String. The error text associated with the error
number. Maximum length is 143 characters.

In this example, if the parameter Err contained the error code 213, 45, 1016,
the call returns the error text “Unknown top-level field of item” into
F_ErrorText.

Error := call "VW Get Error Text"


set (F_ErrorNumber := Err)
get (ErrText := F_ErrorText);

December 1996 Work Performer Developer’s Guide 245


WorkFlo Script Work Performers
WorkFlo Script Calls

246 Work Performer Developer’s Guide December 1996


Glossary

This glossary contains only those terms deemed specific to Visual WorkFlo. It
does not include generic computing or imaging terms.

Active Work Performer


A Work Performer that can browse the Work Queues and select Work
Objects.

Adaptor
FileNet-provided software that acts as a gateway between Visual WorkFlo
and the Operation software.

Authoring repository
A database table that stores all class definitions.

Bound subtree
A subtree contained within a BindToUser or BindToStation system
Instruction and an Unbind system Instruction.

Create Work Object


An application used to create Work Objects. You cannot provide initial
values.

Data Class
Data type.

Dispatch software
Retrieves the Work Object from the On-line repository and submits the
appropriate Work Object data fields to the Work Performer’s adaptor.

Editor
A user interface within the Browsers.

errtuple.h
A ‘C’ header file containing error constants for which you can trap in your
Work Performer code.

December 1996 Work Performer Developer’s Guide 247


Event
A predefined occurrence that triggers some activity within the system.

History repository
A database table that stores statistical information for archival purposes
and management reporting.

Inheritance
The ability to inherit properties from a parent class.

Instruction
A graphical entity on an Instruction Sheet. An Instruction represents either
a Work Performer Operation or a decision. An Instruction includes a
definition for passing data between the Work Object and the Work
Performer.

Instruction Sheet
Graphical representation of a business process. One Work Class can
contain multiple Instruction Sheets, and an Instruction Sheet can call other
Instruction Sheets.

Left mouse button


The button on the left of the mouse. Used to select menu options, etc.

Left pane
The work area in the upper left of Visual WorkFlo/ Composer and Visual
WorkFlo/Conductor screens. Fixed size.

Middle pane
The work area in the upper middle of Visual WorkFlo/ Conductor screens.
Fixed size.

On-line repository
A database table that stores the executable version of Work Class
definitions.

Operation
A software procedure that is a member of a Work Performer class. It
represents either system commands or user-created Work Performers,
and can be displayed as an icon within an Instruction Sheet.

248 Work Performer Developer’s Guide December 1996


Glossary

Operation editor
A user interface within the Instruction Sheet where you specify the names
of Work Object fields.

Passive Work Performer


A Work Performer that accepts Work Objects from the Work Queue. It
cannot make selections from the Work Queue.

Pertool
A tool used to setup the default database tables and to initialize individual
domains.

Repository
A database containing application definitions and runtime versions, as well
as statistical information.

Repository Analysis Tool (RAT)


A tool that provides views of the various database tables used by Visual
WorkFlo to store objects.

Right mouse button


The button on the right of the mouse. Used to display context-sensitive
menus.

Right pane
The work area in the upper right of Visual WorkFlo/ Composer and Visual
WorkFlo/ Conductor screens. Fixed size.

Subtree
A collection of Instructions connected to a common node.

System Instructions
Special flow- and logic-control Instructions provided by FileNet.

Transfer
The process of transferring class definitions from the Authoring repository
to the On-line repository. During this process, the definitions are compiled
into an executable format.

December 1996 Work Performer Developer’s Guide 249


Trigger
An application used to provide concurrent execution of Work Performers.
For multiple passive Work Performers to perform work simultaneously, you
need one Trigger instance per Work Performer.

Visual WorkFlo
A suite of programs that provide intelligent workflow management.

Visual WorkFlo/Composer
The Visual WorkFlo application used to author the definitions for Work
Classes and Work Performers.

Visual WorkFlo/Conductor
The Visual WorkFlo application used to handle exception conditions, apply
on-the-fly updates to Work Object values and Instruction Sheets, and to
manage the flow of work through a Visual WorkFlo system.

Visual WorkFlo/Performer
The runtime version of Visual WorkFlo that enables the Work Performers
to execute their tasks.

VW.INI file
The file containing setup preferences and options for the Visual WorkFlo/
Composer, Visual WorkFlo/ Conductor, and Visual WorkFlo/Performer
environments.

Work Class
A template that defines the Work Object in terms of data fields and
Instruction Sheets.

Work Object
A transitory element that contains data, Instruction Sheets, and status.

Work Object Id
A field specified in the Properties editor of the Work Class browser. The
value in this field is referenced during a Wait for Event definition, and
displays in some panes of Visual WorkFlo/Conductor.

Work Order
The internal class name for an Instruction.

250 Work Performer Developer’s Guide December 1996


Glossary

Work Performer
The entity that actually performs work. An active Work Performer can
select an entry from its Work Queue. A passive Work Performer can only
receive work from the Work Queue based on preset rules.

Work Performer Class


A module containing one or more software procedures (or Operations).

Work Performer data field


A data field associated with a Work Performer instance. Can be used in a
Selection Rule when prepended by a ‘$’ sign.

Work Queue
A database table where Work Objects wait until the Work Performer is
available.

Work Queue fields


Work Object data fields used for identifying Work Objects within a Work
Queue. Used in the Entry Rule, Selection Rule, and the Sort Rules.

Workspace
A snapshot of the On-line repository. Visual WorkFlo can maintain multiple
workspaces.

December 1996 Work Performer Developer’s Guide 251


252 Work Performer Developer’s Guide December 1996
Appendix A—Error Messages

This appendix contains a description for each error tuple that can be reported
by the Visual WorkFlo API calls.

The FileNet error tuple code is a three part 32-bit unsigned long value. The
three parts are as follows:

0000 0000 0000 0000 0000 0000 0000 0000


Error Category Error Function Error Number

The first 16 bits represent the Error Number, the middle 8 bits represent the
Error Function, and the last 8 bits represent the Error Category, described in
the following paragraphs.

Note The Error Message Translator can only decode error tuples from the server
side of the OLE connection. If a Work Performer calls VWAPI functions that
call VWAPISRV through OLE, error tuples from the OLE client (VWAPI in this
case) cannot be decoded by the Error Message Translator. However, there
are very few error messages that come from the client side.See the Visual
WorkFlo Utilities Handbook for more information on the Error Message
Translator.

Error Category
The Error Category code for Visual WorkFlo is 213 (decimal).

Note that if the Error Category portion of the returned error tuple does not
equal 213, it means that this error was reported by WorkForce Desktop–not
Visual WorkFlo. In this case, please refer to the appropriate WorkForce
Desktop documentation for a description of the error tuple code.

December 1996 Work Performer Developer’s Guide 253


Appendix A—Error Messages
Error Function

Error Function
The Error Function code indicates the exception class (type) of the error. The
following table maps the Error Function Codes to their respective exception
classes.

Error Function
Code Exception Class
1 MemoryException
2 AssertException
10 DLLException
11 NumberException
12 ErrorTupleException
13 ErrorTextException
20 SecurityException
25 PersistException
26 BtrieveException
35 PrimitiveException
36 DataClassException
45 ExprExecException
46 ExprCompException
55 SidlCompilerException
56 SmartWorkException
65 LogException
70 QueueException
75 ServicesException
80 PerformException
81 ISInterpreterException
82 WorkPerformerException

254 Work Performer Developer’s Guide December 1996


Appendix A—Error Messages
Error Numbers

Error Numbers
The following table shows each Error Number (and its message) within each
Error Function Code. For a list of error constants and their error tuples, refer to
the errtuple.h file. This file contains a subset of the entries listed in the
following table, as well as a comment section with usage examples.

Error
Function Error
Code Number Error Message
1 1001 Uncaught exception!
1 1002 Assertion Failed (exact message depends on
assertion type).
1 1003 Maximum try nesting depth exceeded.
1 1004 Catch clause not in try block.
1 1005 Rethrow done with no previous throw.
1 1006 Not enough available memory.
1 1007 Memory request exceeded segment size.
1 1008 Could not lock memory handle.
1 1009 Can’t watch application’s memory.
1 1010 Can’t stop watching application’s memory.
1 1011 Throw performed in stack cleanup while
processing another throw.
1 1012 Not an application.
1 1013 Can’t watch global memory handle.
1 1014 Can’t stop watching global memory handle.
2 1 Assertion Failed... The exact message depends
upon the nature of the assertion failure.
10 1001 Could not load DLL.
10 1002 Could not find entry point in DLL.
11 1003 Divide by zero.
11 1004 Square root of a negative value.
11 1005 Underflow.
11 1006 Overflow.

December 1996 Work Performer Developer’s Guide 255


Appendix A—Error Messages
Error Numbers

Error
Function Error
Code Number Error Message
20 1000 You are not logged on. Please log on to the
system first.
20 1001 Missing or invalid INI file entry in Security section.
25 1001 Bad type for database column.
25 1002 Object is in multiple persistent tables.
25 1003 Bad key type for persistent dictionary.
25 1004 Object not found in cache on cache only request.
25 1005 Bad parameter for Oid constructor.
25 1006 Object is in multiple OidCores.
25 1007 Two definitions of a column have different types.
25 1008 Two definitions of an index are different.
25 1009 Use of iteration type not defined for class.
25 1010 Not a valid query clause.
25 1011 Not a valid key description.
25 1012 Missing required configuration item.
25 1013 Bad store type.
25 1014 Missing Begin/End transaction.
26 1500 Unable to open FN_FILE.DDF.
26 1501 Unable to open FN_FIELD.DDF.
26 1502 Unable to open FN_INDEX.DDF.
26 1503 Missing field definition.
26 1504 Not a valid field for index.
26 1505 Cannot find DDF table info for table.
26 1506 Cannot find DDF field info for table.
26 1507 Cannot find DDF index info for table.
26 1508 Unable to create table.
26 1509 Unable to open table.
26 1510 Bad field value type.

256 Work Performer Developer’s Guide December 1996


Appendix A—Error Messages
Error Numbers

Error
Function Error
Code Number Error Message
26 1511 Bad field name.
26 1512 Bad type for a key.
26 1513 Unable to insert record into table.
26 1514 Bad key type for dictionary.
26 1515 Bad value type for dictionary.
26 1516 Bad Record Type for the table.
26 1517 Failed to begin a transaction.
26 1518 Unable to close table.
26 1519 Unable to create directory for Database.
26 1520 Unable to initialize Btrieve.
35 1 Unsupported primitive data type.
36 1001 Runtime class was not found.
45 1001 Invalid data type for operation.
45 1002 Invalid opcode encountered.
45 1003 Expression stack unexpectedly has too few
items.
45 1004 Expression evaluation resulted in bad stack
contents.
45 1005 Division by zero.
45 1006 Attempted to use string index/length outside of
string.
45 1007 Second and third arguments to translate function
must be same length.
45 1008 Second argument to WorkFlo substitute function
must not be empty.
45 1009 Argument to hex function must be even length
and contain all hex digits.
45 1010 Bad null type.
45 1011 Bad conversion type(s).
45 1012 Bad conversion value.

December 1996 Work Performer Developer’s Guide 257


Appendix A—Error Messages
Error Numbers

Error
Function Error
Code Number Error Message
45 1013 Unknown object type encountered.
45 1014 Opcode not yet implemented.
45 1015 Value out of range.
45 1016 Unknown work object item.
45 1017 Unknown field of item.
45 1018 Subscript out of range.
45 1019 Invalid operation on null value.
45 1020 Cannot convert value to string.
46 2001 Bad types for operand(s).
46 2002 Syntax error.
46 2003 Parser stack overflow.
46 2004 Bad space for scanner.
46 2005 No space for scanner.
46 2006 Unknown compilation error.
46 2007 Token too large.
46 2008 Push-back buffer overflow.
55 2001 Non existent DataClass.
55 2002 Syntax error.
55 2003 Parser stack overflow.
55 2004 Bad space for scanner.
55 2005 No space for scanner.
55 2006 Unknown compilation error.
55 2007 Token too large.
55 2008 Push-back buffer overflow.
56 311 Invalid WorkObject exception.
56 312 Primitive InstructionSheet not found.
56 313 Undefined WorkObject exception.
56 314 Illegal WorkObject exception.

258 Work Performer Developer’s Guide December 1996


Appendix A—Error Messages
Error Numbers

Error
Function Error
Code Number Error Message
65 1000 Unable to create the ClientLogger timer.
65 1001 Failed to get instance of PersistentStrDictionary
for logger.
70 1001 Invalid queue name.
70 1002 Invalid message dictionary format.
70 1003 Invalid queue field type.
70 1004 Queue assertion violated.
70 1005 Bad result type for expression.
70 1006 Could not lock queue entry.
70 1007 Could not unlock queue entry.
75 1 Unknown error.
75 2 Invalid WorkClass name.
75 3 Invalid Work Object Id.
75 4 Invalid Work Object field name.
75 5 Invalid context id.
75 6 Field type mismatch.
75 7 Invalid Work Performer id.
75 8 Invalid browse id.
75 9 Browse has been exhausted.
75 10 Invalid lock id.
75 11 Cannot get an ‘Out’ parameter.
75 12 Cannot set an ‘In’ parameter.
75 13 Object type mismatch.
75 14 Invalid parameter name.
75 15 Incorrect parameter type.
75 16 Invalid object id.
75 17 Cannot set the Work Queue fields.
75 18 Invalid Work Performer class name.

December 1996 Work Performer Developer’s Guide 259


Appendix A—Error Messages
Error Numbers

Error
Function Error
Code Number Error Message
75 19 Insufficient security rights.
75 20 Out of memory.
75 21 Cannot lock memory handle.
75 23 Cannot lock the Work Object.
75 24 All active Work Performers deactivated–
ReportToWork not allowed.
75 25 Active Work Performer deactivated–
LockWorkObject not allowed.
75 26 Removal of a busy active Work Performer not
allowed.
75 27 Visual WorkFlo/Performer not responding–
ReportToWork not allowed.
75 28 Unable to establish DDE connection with Visual
WorkFlo/ Performer–ReportToWork not allowed.
75 29 Unsupported field type.
75 30 Exception already raised for Work Object.
75 31 Exception undefined for Work Object class.
75 32 Illegal raising of a Work Object exception.
75 33 Currently no exception for Work Object.
75 34 The specified bit position is not supported by
LogMessage().
75 35 Invalid WorkQueue field name.
75 36 Invalid registration id.
75 37 User access denied.
80 211 TBD
80 212 Unable to find next Work Performer.
80 213 Unable to enqueue Work Object.
80 216 Invalid object class.
80 217 Required data not found.
80 218 Requested Work Performer not found.

260 Work Performer Developer’s Guide December 1996


Appendix A—Error Messages
Error Numbers

Error
Function Error
Code Number Error Message
80 219 Requested Work Performer not available.
80 220 No performable WorkObjects available.
80 221 WorkObject not doable by specified
WorkPerformer.
80 222 WorkQueue not found.
80 223 Adaptor type not supported.
80 224 Adaptor name not found for WorkPerformer
class.
80 225 Specified WorkPerformer class not found.
81 181 Primitive InstructionSheet unavailable.
81 182 Unsupported InstructionSheetInterpreter
service.
81 183 Malfunction InstructionSheet not defined.
82 192 WorkObject access violation.
82 193 Invalid action parameters.
82 194 WorkObject assertion violation.
82 195 WorkPerformer service failure.
82 196 WorkPerformer start failure.
82 197 WorkPerformer perform failure.
82 198 WorkPerformer stop failure.
82 199 Corrupted value returned by WorkPerformer.
82 200 Unknown DataClass returned by
WorkPerformer.
82 201 Invalid parameter returned by Work Performer–
must be subclass of dataclass in service
specification.

December 1996 Work Performer Developer’s Guide 261


Appendix A—Error Messages
Error Numbers

262 Work Performer Developer’s Guide December 1996


Index

A VW Get Fields 235


active Work Performer 4 VW Get Log Flags 243
browse function sequence 11 VW Log Message 243
converting to use OLE 33 VW Logoff 224
function sequences 10 VW Logon 224
process Work Object function sequence 12 VW Open Browse Session 229
WorkFlo Script code example 200 VW Open Object Query Session 237
active Work Performer API calls VW Open Work Session 224
VW_AttachToWorkQueue 20 VW Raise Exception 244
VW_BeginBrowsingWorkQueue 20 VW Return Work Object 236
VW_BrmCreateBrowseModifier 20 VW Set Attributes 242
VW_BrmFreeBrowseModifier 21 VW Set Fields 234
VW_BrmSetPreSelectRule 20 VW Set Log Flags 242
VW_BrmSetSelectRule 20 VW Terminate Work Object 228
VW_BrmSetSortRules 21 VW Work Object Query 238
VW_DetachFromWorkQueue 21 adaptors 8
VW_EndBrowsingWorkQueue 21 DLL 81
VW_FreeAccessHandle 22 VWOLEADP 8, 29, 31
VW_GetAccessHandle 22 WorkFlo Script 197
VW_LeaveWork 21 administration programs 9
VW_LockWorkObject 21 function sequences 16
VW_Logoff 18 API calls
VW_Logon 18 C 88
VW_NextWorkObjectToBrowse 21 message logging 19
VW_ReportToWork 21 overview 18
VW_UnlockAndDispatch 21 queue handling 19
VW_UnlockWorkObject 21 VWAPISRV 34
active WorkFlo Script calls array data types
VW Attach To Work Queue 224 corresponding C data types 82
VW Browse Work Queue 231 array handling 7
VW Close Browse Session 240
VW Close Object Query Session 238 B
VW Close Work Session 241 browse handle
VW Create Work Object 227 establishing 229
VW Detach From Work Queue 240 C
VW Fetch Work Object 231 C API calls 88
VW Free Handle 241
VW Get Current Exception 244
VW Get Error Text 245

December 1996 Work Performer Developer’s Guide 263


Index

D error tuple descriptions 253


data access API calls executable file extension
VW_FreeArrayPtr 23 passive Work Performer 7
VW_GetArrayPtr 23 exposed fields
VW_GetArraySize 23 number of 5
VW_GetBoolean 23
VW_GetDataType 23 F
VW_GetDataTypeArray 23 F_VWLogonHandle 224
VW_GetFloat 23 function sequences
VW_GetInteger 23 active Work Performer 10
VW_GetString 23 administration programs 16
VW_GetStringSize 23 browse 11
VW_GetTime 23 locating a Work Object 17
VW_SetArrayPtr 23 process Work Object 12
VW_SetBoolean 23 Work Object creation 16
VW_SetFloat 23 G
VW_SetInteger 24 glossary 247
VW_SetString 24 granularity
VW_SetTime 24 Work Performer Operations 5
data fields
set via WorkFlo 233 H
data type conversion handles
C 82 F_BrowseHandle 199
WorkFlo Script 198 F_ContextHandle 199
debugging Work Performers 25 F_LockHandle 199
message logging 25 F_ObjectHandle 199
NDump 26 F_RegistrationHandle 199
design considerations F_VWHandle 199
Work Performers 3 F_WorkPerformerHandle 199
DLL adaptor 81 L
DLL code example locating a Work Object function sequences 17
passive Work Performer 85 log messages
E VW_GetLoggingState 19
error category 253 VW_LogMessage 19
error function 253 VW_SetLogCacheFlushLength 19
error handling API calls VW_SetLoggingState 19
VW_CheckVersionCompatibility 25 M
VW_CurrentException 25 message logging API calls 19
VW_GetErrorMessage 25
VW_GetErrorMessageSize 25 N
VW_RaiseException 25 NDump 26
VW_TerminateWorkObject 25 sample output 27
error number 255

264 Work Performer Developer’s Guide December 1996


Index

O VW Raise Exception 244


OLE VW Set Attributes 242
active Work Performer VW Set Fields 234
VW_BrmSetSortRules() example 40 VW Set Log Flags 242
active Work Performer example 41 VW Terminate Work Object 228
active Work Performers 31 process Work Object
converting existing active Work Performers to function sequence 12
use OLE 33 ProgId
Work Performers that use 29 passive Work Performer script name 30
OLE data types
R
and Visual WorkFlo data types 29
registering OLE servers 30
OLE server
reusability
converting an existing Work Performer to use
Work Performer Operations 5
OLE 31
passive Work Performer example 48 S
registering 30 script name for passive Work Performer
Visual Basic 31 ProgId 30
writing 29 security
Operations Work Performers 6
granularity of 5 session
multiple 6 establish 224
reusability 5 terminate 224
P V
passive Work Performer 4 validation checking 6
DLL code example 85 Visual WorkFlo
executable file extension 7 API calls overview 18
function sequences 13 Visual WorkFlo array handling 7
registering 30 Visual WorkFlo data types
that use OLE 29 and OLE data types 29
WorkFlo Script code example 217 VW Browse Work Queue 231
passive WorkFlo Script calls VW Close Browse Session 240
VW Create Work Object 227 VW Close Object Query Session 238
VW Free Handle 241 VW Close Work Session 241
VW Get Current Exception 244 VW Create Work Object 227
VW Get Error Text 245 VW Detach From Work Queue 240
VW Get Fields 235 VW Fetch Work Object 231
VW Get Log Flags 243 VW Free Handle 241
VW Get Operation Handle 225 VW Get Current Exception 244
VW Get Work Performer Handle 225 VW Get Error Text 245
VW Log Message 243 VW Get Fields 235
VW Logoff 224 VW Get Log Flags 243
VW Logon 224 VW Get Operation Handle 225

December 1996 Work Performer Developer’s Guide 265


Index

VW Get Work Performer Handle 225 VW_CreateWorkObject 18


VW Log Message 243 C 105
VW Logoff 224 VWAPISRV 36
VW Logon 224 VW_CurrentException 25
VW Open Browse Session 229 C 107
VW Open Object Query Session 237 VWAPISRV 36
VW Open Work Session 224 VW_DetachFromWorkQueue 21
VW Raise Exception 244 C 109
VW Return Work Object 236 VWAPISRV 36
VW Set Attributes 242 VW_DispatchWorkObject 18
VW Set Fields 234 C 110
VW Set Log Flags 242 VWAPISRV 36
VW Terminate Work Object 228 VW_EndBrowsingWorkQueue 21
VW Work Object Query 238 C 111
VW.INI file 9 VWAPISRV 36
VW.WFI file 197 VW_FreeAccessHandle 22
VW_AttachToWorkQueue 20 C 112
C 89 VWAPISRV 36
VWAPISRV 35 VW_FreeArrayPtr 23
VW_BeginBrowsingWorkQueue 20 C 114
C 91 VW_GetAccessHandle 22
VWAPISRV 35 C 115
VW_BindToUser 23 VWAPISRV 36
C 93 VW_GetArray
VWAPISRV 35 VWAPISRV 36
VW_BrmCreateBrowseModifier 20 VW_GetArrayPtr 23
C 94 C 117
VWAPISRV 35 VW_GetArraySize 23
VW_BrmFreeBrowseModifier 21 C 119
C 96 VWAPISRV 36
VWAPISRV 35 VW_GetBoolean 23
VW_BrmSetPreSelectRule 20 C 121
C 97 VWAPISRV 36
VWAPISRV 35 VW_GetDataType 23
VW_BrmSetSelectRule 20 C 123
C 99 VWAPISRV 36
VWAPISRV 35 VW_GetDataTypeArray 23
VW_BrmSetSortRules 21 C 125
C 101 VWAPISRV 36
VWAPISRV 35 VW_GetErrorMessage 25
VW_CheckVersionCompatibility 25 C 127
C 103 VWAPISRV 36
VWAPISRV 35

266 Work Performer Developer’s Guide December 1996


Index

VW_GetErrorMessageSize 25 VW_LockWorkObject 21
C 128 C 150
VWAPISRV 36 VWAPISRV 37
VW_GetFieldNames VW_LogMessage 19
C 129 C 152
VWAPISRV 37 VWAPISRV 37
VW_GetFloat 23 VW_Logoff 18
C 131 C 154
VWAPISRV 37 VWAPISRV 37
VW_GetFPNumber VW_Logon 18
C 133 C 155
VWAPISRV 37 VWAPISRV 38
VW_GetInteger 23 VW_NextWorkObjectToBrowse 21
C 135 C 157
VWAPISRV 37 VWAPISRV 38
VW_GetLoggingState 19 VW_RaiseException 25
C 137 C 158
VWAPISRV 37 VWAPISRV 38
VW_GetOperationName 22 VW_ReportToWork 21
C 139 C 160
VWAPISRV 37 VWAPISRV 38
VW_GetOperationNameSize 22 VW_SetArray
C 140 VWAPISRV 38
VWAPISRV 37 VW_SetArrayPtr 23
VW_GetString 23 C 161
C 141 VW_SetBoolean 23
VWAPISRV 37 C 163
VW_GetStringSize 23 VWAPISRV 38
C 143 VW_SetFloat 23
VWAPISRV 37 C 165
VW_GetTime 23 VWAPISRV 38
C 145 VW_SetFPNumber
VWAPISRV 37 C 167
VW_GetWobSignature 22 VWAPISRV 38
C 147 VW_SetInteger 24
VWAPISRV 37 C 169
VW_GetWorkPerformerHandle 22 VWAPISRV 38
C 148 VW_SetLogCacheFlushLength 19
VWAPISRV 37 C 171
VW_LeaveWork 21 VWAPISRV 38
C 149 VW_SetLoggingState 19
VWAPISRV 37 C 172
VWAPISRV 38

December 1996 Work Performer Developer’s Guide 267


Index

VW_SetString 24 W
C 174 WFLADAPT.DLL 197
VWAPISRV 38 Work Object
VW_SetTime 24 changing 21, 115, 188
C 176 creation 227
VWAPISRV 38 termination 228
VW_TerminateWorkObject 25 Work Object binding API calls
C 178 VW_BindToUser 23
VWAPISRV 38 VW_UnBind 23
VW_UnBind 23 Work Object creation
C 180 function sequence 16
VWAPISRV 38 VW_CreateWorkObject 18
VW_UnlockAndDispatch 21 VW_DispatchWorkObject 18
C 181 Work Object information API calls
VWAPISRV 38 VW_GetOperationName 22
VW_UnlockWorkObject 21 VW_GetOperationNameSize 22
C 182 VW_GetWobSignature 22
VWAPISRV 39 VW_GetWorkPerformerHandle 22
VW_WobQueryCreate 24 Work Object location API calls
C 183 VW_WobQueryCreate 24
VWAPISRV 39 VW_WobQueryEnd 24
VW_WobQueryEnd 24 VW_WobQueryExecute 24
C 185 VW_WobQueryGetAccessHandle 22
VWAPISRV 39 VW_WobQueryInstrSheet 24
VW_WobQueryExecute 24 VW_WobQueryOperation 24
C 186 VW_WobQueryWorkPerformerClass 24
VWAPISRV 39 Work Performer
VW_WobQueryGetAccessHandle 22 16-bit 1
C 188 32-bit 2
VWAPISRV 39 design considerations 3
VW_WobQueryInstrSheet 24 using OLE 29
C 190 Work Performer fields
VWAPISRV 39 getting and setting 232
VW_WobQueryOperation 24 Work Queue fields
C 192 getting and setting 232
VWAPISRV 39 number of 5
VW_WobQueryWorkPerformerClass 24 Work Queues
C 194 number of 5
VWAPISRV 39 WorkFlo Script
VWAPISRV data type conversion 198
API call syntax 34 Visual WorkFlo handles 199
VWOLEADP adaptor 8, 29, 31

268 Work Performer Developer’s Guide December 1996


Index

WorkFlo Script code example


active Work Performer 200
passive Work Performer 217

December 1996 Work Performer Developer’s Guide 269


Index

270 Work Performer Developer’s Guide December 1996

You might also like