Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- GT_LIB v1.0 Reference Guide Release 1.0 - <b>compress a clipper numeric value into a string</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 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

See Also: GT_UNCOMPN()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson