Вы здесь

Class ArrayServer for CA-Visual Objects

Array
 
 
Ready library of a class for operation with arrays, as with a database server (DbServer). It is created by analogy to bArrayServer (bBrowser).
 
 
Advantages and features:
 
  • Syntax completely from the class DbServer (full compatibility of a code)
  • In a mode of compatibility of data with DBF (AS_DATAFORMAT_DBASE) – high security from programming errors ("protection against the fool")
  • The fastest mode - AS_DATAFORMAT_FAST (as in bArrayServer - BDATAFORMAT_NORMAL)
  • In a normal mode (AS_DATAFORMAT_NORMAL) – operation speed in comparison with bArrayServer – above (for example, in case of creation of orders - 1.92%).
For CA-Visual Objects 2.8 SP3
 
 
 
From the author.
By the nature of the activities I had to apply uncommon decisions to achievement of goals. And it is frequent, to convenience of viewing and information processing I apply arrays. And for convenience of operation with arrays – ArrayServer (array-server).
 
Until recently as ArrayServer used bArrayServer. But, during operation I was stimulated to enter a set of changes. And, some time ago I corresponded with the author of library, having suggested it to make corrections. The author of bArrayServer recommended to me to write the class.
 
And by the end of summer of 2012 work was made.
 
 
 
Short description
 
Data formats ArrayServer:
            AS_DATAFORMAT_FAST
            AS_DATAFORMAT_NORMAL
            AS_DATAFORMAT_DBASE
 
When using the AS_DATAFORMAT_FAST and AS_DATAFORMAT_NORMAL formats - two types of fields are added:
            "O" – objects
            "U" – usual
 
For these types of fields it isn't controlled their lengths (but by DBS_LEN must be > 0).
 
When using AS_DATAFORMAT_FAST format - it is considered that the user (programmer) does everything correctly, monitoring over data is reduced. It increases operation speed.
 
When using AS_DATAFORMAT_NORMAL format - verification of read-out data (only for DBASE of types of fields) and their adjustment to a required format is added.
 
When using AS_DATAFORMAT_DBASE format - the DBASE type fields are admissible only. Complete control is made in case of read operations and data record.
 
Database structure check is made:
  1. In case of DBASE formats from names of fields gaps and their length are removed is restricted to 10 characters.
  2. Restrictions on lengths of fields are inserted.
  3. For digital fields length of decimal part <= (total length - 3)
 
The Use( ) method allows to change and a body of a DB and to add other data (copying of data).
As well as for DbServer – SetOrderCondition( ) operation is made.
Operation with Custom, Unique-warrants and so forth is allowed. Generally, in difference from bArrayServer, all installations of SetOrderCondition( ) are involved.
 
Since by operation with ArrayServer disk operations aren't provided (it not the file), the buffer size - zero. Operation with the buffer of data - isn't provided.
 
Since it not a file server, locks actually don't work (they aren't necessary). RLock( ), RLockVerify( ), UnLock( ), etc. - always return TRUE. __ NotifyBufferFlush( ) - too does nothing.
But, all these methods are left for compatibility!
 
The server uses ANSI character set. See: Info( DBI_ISANSI ).
 
Orders.
  1. As well as in the environment of DBF, in this class creation of incomplete warrants is possible. I.e. orders which don't contain key expressions for all records (somehow: Custom, Unique and so forth). Therefore in case of change of the order there can always be a situation when it is impossible to define a key line item for the current record.
  2. As well as in the environment of DBF, in case of order change - the line item of record doesn't change (remains former) irrespective of, the appropriate line item of a key is found or not. For the solution of possible contradictions, as well as in DBF, it is recommended to use Seek( ).
  3. Since servers while works only with ANSI character set, key expressions - too in it.
 
Attention! Important information on the decimal separation character in key expressions. (In case of creation of orders with conversion: Str( NumberField )). Since characters of separators of discharges and fractional parts randomly don't change, they can be changed only in the absence of orders. The type of these delimiting characters is fixed by the server in case of order creation. If delimiting characters have to be changed, at first it is necessary to close (to delete) all orders, then – to set necessary, and to recreate orders again. Respectively, OrderInfo( DBOI_KEYVAL ) - will give out value taking into account the separators set for the server now. See: Info( DBI_GETDELIMETER ), Info( DBI_SETDELIMETER ).
 
SetRelation, etc.
We can establish connection with the Detail-server. And here DbServer as the Master-server for us, most likely, won't be able to be since it works through алиас. And at us алиаса isn't present. The problem can be bypassed, having made SubClassing and, having written for your new class the suitable SetRelation( ) method. (See bDbServer:SetRelation( ) from bBrowser library).
 
The Master-server can be only one.
The Detail-servers - is so much, how many it is necessary.
 
 
Notes:
Class while without methods: Scope( ) and Eval( ). In principle, the kernel for use of the Scope( ) methods and Eval( ) – is made. Already created methods allow working with them. Interested persons can quietly complete it.
 
That for this purpose it is necessary:
 
  1. ClearScope( )
  2. Eval( )
  3. ForBlock:ACCESS
  4. ForBlock:ASSIGN
  5. Scope:ACCESS
  6. Scope:ASSIGN
  7. WhileBlock:ACCESS
  8. WhileBlock:ASSIGN
 
 
 
Differences from the classes DbServer and msArrayServer
 
METHOD Init( auStruct [, auData] [, wDataFormat] [, lReadOnly] ) CLASS msArrayServer
Arguments:
auStruct            - A two-dimensional array that defines the field structure of the server. The first dimension of the array defines the fields. The second dimension defines the structure of each field.
 
