BpcSMScriptLibrary 11

From RiskWiki

Jump to: navigation, search

Contents

TClientDataSet BPC Library

Language: Delphi 7 - 2007


This library delivers the stringgrid manipulations and enhancements to directly to Delphi ClientDataSets, as well as a few additional useful facilities.


Currently Implemented

//////////////////////////////////////////////////////////////////////////////////////////
//////// TClientDataSet BPC Library
//////////////////////////////////////////////////////////////////////////////////////////

interface
uses Classes, Types,  Windows, Grids, DB, DBClient;

Type
TbpcCDSLoadDLMStrOnSetFieldValue = procedure ( myTargCDS: TClientDataSet; sImportFieldName : string; var sImportFieldValue : string; var bAllowed : boolean ) of object;

//////////////////////////////////////////////////
// TClientDataSet BPC Library

Not currently implemented

// Copy the selected rows from the grid into the clipboard as an smXMLPacket
// Returns true if the clipboard is non-empty
function bpcsmXMLCDSGrid1Copy( Sender: TClientDataSet) : boolean;
// Copy the selected rows from the grid into the clipboard as a CSV packet
// Returns true if the clipboard is non-empty
function bpcCSVCDSGrid1Copy( Sender: TClientDataSet) : boolean;
function bpcTABCDSGrid1Copy( Sender: TClientDataSet) : boolean;
// Paste into the stringgrid as a CSV, TAB, XML string and return the string
function bpcXMLCDSGrid1Paste( Sender: TClientDataSet) : TClientDataSet;
function bpcCSVCDSGrid1Paste( Sender: TClientDataSet) : TClientDataSet;
function bpcTABCDSGrid1Paste( Sender: TClientDataSet) : TClientDataSet;

Currently Implemented

