: Automate and process repetitive tasks with this automation program
// Read: Copyright © Thomas Schulz, all rights reserved.
// Contact: Primary: thomas#microsystools.com. Secondary: dk_sz#hotmail.com.
// Can only be used when making modules for "Micro-Sys MultiBatcher".
//------------------------------------------------------------------------------
{$I AImsCoreDefines.inc}
unit LUmsPluginAllSharedBaseCore;
interface
uses
SysUtils
,
LUmsCommonAllSharedDeclars
,
LUmsCommonAllSharedDeclarsOO
;
//------------------------------------------------------------------------------
{
External plugins developed in Delphi can use:
* LUmsPluginAllSharedBaseCore (this)
They only need to use *this* unit and inherit from *TPluginExternal*
(which inherits from LUmsCommonAllSharedDeclarsOO / *TPluginShared*)
...
This unit is something application calls on plugin call...
}
//------------------------------------------------------------------------------
var
// *TExeParamsDataAll*
invLanguage: string = '';
invPluginFilePathName: string = '';
invPluginFilePath: string = '';
// *TExeParamsDataWork*
inv_work_BatchRootPath: string = '';
// *TExeParamsProcInit*
// general/all
invpExeMakePropName: TProcExeMakePropName = nil;
// grid
invpExeSetPropMetasGrid: TProcExeSetPropMetasGrid = nil;
// TExeParamsProcPreEdit
// choice::single + multiple
invpExeSetPropChoiceValueCount: TProcExeSetPropChoiceValueCount = nil;
invpExeAddPropChoiceValue: TProcExeAddPropChoiceValue = nil;
// textboxes
invpExeSetPropTextBoxValueCount: TProcExeSetPropTextBoxValueCount = nil;
invpExeSetPropTextBoxValue: TProcExeSetPropTextBoxValue = nil;
// grid
invpExeSetPropGridColumnCount: TProcExeSetPropGridColumnCount = nil;
invpExeAddPropGridColumn: TProcExeAddPropGridColumn = nil;
invpExeSetPropDefaultGridValueCount: TProcExeSetPropDefaultGridValueCount = nil;
invpExeAddPropDefaultGridValue: TProcExeAddPropDefaultGridValue = nil;
// file
invpExeSetPropDefaultFileValue: TProcExeSetPropDefaultFileValue = nil;
// *TExeParamsProcEdit*
// *TExeParamsProcWork*
// general/all
invpExeHandleWorkPathErrorMsg_Ansi: TProcExeHandleWorkPathErrorMsg_Ansi = nil;
invpExeHandleWorkPathErrorMsg_Wide: TProcExeHandleWorkPathErrorMsg_Wide = nil;
invpExeRequestAddPathToBatch: TProcExeRequestAddPathToBatch = nil;
//------------------------------------------------------------------------------
// plugin special
function PluginReturnInfo(ExeParamsDataAll: PExeParamsDataAll): PPluginInfo; {$I AImsCC.inc}
procedure PluginSetupInit(ExeParamsDataAll: PExeParamsDataAll; ExeParamsProc: PExeParamsProcInit); {$I AImsCC.inc}
procedure PluginSetupPreEdit(ExeParamsDataAll: PExeParamsDataAll; ExeParamsProc: PExeParamsProcPreEdit); {$I AImsCC.inc}
procedure PluginSetupEdit(ExeParamsDataAll: PExeParamsDataAll; ExeParamsProc: PExeParamsProcEdit); {$I AImsCC.inc}
procedure PluginSetupWorkStart(ExeParamsDataAll: PExeParamsDataAll; ExeParamsDataWork: PExeParamsDataWork; ExeParamsProc: PExeParamsProcWork); {$I AImsCC.inc}
procedure PluginSetupWorkStartDone; {$I AImsCC.inc}
procedure PluginSetupWorkEnd(ExeParamsDataAll: PExeParamsDataAll); {$I AImsCC.inc}
// general/all (work)
procedure PluginWorkPath(PluginPassedReadInProps: PPluginPassedReadInProps; PluginPassedWriteOutProps: PPluginPassedWriteOutProps); {$I AImsCC.inc}
// choice::multiple (work)
procedure PluginSetPropChoiceValueCount(PropName: PAnsiChar; PropValueCount: Integer); {$I AImsCC.inc}
// choice::single + multiple (work)
procedure PluginSetPropChoiceValue(PropName: PAnsiChar; ChoiceID: PAnsiChar); {$I AImsCC.inc}
// textboxes (edit)
procedure PluginVerifyPropTextBoxValue(PropName: PAnsiChar; TextBoxID: PAnsiChar; PropValue: PWideChar; ExeCallBack: TProcExeHandleEditPropTextBoxErrorMsg); {$I AImsCC.inc}
// textboxes (work)
procedure PluginSetPropTextBoxValue(PropName: PAnsiChar; TextBoxID: PAnsiChar; PropValue: PWideChar); {$I AImsCC.inc}
// grid (edit)
procedure PluginPrepareVerifyGridRow(PropName: PAnsiChar); {$I AImsCC.inc}
procedure PluginAddVerifyPropGridValue(PropName: PAnsiChar; PropValue: PWideChar); {$I AImsCC.inc}
procedure PluginEndVerifyGridRow(PropName: PAnsiChar; ExeCallBack: TProcExeHandleEditPropGridErrorMsg); {$I AImsCC.inc}
// grid (work)
procedure PluginSetPropGridValueCount(PropName: PAnsiChar; ValueCount: Integer); {$I AImsCC.inc}
procedure PluginSetPropGridValue(PropName: PAnsiChar; ColID: PAnsiChar; RowIdx: Integer; FieldValue: PWideChar); {$I AImsCC.inc}
// file (edit)
procedure PluginVerifyPropFileValue(PropName: PAnsiChar; FullFilePathName: PWideChar; ExeCallBack: TProcExeHandleEditPropFileErrorMsg); {$I AImsCC.inc}
// file (work)
procedure PluginSetPropFileValue(PropName: PAnsiChar; FullFilePathName: PWideChar); {$I AImsCC.inc}
//------------------------------------------------------------------------------
exports
// plugin special
PluginReturnInfo
,
PluginSetupInit
,
PluginSetupPreEdit
,
PluginSetupEdit
,
PluginSetupWorkStart
,
PluginSetupWorkStartDone
,
PluginSetupWorkEnd
,
// general/all (work)
PluginWorkPath
,
// choice::single + multiple (work)
PluginSetPropChoiceValue
,
// choice::multiple (work)
PluginSetPropChoiceValueCount
,
// textboxes (edit)
PluginVerifyPropTextBoxValue
,
// textboxes (work)
PluginSetPropTextBoxValue
,
// grid (edit)
PluginPrepareVerifyGridRow
,
PluginAddVerifyPropGridValue
,
PluginEndVerifyGridRow
,
// grid (work)
PluginSetPropGridValueCount
,
PluginSetPropGridValue
,
// file (edit)
PluginVerifyPropFileValue
,
// file (work)
PluginSetPropFileValue
;
//------------------------------------------------------------------------------
{
If you want to benefit from this unit do following:
* Inherit a new class from *TPluginExternal* overriding the methods you need.
* Set *invPluginExternalClass* equal to your new descendant class (not instance!)
in initializaton (see demos).
Notes:
* You do not have to worry about freeing or creating instances of this class!
}
//------------------------------------------------------------------------------
type
TPluginExternalClass = class of TPluginExternal;
TPluginExternal = class(TPluginSharedComm)
protected
procedure CallErrorCommon(const AError: string); override;
end;
//------------------------------------------------------------------------------
var
invPluginExternalClass: TPluginExternalClass = nil;
//------------------------------------------------------------------------------
implementation
var
imvPluginExternal: TPluginExternal = nil;
{ TPluginExternal }
//------------------------------------------------------------------------------
procedure TPluginExternal.CallErrorCommon(const AError: string);
begin
inherited;
// AError + ' . In plugin: "' + invPluginFilePathName + '". Error: "Not implemented"'
// implement something here ..
end;
// own
//------------------------------------------------------------------------------
procedure OwnCreateInitPlugin(ExeParamsDataAll: PExeParamsDataAll);
begin
// this class instance is freed on *finalization*
if imvPluginExternal = nil then
begin
if Assigned(invPluginExternalClass) then
imvPluginExternal := invPluginExternalClass.Create
else
imvPluginExternal := TPluginExternal.Create
;
end;
//--
{
All incoming data is guranteed to be assigned and it has to be copied.
Delphi copies data automaticly when assigning a *string* to *PChar*.
}
with ExeParamsDataAll^ do
begin
invLanguage := Language;
invPluginFilePathName := PluginFilePathName;
end;
invPluginFilePath := ExtractFilePath(invPluginFilePathName)
end;
// plugin special
//------------------------------------------------------------------------------
function PluginReturnInfo(ExeParamsDataAll: PExeParamsDataAll): PPluginInfo;
begin
OwnCreateInitPlugin(ExeParamsDataAll);
{
Result will typically be set to address of a const instance of a structure
(or one that at least is kept in memory for whole plugin lifetime).
If you return the data in "automatic", i.e. so the memory is freed when the
function ends, the exe_application does not receive a valid result.
//--
Notice that *ExeParamsDataAll* is included to return info can return different
results depending on e.g. language.
}
Result := imvPluginExternal.PluginReturnInfo;
end;
//------------------------------------------------------------------------------
procedure PluginSetupInit(ExeParamsDataAll: PExeParamsDataAll; ExeParamsProc: PExeParamsProcInit);
begin
OwnCreateInitPlugin(ExeParamsDataAll);
with ExeParamsProc^ do
begin
// general/all
invpExeMakePropName := ProcExeMakePropName;
// grid
invpExeSetPropMetasGrid := ProcExeSetPropMetasGrid;
end;
imvPluginExternal.PluginSetupInit;
end;
//------------------------------------------------------------------------------
procedure PluginSetupPreEdit(ExeParamsDataAll: PExeParamsDataAll; ExeParamsProc: PExeParamsProcPreEdit);
begin
OwnCreateInitPlugin(ExeParamsDataAll);
with ExeParamsProc^ do
begin
// choice::single + multiple
invpExeSetPropChoiceValueCount := ProcExeSetPropChoiceValueCount;
invpExeAddPropChoiceValue := ProcExeAddPropChoiceValue;
// textboxes
invpExeSetPropTextBoxValueCount := ProcExeSetPropTextBoxValueCount;
invpExeSetPropTextBoxValue := ProcExeSetPropTextBoxValue;
// grid
invpExeSetPropGridColumnCount := ProcExeSetPropGridColumnCount;
invpExeAddPropGridColumn := ProcExeAddPropGridColumn;
invpExeSetPropDefaultGridValueCount := ProcExeSetPropDefaultGridValueCount;
invpExeAddPropDefaultGridValue := ProcExeAddPropDefaultGridValue;
// file
invpExeSetPropDefaultFileValue := ProcExeSetPropDefaultFileValue;
end;
imvPluginExternal.PluginSetupPreEdit;
end;
//------------------------------------------------------------------------------
procedure PluginSetupEdit(ExeParamsDataAll: PExeParamsDataAll; ExeParamsProc: PExeParamsProcEdit);
begin
OwnCreateInitPlugin(ExeParamsDataAll);
with ExeParamsProc^ do
begin
end;
imvPluginExternal.PluginSetupEdit;
end;
//------------------------------------------------------------------------------
procedure PluginSetupWorkStart(ExeParamsDataAll: PExeParamsDataAll; ExeParamsDataWork: PExeParamsDataWork; ExeParamsProc: PExeParamsProcWork);
begin
{
*PluginSetupWorkStart* function is ran before any property data is initted.
}
OwnCreateInitPlugin(ExeParamsDataAll);
{
Here we make sure the memory manager (if needed) can handle threading. It is
necessary if plugin is to handle calls from multiple threads to
*PluginWorkPath* (e.g. if it marked itself as capable of such!).
}
{$IFDEF mymsBorlRTL}
IsMultiThread := True;
{$ENDIF}
//--
with ExeParamsDataWork^ do
begin
inv_work_BatchRootPath := BatchRootPath;
end;
//--
with ExeParamsProc^ do
begin
// general/all
invpExeHandleWorkPathErrorMsg_Ansi := ProcExeHandleWorkPathErrorMsg_Ansi;
invpExeHandleWorkPathErrorMsg_Wide := ProcExeHandleWorkPathErrorMsg_Wide;
invpExeRequestAddPathToBatch := ProcExeRequestAddPathToBatch;
end;
imvPluginExternal.PluginSetupWorkStart;
end;
//------------------------------------------------------------------------------
procedure PluginSetupWorkStartDone;
begin
imvPluginExternal.PluginSetupWorkStartDone;
end;
//------------------------------------------------------------------------------
procedure PluginSetupWorkEnd(ExeParamsDataAll: PExeParamsDataAll);
begin
OwnCreateInitPlugin(ExeParamsDataAll);
imvPluginExternal.PluginSetupWorkEnd;
end;
// general/all (work)
//------------------------------------------------------------------------------
procedure PluginWorkPath(PluginPassedReadInProps: PPluginPassedReadInProps; PluginPassedWriteOutProps: PPluginPassedWriteOutProps);
begin
(*
*PluginPassedWriteOutProps* is already initted by application:
--------------------------------------------------------------
WorkPathNameOut "same value" as WorkPathNameIn
AdviseThisBatchStop := False;
AdviseProjectBatchStop := False;
AdviseMainBatchStop := False;
*)
imvPluginExternal.PluginWorkPath(PluginPassedReadInProps, PluginPassedWriteOutProps);
end;
// choice::multiple (work)
//------------------------------------------------------------------------------
procedure PluginSetPropChoiceValueCount(PropName: PAnsiChar; PropValueCount: Integer);
begin
imvPluginExternal.PluginSetPropChoiceValueCount(PropName, PropValueCount);
end;
// choice::single + multiple (work)
//------------------------------------------------------------------------------
procedure PluginSetPropChoiceValue(PropName: PAnsiChar; ChoiceID: PAnsiChar);
begin
imvPluginExternal.PluginSetPropChoiceValue(PropName, ChoiceID);
end;
// textboxes (edit)
//------------------------------------------------------------------------------
procedure PluginVerifyPropTextBoxValue(PropName: PAnsiChar; TextBoxID: PAnsiChar; PropValue: PWideChar; ExeCallBack: TProcExeHandleEditPropTextBoxErrorMsg);
begin
imvPluginExternal.PluginVerifyPropTextBoxValue(PropName, TextBoxID, PropValue, ExeCallBack);
end;
// textboxes (work)
//------------------------------------------------------------------------------
procedure PluginSetPropTextBoxValue(PropName: PAnsiChar; TextBoxID: PAnsiChar; PropValue: PWideChar);
begin
imvPluginExternal.PluginSetPropTextBoxValue(PropName, TextBoxID, PropValue);
end;
// grid (edit)
//------------------------------------------------------------------------------
procedure PluginPrepareVerifyGridRow(PropName: PAnsiChar);
begin
imvPluginExternal.PluginPrepareVerifyGridRow(PropName);
end;
//------------------------------------------------------------------------------
procedure PluginAddVerifyPropGridValue(PropName: PAnsiChar; PropValue: PWideChar);
begin
imvPluginExternal.PluginAddVerifyPropGridValue(PropName, PropValue);
end;
//------------------------------------------------------------------------------
procedure PluginEndVerifyGridRow(PropName: PAnsiChar; ExeCallBack: TProcExeHandleEditPropGridErrorMsg);
begin
imvPluginExternal.PluginEndVerifyGridRow(PropName, ExeCallBack);
end;
// grid (work)
//------------------------------------------------------------------------------
procedure PluginSetPropGridValueCount(PropName: PAnsiChar; ValueCount: Integer);
begin
imvPluginExternal.PluginSetPropGridValueCount(PropName, ValueCount);
end;
//------------------------------------------------------------------------------
procedure PluginSetPropGridValue(PropName: PAnsiChar; ColID: PAnsiChar; RowIdx: Integer; FieldValue: PWideChar);
begin
// RowIdx is zero-based (starts from first non-fixed row)
imvPluginExternal.PluginSetPropGridValue(PropName, ColID, RowIdx, FieldValue);
end;
// file (edit)
//------------------------------------------------------------------------------
procedure PluginVerifyPropFileValue(PropName: PAnsiChar; FullFilePathName: PWideChar; ExeCallBack: TProcExeHandleEditPropFileErrorMsg);
begin
imvPluginExternal.PluginVerifyPropFileValue(PropName, FullFilePathName, ExeCallBack);
end;
// file (work)
//------------------------------------------------------------------------------
procedure PluginSetPropFileValue(PropName: PAnsiChar; FullFilePathName: PWideChar);
begin
imvPluginExternal.PluginSetPropFileValue(PropName, FullFilePathName);
end;
//------------------------------------------------------------------------------
initialization
finalization
FreeAndNil(imvPluginExternal);
end.
This file is part of Automation Batch Tools. All rights reserved. See legal.