Navigation: ABC Library Reference > ProcessClass >====== ProcessClass Overview ====== | |
The ProcessClass is a ViewManager with a progress window.
ProcessClass Concepts
The ProcessClass lets you “batch” process a VIEW, applying sort orders, range limits, and filters as needed to process only the specific result set in the specific sequence you require; plus the ProcessClass supplies appropriate (configurable) visual feedback to the end user on the progress of the batch process.
ProcessClass Relationship to Other Application Builder Classes
The ProcessClass is derived from the ViewManager, plus it relies on many of the other Application Builder Classes to accomplish its tasks. Therefore, if your program instantiates the ProcessClass, it must also instantiate these other classes. Much of this is automatic when you INCLUDE the ProcessClass header (ABREPORT.INC) in your program's data section. See the Conceptual Example.
The ReportManager uses the ProcessClass to process report data and provide appropriate visual feedback to the end user on the progress of the report.
ProcessClass ABC Template Implementation
The ABC Templates automatically include all the classes necessary to support the batch processes (Process procedures and Report procedures) specified in your application.
The templates derive a class from the ProcessClass for each batch process (Process Procedures and Report Procedures) in the application. The derived classes are called ThisProcess and ThisReport. These derived ProcessClass objects support all the functionality specified in the Process or Report procedure template.
The derived ProcessClass is local to the procedure, is specific to a single process and relies on the global file-specific RelationManager and FileManager objects for the processed files.
ProcessClass Source Files
The ProcessClass source code is installed by default to the Clarion \LIBSRC. The ProcessClass source code and their respective components are contained in:
ABREPORT.INC | ProcessClass declarations |
ABREPORT.CLW | ProcessClass method definitions |
ProcessClass Conceptual Example
The following example shows a typical sequence of statements to declare, instantiate, initialize, use, and terminate a ProcessClass object and related objects. This example processes selected records in a file, updates them, and displays a window with a progress bar to show the progress of the process.
PROGRAM
INCLUDE('ABWINDOW.INC') !declare WindowManager Class
INCLUDE('ABREPORT.INC') !declare Process Class
MAP
END
Customer FILE,DRIVER('TOPSPEED'),PRE(CUS),THREAD !declare Customer file
BYNUMBER KEY(CUS:CUSTNO),NOCASE,OPT,PRIMARY
Record RECORD,PRE()
CUSTNO LONG
Name STRING(30)
State STRING(2)
END
END
CusView VIEW(Customer) !declare VIEW for process
END
Access:Customer CLASS(FileManager) !declare Access:Customer object
Init PROCEDURE
END
Relate:Customer CLASS(RelationManager) !declare Relate:Customer object
Init PROCEDURE
END
ThisWindow CLASS(ReportManager) !declare ThisWindow object
Init PROCEDURE(),BYTE,PROC,VIRTUAL
Kill PROCEDURE(),BYTE,PROC,VIRTUAL
END
ThisProcess CLASS(ProcessClass) !declare ThisProcess object
TakeRecord PROCEDURE(),BYTE,PROC,VIRTUAL
END
ProgressMgr StepLongClass !declare ProgressMgr object
GlobalErrors ErrorClass !declare GlobalErrors object
VCRRequest LONG(0),THREAD
Thermometer BYTE !declare PROGRESS variable
ProgressWindow WINDOW('Progress…'),AT(,,142,59),CENTER,TIMER(1),GRAY,DOUBLE
PROGRESS,USE(Thermometer),AT(15,15,111,12),RANGE(0,100)
STRING(),AT(0,3,141,10),USE(?UserString),CENTER
STRING(
),AT(0,30,141,10),USE(?PctText),CENTER
BUTTON('Cancel'),AT(45,42),USE(?Cancel)
END
CODE
ThisWindow.Run() !run the Process procedure
ThisWindow.Init PROCEDURE() !initialize things
ReturnValue BYTE,AUTO
CODE
GlobalErrors.Init !initialize GlobalErrors object
Relate:Customer.Init !initialize Relate:Customer object
ReturnValue = PARENT.Init() !call base class init
SELF.FirstField = ?Thermometer !set FirstField for ThisWindow
SELF.VCRRequest &= VCRRequest !VCRRequest not used
SELF.Errors &= GlobalErrors !set errorhandler for ThisWindow
Relate:Customer.Open !Open Customer and related files
OPEN(ProgressWindow) !open the window
SELF.Opened=True !set Opened flag for ThisWindow
ProgressMgr.Init(ScrollSort:AllowNumeric) !initialize ProgressMgr object
!init ThisProcess by naming its VIEW, RelationManager,ProgressMgr & progress variables
ThisProcess.Init(CusView,Relate:Customer,?PctText,Thermometer,ProgressMgr,CUS:CUSTNO)
ThisProcess.AddSortOrder(CUS:BYNUMBER) !set the process sort order
SELF.Init(ThisProcess) !process specific initialization
SELF.AddItem(?Cancel,RequestCancelled) !register Cancel with ThisWindow
SELF.SetAlerts() !alert keys for ThisWindow
RETURN ReturnValue
ThisWindow.Kill PROCEDURE() !shut down things
ReturnValue BYTE,AUTO
CODE
ReturnValue = PARENT.Kill() !call base class shut down
Relate:Customer.Close !close Customer and related files
Relate:Customer.Kill !shut down Relate:Customer object
GlobalErrors.Kill !shut down GlobalErrors object
RETURN ReturnValue
ThisProcess.TakeRecord PROCEDURE() !action for each record processed
ReturnValue BYTE,AUTO
CODE
IF NOT CUS:State !if State is blank
CUS:State = 'FL' ! set it to 'FL'
END
ReturnValue = PARENT.TakeRecord() !call base class for each record
PUT(CusView) !write the updated record
IF ERRORCODE() !if write failed
ThisWindow.Response = RequestCompleted ! shut down process
ReturnValue = Level:Fatal !Use IF Relate:Customer.Update()
END !to apply RI constraints to
RETURN ReturnValue ! Customer and related files.
Access:Customer.Init PROCEDURE
CODE
PARENT.Init(Customer,GlobalErrors)
SELF.FileNameValue = 'Customer'
SELF.Buffer &= CUS:Record
SELF.LazyOpen = False
SELF.AddKey(CUS:BYNUMBER,'CUS:BYNUMBER',0)
Relate:Customer.Init PROCEDURE
CODE
Access:Customer.Init
PARENT.Init(Access:Customer,1)