// Write the TClientDataSet to a string as a CSV file and return the string
function bpcCDSWriteTABString(myStringGrid1: TClientDataSet ) : string;
// Write the TClientDataSet to a string as a CSV file and return the string
function bpcCDSWriteCSVString(myStringGrid1: TClientDataSet ) : string;
// Read in a CSV string - the first row MUST BE the headings.  Strings are marked by "" and ',' are separators.
// If bGrowFromLastRow is true, the file will be added to theend of the stringgrid without clearing, if bClearGrid is true all
// columns will be cleared.  FixedCols is the number of fixed columns from the left, while StartCol says which col to start
// inserting data, while FixedColsList is a comma separated list of headings for the fixed columns portion (assuming the
// startcol is after the fied cols. The CSVString is the CSV string to be imported.  Returns the
// stringgrid.
function bpcCDSLoadFromTable( myStringGrid1: TClientDataSet; bGrowFromLastRow: boolean; bClearGrid: boolean; StartCol : integer; FileContents: TDataSet): TClientDataSet; overload;
function bpcCDSLoadCSVFile( myStringGrid1: TClientDataSet; bGrowFromLastRow: boolean; bClearGrid: boolean; StartCol : integer; FileName: string; QuotesAreDoubled : boolean ): TClientDataSet; overload;
function bpcCDSLoadDLMString( myStringGrid1: TClientDataSet; csvFieldList : array of string; bNullOnEmptyVal : boolean; bGrowFromLastRow: boolean; bClearGrid: boolean; StartCol : integer; MyOnFieldWrite : TbpcCDSLoadDLMStrOnSetFieldValue; CSVString: string; Delim : char ): TClientDataSet; overload;
function bpcCDSLoadCSVString( myStringGrid1: TClientDataSet; csvFieldList : array of string; bNullOnEmptyVal : boolean; bGrowFromLastRow: boolean; bClearGrid: boolean; FixedCols, StartCol : integer; FixedColsList: string; MyOnFieldWrite : TbpcCDSLoadDLMStrOnSetFieldValue; CSVString: string): TClientDataSet; overload;
function bpcCDSLoadTABString( myStringGrid1: TClientDataSet; csvFieldList : array of string; bNullOnEmptyVal : boolean; bGrowFromLastRow: boolean; bClearGrid: boolean; FixedCols, StartCol : integer; FixedColsList: string; MyOnFieldWrite : TbpcCDSLoadDLMStrOnSetFieldValue; CSVString: string): TClientDataSet; overload;
function bpcCDSLoadTABString( myStringGrid1: TClientDataSet; csvFieldList : array of string; bNullOnEmptyVal : boolean; bGrowFromLastRow: boolean; bClearGrid: boolean; StartCol : integer; MyOnFieldWrite : TbpcCDSLoadDLMStrOnSetFieldValue; CSVString: string): TClientDataSet; overload;
function bpcCDSLoadTABString( myStringGrid1: TClientDataSet; bGrowFromLastRow: boolean; bClearGrid: boolean; StartCol : integer; CSVString: string): TClientDataSet; overload;
//function bpcCDSLoadDLMString( myStringGrid1: TClientDataSet; bGrowFromLastRow: boolean; bClearGrid: boolean; FixedCols, StartCol : integer; FixedColsList: string; CSVString: string; Delim : char ): TClientDataSet; overload;
// Read in a CSV file - the first row MUST BE the headings.  Strings are marked by "" and ',' are separators.
// If bGrowFromLastRow is true, the file will be added to theend of the stringgrid without clearing, if bClearGrid is true all
// columns will be cleared.  FixedCols is the number of fixed columns from the left, while StartCol says which col to start
// inserting data, while FixedColsList is a comma separated list of headings for the fixed columns portion (assuming the
// startcol is after the fied cols. The FileName is the full path including filename to the csv file to be imported.  Returns the
// stringgrid.
// eg: bpcCDSLoadCSVFile( StringGrid1,(MergeRowsDSCBX.Checked), (not (MergeRowsDSCBX.Checked or MergeColsDSCBX.Checked)), 1, iff(MergeColsDSCBX.Checked,StringGrid1.ColCount,1), 'Status', FileName );
//function bpcCDSLoadCSVFile( myStringGrid1: TClientDataSet; bGrowFromLastRow: boolean; bClearGrid: boolean; FixedCols, StartCol : integer; FixedColsList: string; FileName: string; QuotesAreDoubled : boolean=false ): TClientDataSet;
// Read in a dtatset - the fieild names are used as the headings of the grid.
// If bGrowFromLastRow is true, the file will be added to theend of the stringgrid without clearing, if bClearGrid is true all
// columns will be cleared.  FixedCols is the number of fixed columns from the left, while StartCol says which col to start
// inserting data, while FixedColsList is a comma separated list of headings for the fixed columns portion (assuming the
// startcol is after the fied cols. The FileContents is the tdataset to be imported, which will be opened if necessary,
// and repositioned at the first record after completion. Returns the stringgrid.
// eg: bpcCDSLoadFromTable( StringGrid1, (MergeRowsDSCBX.Checked), (not (MergeRowsDSCBX.Checked or MergeColsDSCBX.Checked)), 1, iff(MergeColsDSCBX.Checked,StringGrid1.ColCount,1), 'Status', FileContents );
//function bpcCDSLoadFromTable( myStringGrid1: TClientDataSet; bGrowFromLastRow: boolean; bClearGrid: boolean; FixedCols, StartCol : integer; FixedColsList: string; FileContents: TDataSet): TClientDataSet;

// Returns the column index of the stringgrid col corresponding to the colname
function bpcCDSIndexOfCDSCol( myStringGrid1: TClientDataSet; colname : string ) : integer;



Deprecated Routines

These are stringrid routines that are not relevant in CDS or are considered unsafe in database contexts. These rountines have been removed from the V3 libraries onwards.


