Description
This method compares the buffers held by two CTBUFF instances. Do not confuse this method with CTBUFF_Comp, which compares a CTBUFF instance with a memory area.
Prototype
DCTBUFF_BuffComp...
D PR 10I 0
D@This * Value
D@Buff * Value
Parameters
@This
Type | Pointer (*) |
Passing Mode | Value |
Description | The address of an CTBUFF instance. This pointer MUST be obtained through a call to CTBUFF_Constructor. |
@pBuff
Type | Pointer (*) |
Passing Mode | Value |
Description | The address of an CTBUFF instance. This pointer MUST be obtained through a call to CTBUFF_Constructor. |
Return Values
Symbolic Constant | Value | Description |
N/A | 1 | The values of the buffer in @This is greater than the value of the buffer in @pBuff |
N/A | 0 | The values of the buffer in @This is equal t0 the value of the buffer in @pBuff |
N/A | -1 | The values of the buffer in @This is lower than the value of the buffer in @pBuff |
Examples
HDatEdit(*YMD)
FCTMAP IF E DISK
FCTMAPTO UF A E DISK
*--------------------------------------------------------------
* Clara-Tools Definitions
*--------------------------------------------------------------
/Include QINCSRC,CTBASE
DEntryProc Pr ExtProc('TESTBUFF')
DEntryProc PI
*-------------------------------------------------------------------------------
* Main
*-------------------------------------------------------------------------------
DpBuff S *
DpBuff2 S *
DRc S 10I 0
Di S 10I 0
Dk S 10I 0
DBytes S 10I 0
DCount S 10I 0
DValueBuff S 255A
/Free
pBuff = CTBUFF_Constructor();
pBuff2 = CTBUFF_Constructor();
ValueBuff = 'abcdefghij';
CTBUFF_Set(pBuff: %Addr(ValueBuff): %Len(%Trim(ValueBuff)));
ValueBuff = 'abcdefghij';
CTBUFF_Set(pBuff2: %Addr(ValueBuff): %Len(%Trim(ValueBuff)));
// Return value will be 0 since both buffers are identical
Rc = CTBUFF_BuffComp(pBuff: pBuff2);
ValueBuff = 'YYZ';
CTBUFF_Set(pBuff: %Addr(ValueBuff): %Len(%Trim(ValueBuff)));
ValueBuff = 'ABC';
CTBUFF_Set(pBuff2: %Addr(ValueBuff): %Len(%Trim(ValueBuff)));
// Return value will be 1 since pBuff is higher than pBuff2
Rc = CTBUFF_BuffComp(pBuff: pBuff2);
ValueBuff = 'ABC';
CTBUFF_Set(pBuff: %Addr(ValueBuff): %Len(%Trim(ValueBuff)));
ValueBuff = 'ABCD';
CTBUFF_Set(pBuff2: %Addr(ValueBuff): %Len(%Trim(ValueBuff)));
// Return value will be -1 since pBuff2 is higher than pBuff
Rc = CTBUFF_BuffComp(pBuff: pBuff2);
// In this next case, the length paramter
// determines how the comparison is made.
// The second test buffer is not a CTBUFF
// instance but simply a buffer in memory.
//
// In the first case, the buffer in pBuff is
// highher because we are comparing abcd with abc.
//
// In the second case, we are comparing the CTBUFF
// buffer with the first 4 bytes of ValueBuff; the
// return value will be 0 since both buffers are
// identical.
//
// In the last case, the ValueBuff buffer is higher
// so the return value is -1
ValueBuff = 'abcd';
CTBUFF_Set(pBuff: %Addr(ValueBuff): 4);
ValueBuff = 'abcde';
// Comparing abcd with abc ...
Rc = CTBUFF_Comp(pBuff: %Addr(ValueBuff): 3);
// Comparing abcd with abcd ...
Rc = CTBUFF_Comp(pBuff: %Addr(ValueBuff): 4);
// Comparing abcd with abcde ...
Rc = CTBUFF_Comp(pBuff: %Addr(ValueBuff): 5);
*InLr = *On;
/End-Free