Compress a Clipper Numeric value into a string
──────────────────────────────────────────────────────────────────────────────

Syntax

<str> := GT_CompN(<numeric>,<size>)

Arguments:

<numeric> - Clipper value to compress
<size> - Number of Bytes to compress to (1/2/4/8)

Returns:

<str> - Character String Returned

Description:

This function is surprisingly quite handy. Its principle use is to
create data storage types similar to C, char,int, long, double.
The use then surpasses that with the fact that these new variables
in clipper are just 1/2/4/8 character strings which can be written
away to databases or even used in an index.

what this all means is that a field that only needs to store values
from 0-255, only need be one character wide in the database
structure.


Examples:

#include "gt_compn.h"

function main()

* Setup some Test Values into some local variables

local w := 10
local x := 1000
local y := 1234567
local z := 1234567.890123

* Reserve Enough Space in Each Storage Variable

local s_w := space( GT_BYTE )
local s_x := space( GT_INT )
local s_y := space( GT_LONG )
local s_z := space( GT_DOUBLE )

* Store The Compressed Numbers in Their Storage Variables

s_w := GT_CompN( w, GT_BYTE)
s_x := GT_CompN( x, GT_INT )
s_y := GT_CompN( y, GT_LONG)
s_z := GT_CompN( z, GT_DOUBLE)


Source: GT_COMPN.C

Author: Brian Dukes