// Fill a stringgrid column targcol with an (optionally incrementing) Mask of chars, or with GUID's, FromRow ToRowand and return the stringgrid
// OVERLOADED FUNCTION
//      bpcCDSFillRows( StringGrid1, FromRow,  ToRow, MakeGUIDs, Mask, MaskChar, StartString, IncrementBy, OnlyNums )
// eg: bpcCDSFillRows( StringGrid1, StringGrid1.Col, FromRow,  ToRow, FillColumnDlg.UseGUIDCBX.Checked, FillColumnDlg.FillMask.Text, iff( FillColumnDlg.UseMaskCharCBX.Checked, iff( length(FillColumnDlg.MaskChar.Text)>0, FillColumnDlg.MaskChar.Text[1], '#'), #0 ), trim(FillColumnDlg.StartString.Text) ,iff( FillColumnDlg.IncrementCBX.Checked, FillColumnDlg.Incrementer.AsInteger, 0 ), FillColumnDlg.NumsOnlyCBX.Checked );
function bpcCDSFillRows( myStringGrid1: TClientDataSet; targcol : integer; FromRow,  ToRow : integer; MakeGUIDs : boolean; Mask : string; MaskChar : char; StartString : string; IncrementBy : integer; OnlyNums  : boolean ) : TClientDataSet; overload;
// Fill a stringgrid column targcol with GUID's FromRow ToRowand and return the stringgrid
// OVERLOADED FUNCTION
function bpcCDSFillRows( myStringGrid1: TClientDataSet; targcol : integer; FromRow,  ToRow : integer; MakeGUIDs : boolean ) : TClientDataSet; overload;
// Write the stringgrid to a file called sFileName as a CSV file
procedure bpcCDSWriteCSVFile(myStringGrid1: TClientDataSet; sFileName : string);
// Insert a new blank col at curcol in a stringgrid col returning the stringgrid
function bpcCDSDeleteCol( myStringGrid1: TClientDataSet; TargCol : integer ) : TClientDataSet;
// Delete the row at targrow in a stringgrid returning the stringgrid
function bpcCDSDeleteRow( myStringGrid1: TClientDataSet; TargRow : integer ) : TClientDataSet;
// Delete the rows in a stringgrid preserving the header row if includeHeader is false and returning the stringgrid
function bpcCDSDeleteAllRows( myStringGrid1: TClientDataSet; includeHeader : boolean ) : TClientDataSet;
// Insert a new blank col at curcol in a stringgrid col returning the stringgrid
function bpcCDSInsertCol( myStringGrid1: TClientDataSet; CurCol : integer ) : TClientDataSet;
// Insert a new blank row at currow in a stringgrid row returning the stringgrid
function bpcCDSInsertRow( myStringGrid1: TClientDataSet; CurRow : integer ) : TClientDataSet;
// Clear the contents of a stringgrid col at targcol
function bpcCDSClearCol( myStringGrid1: TClientDataSet; targcol : integer ) : TClientDataSet;
// Clear the contents of a stringgrid row at targrow
function bpcCDSClearRow( myStringGrid1: TClientDataSet; targrow : integer ) : TClientDataSet;
// Clear all the contents of a stringgrid preserving the header row if includeHeader is false and returning the stringgrid
function bpcCDSClearAllRows( myStringGrid1: TClientDataSet; includeHeader : boolean ) : TClientDataSet;


{
// Returns true if the stringgrid row is empty
function bpcCDSIsEmptyRow( myStringGrid1: TClientDataSet; targrow : integer ) : boolean;
// Copies a StringGrid col fromcol tocol and returns the index of the col after the tocol
function bpcCDSCopyCol( myStringGrid1: TClientDataSet; tocol, fromcol : integer ) : integer;
// Copies a StringGrid row fromrow torow and returns the index of the row after the torow
function bpcCDSCopyRow( myStringGrid1: TClientDataSet; torow, fromrow : integer ) : integer;
}

BackLinks



CopyRight Bishop Phillips Consulting Pty Ltd 1997-2012 ( BpcSMScriptLibrary 11 )
Personal tools