The second dimension consists of five elements that are described in the following table:
Constant
Data type
Description
DBS_NAME
String
Name of field.
DBS_TYPE
String
Data type of field.
DBS_LEN
Integer
Length of field, including the decimal point and the decimal places.
DBS_DEC
Integer
Number of decimals.
DBS_ALIAS
String
Alias of field.
 
auData             - A two-dimensional array that contains the records of the server. The array has the format { {aRecord1}, {aRecord2},…{aRecordn} } where each record is {ufield1, uField2, …}.
wDataFormat   - The mode of data. The following values are supported:
 
Constant
Description
AS_DATAFORMAT_FAST
There is no verification of data (as in bArrayServer - BDATAFORMAT_NORMAL).
AS_DATAFORMAT_NORMAL
Simple verifications of data become (as in bArrayServer - BDATAFORMAT_DBASE). Default value.
AS_DATAFORMAT_DBASE
All necessary verifications of the input and output data (as in DbServer).
 
 
 
METHOD ClearOrder( [ <cOrder> | <nPosition> ] ) CLASS msArrayServer
 
            // Description    : Remove single or all orders associated with the data.
            // Parameters    : [<cOrder> | <nPosition>]
            // Returns         : LOGIC
 
Note:   Unlike bArrayServer: if the specified warrant isn't present – TRUE returned value.
 
 
METHOD ClearSelection( ) AS VOID PASCAL CLASS msArrayServer
            // Description    : Completion of work with the Master-server (Master-Detail mode).
            // Parameters    : No
            // Returns         : VOID
 
 
ASSIGN DataFormat( wNewValue AS DWORD ) AS DWORD PASCAL CLASS msArrayServer
            // Description    : Sets new mode of data.
            // Parameters    : DWORD
            // Returns         : DWORD (New Mode)
 
            wNewValue:
 
Constant
Description
AS_DATAFORMAT_FAST
There is no verification of data (as in bArrayServer - BDATAFORMAT_NORMAL).
AS_DATAFORMAT_NORMAL
Simple verifications of data become (as in bArrayServer - BDATAFORMAT_DBASE). Default value.
AS_DATAFORMAT_DBASE
All necessary verifications of the input and output data (as in DbServer).
 
 
 
ASSIGN SetViewDeleted( wNewValue AS DWORD ) AS DWORD PASCAL CLASS msArrayServer
            // Description    : Sets a new browse mode of deleted records.
            // Parameters    : DWORD
            // Returns         : DWORD (New Mode)
 
wNewValue     - A numeric value that indicates how deleted records are to be treated. The following values are supported:
 
Constant
Description
AS_VIEWDELETED_FALSE
Deleted records are hidden.
AS_VIEWDELETED_TRUE
Deleted records are visible.
AS_VIEWDELETED_AUTO
The setting of the function SetDeleted() is used.
 
 
 
METHOD Use( auData AS ARRAY, lAppend := FALSE AS LOGIC ) AS LOGIC PASCAL ;
CLASS msArrayServer
 
            // Description: Sets an array with data that contains the records of the server.
            // Parameters : auData, lAppend
            // Returns    : LOGIC
 
auData             - A two-dimensional array that contains the records of the server. The array has the format { {aRecord1}, {aRecord2},…{aRecordn} } where each record is {ufield1, uField2, …}.
 
lAppend           - If FALSE (default) - Sets an array with data that contains the records of the server. If TRUE - is made addition of data (as ACopy( )).
 
 
 
METHOD Delete( [cForCondition | cbForCondition], [cWhileCondition | cbWhileCondition],;
         [uScope], [lMark] ) CLASS msArrayServer
            // Description  : Delete the current record or the records specified with the scoping parameters.
            // Parameters :  [cForCondition | cbForCondition],;
                 //                 [cWhileCondition | cbWhileCondition],;
                 //                 [uScope],;
                 //                 [lMark]
            // Returns       : LOGIC (TRUE if successful; otherwise, FALSE)
 
Arguments:
 
If no parameters are specified, Delete() is subject to the server scope set with the msArrayServer ForBlock, WhileBlock and Scope access/assign methods.  If not set, this server scope defaults to "no scope," and the method processes the current record.
 
cForCondition | cbForCondition              – The condition evaluated for each record in the scope; if TRUE, the record is included in the processing.  It provides the same functionality as the FOR clause of record processing commands.
 
cWhileCondition | cbWhileCondition        – The condition evaluated for each record from the current record until the condition returns FALSE.  It provides the same functionality as the WHILE clause of record processing commands.
 
uScope          – The range of records to process, providing the same functionality as the ALL, REST and NEXT clauses of record processing commands.
 
uScope
Description
DBSCOPEALL
The scope is all the records in the table.  This is the default, although if a WHILE condition is specified, the scope becomes DBSCOPEREST.
DBSCOPEREST
The scope is the remaining records in the table from the current position.
<nRecords>
The scope is the next <nRecords> records.
 
lMark – A logical value that determines whether the record is irrevocably deleted (FALSE) or marked for deletion (TRUE). Value by default – TRUE.
 
 
 
This project continues to develop and be added by new methods. The next code optimization will be made soon. So – "coming soon"!
 
 
In the file for downloading after unpacking you receive:
1.     msArrSrv.dll
2.     msArrSrv-DLL.aef
3.     «Table of methods.xls» - the list of the made methods and the description of their compliances with other classes.
 
P.S. : Now (12.03.2016) the actual version of library – 1.0.0.24. 
 
 
ВложениеРазмер
Файл msArrayServer_v_1_0_0_24.rar86.3 КБ

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer