WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Content Addressable Memory

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Content Addressable Memory Extender

 Keywords:  

The WinBatch 'xCAM' extender provides keyword addressable storage in an efficient manner.

[xcam34i.v34032.zip]

Author:
   Detlev Dalitz
   Marty Williams (The first WinBatch CAM code.)

Version:
   20031101
   FILEVERSION 34032
   PRODUCTVERSION 10032

Download:
   Setup package  xcam34i.v34032.zip  172 KB

Usage:
   AddExtender("xcam34i.dll")

-------------------------------------------------------------------------------

 WinBatch Extender 'xCAM Content Addressable Memory' (xCAM34i.dll)

 (c)20030215.Detlev Dalitz
 Portions copyright by Marty Williams, WinBatch, Wilson Window Ware.
 Portions copyright by Alan Kreutzer.

-------------------------------------------------------------------------------

 The WinBatch 'xCAM' extender provides keyword addressable
 storage in an efficient manner.

 'xCAM' uses a hash algorithm to utilize direct access to
  a WinBatch array cell by a given KeyValue, which can be of
  datatype integer, float or string.

 'xCAM' can reduce the cost of data access to about O(1).

 The minor disadvantage of the excellent access quality is the fact,
 that a CAM array is designed to need as twice as much memory as there are
 Key-Data pairs to be stored.


 Additional you find in this extender some array related tools
 that can enhance your productivity when working with WinBatch arrays,
 for example array functions for loading and unloading
 and various sort functions, array merge, shrink and extract function.

-------------------------------------------------------------------------------

Overview

  Functions
     camExtenderInfo
     camInit
     camCheck
     camPut
     camGet
     camKeyList
     camDataList
     camCAMFromArray
     camCAMToArray
     camArraySort       *
     camArrayFileGet    *
     camArrayFilePut    *
     camArrayFromList   *
     camArrayToList     *
     camArrayFromFile   *
     camArrayToFile     *
     camArrayFlip       *
     camArrayMerge      *
     camArrayShrink     *
     camArrayRange      *
     camArrayRangeCast  *
     camArrayRangeFill  *
     camArrayRangeMath  *
     camArrayPrintf     *
     camGUID
     camUrlEncode
     camUrlDecode
     camGetDelim
                        * = For use with standard WinBatch arrays.

  Constants
     @INSERTSORT
     @SHELLSORT
     @QUICKSORT
     @SORT_INSERTSORT
     @SORT_SHELLSORT
     @SORT_QUICKSORT
     @MATH_COUNT
     @MATH_MIN
     @MATH_MAX
     @MATH_SUM
     @MATH_SUM_SQ
     @MATH_MEAN
     @MATH_SUM_SQ_MEAN_DEV
     @MATH_VAR
     @MATH_STD_DEV
     @MATH_VAR_N
     @MATH_STD_DEV_N
     @CAST_ANY_TO_UNDEF
     @CAST_ANSI_TO_OEM
     @CAST_OEM_TO_ANSI
     @CAST_STR_TO_LOWER
     @CAST_STR_TO_UPPER
     @CAST_STR_TO_NUM
     @CAST_NUM_TO_STR
     @CAST_INT_TO_FLOAT
     @CAST_FLOAT_TO_INT
     @CAST_INT_TO_BIN
     @CAST_BIN_TO_INT
     @CAST_INT_TO_OCT
     @CAST_OCT_TO_INT
     @CAST_INT_TO_HEX
     @CAST_HEX_TO_INT

-------------------------------------------------------------------------------

 The "xCAM  Content Addressable Memory Extender" contains:


 - camExtenderInfo
      Returns extender related information.

      Syntax:
         i:Number = xmtExtenderInfo (i:Request)

            Request = 0 ==> Version
            Request = 1 ==> Total Functions
            Request = 2 ==> Total Constants


 - camInit
      Returns a special designed WinBatch array to use as a CAM storage.

      Syntax:
         a:CAMArray = camInit (i:MaxItems)

            MaxItems = Max number of items to store.
                       From 1 to 2**16 to maybe approx. limit 2**31 ?


 - camCheck
      Returns a boolean value which indicates
      if the given array seems to be a valid CAM array.

      Syntax:
         i:BooleanValue = camCheck (a:CAMArray)


 - camPut
      Puts a key-data pair into the CAM storage.

      Syntax:
         i/s:ResultValue = camPut (a:CAMArray, i/f/s:KeyValue, i/f/s:DataValue)

         Returning ResultValue can be:
            ResultValue = 1            (Put process was successful)
            ResultValue = "*EOF*CAM"   (Error while put process or error in input parameters)

      Note: Keys are stored in a CAM array in lower case (case insensitive).


 - camGet
      Returns the data value for a given key value.

      Syntax:
         i/f/s:DataValue = camGet (a:CAMArray, i/f/s:KeyValue)


 - camKeyList
      Creates an Itemlist from key values stored in CAM array.

      Syntax:
         s:Itemlist = camKeyList (a:CAMArray, s:DelimChar, i:ListMode)

         - ListMode = 0 ==> No  trailing delimiter.
         - ListMode = 1 ==> Add trailing delimiter.

      Example:
         camKeyList (CAMarray, "|", 1)

            takes a CAM array with keyvalue/datavalue pairs:
                key  data
               +---+--------+
               ! 2 ! pear   !
               ! 1 ! apple  !
               ! 3 ! banana !
               !---+--------+

            gives a string:
               "2|1|3|"

         The keys are returned in a random order.
         A simple ItemSort can sort them (if needed).


 - camDataList
      Creates an Itemlist from data values stored in a CAM array.

      Syntax:
         s:Itemlist = camDataList (a:CAMArray, s:DelimChar, i:ListMode)

         - ListMode = 0 ==> No  trailing delimiter.
         - ListMode = 1 ==> Add trailing delimiter.

      Example:
         camDataList (CAMarray, "|", 1)

            takes a CAM array with keyvalue/datavalue pairs:
                key  data
               +---+--------+
               ! 2 ! pear   !
               ! 1 ! apple  !
               ! 3 ! banana !
               !---+--------+

            gives a string:
               "pear|apple|banana|"

         The keys are returned in a random order.
         A simple ItemSort can sort them (if needed).


- camCAMFromArray
      Creates a CAM array from a normal Dim1 or Dim2 array.

      Syntax:
         a:CAMArray = camCAMFromArray (a:Array, i:KeyColumn, i:DataColumn)

         If parameter i:DataColumn is less than zero (-1),
         then the CAM array's DataValue will be filled with an integer number,
         that is the corresponding row number of the input array.


- camCAMToArray
      Creates a normal Dim2 array from a CAM array.
      Provides deloading functionality into array
      (like camKeyList and camDataList into string).

      Syntax:
         a:Array = camCAMToArray (a:CAMArray)


- camArrayToFile
      Dumps an array to a special designed array dump textfile.

      Syntax:
         i:BooleanValue = camArrayToFile (a:Array, s:Filename)

      File access rights must be create, write, read.

      Note: Not limited to CAM arrays, can be used with WinBatch arrays in general.


 - camArrayFromFile
      Creates an array from a special designed array dump textfile.

      Syntax:
         a:Array = camFileToArray (s:Filename)

      Note: Not limited to CAM arrays, can be used with WinBatch arrays in general.


 - camArraySort
      Performs a sort on a WinBatch array.
      Array can have up to 5 dimensions, but will be sorted in Dim-1 column only.
      Other dimensions remain joined.

      Offers three different sort algorithms:
      - InsertSort ... for small arrays.
      - ShellSort  ... for large arrays.
      - QuickSort  ... for big arrays.

      Syntax:
         i:BooleanValue = camArraySort (a:Array, i:SortMethod, i:SortDirection, i:MatchCase)

         SortMethod    = @INSERTSORT (0)
         SortMethod    = @SHELLSORT  (1)
         SortMethod    = @QUICKSORT  (2)

         SortDirection = @ASCENDING  (0)
         SortDirection = @DESCENDING (16)

         MatchCase     = @FALSE (0)
         MatchCase     = @TRUE  (1)

         Returns:
         (Array in-place sorted)
         BooleanValue  = @FALSE ==> Error on sort time or wrong parameters.
         BooleanValue  = @TRUE  ==> Sort was successful.

      Note: Use camArraySort to sort standard WinBatch arrays only.

      Note: Do never sort a CAM array. Sorting would corrupt the entire CAM array.


 - camArrayFileGet
      Reads a textfile and returns a Dim1 array.
      Each array element contains one line of the given input file,
      with EndOfLine characters stripped off.

      The BaseMode parameter controls the creation
      of a zero based or a one based Array.

      The array contains n elements (zero based)
      resp. n+1 elements (one based),
      with n = Number of File lines.

      After returning from this function the number of file lines read
      can be retrieved by 'LineCount = ArrInfo(Array,1) - BaseMode'.

      Syntax:
         a:Array = camArrayFileGet (s:Filename, i:Basemode)

         BaseMode = 0  = zero based array
         BaseMode = 1  = one  based array


 - camArrayFilePut
      Writes an array to textfile (only column Dim1) .
      Each array element is one line in textfile.
      EndOfLine character is a CRLF sequence.

      The iBaseMode parameter controls how the array is readout,
      starting with element 0 if array is zero based or
      starting with element 1 if array is one based.

      Syntax:
         i:BooleanValue = camArrayFilePut (a:Array, s:Filename, i:BaseMode)

         BooleanValue = @TRUE  = 1  on success.
         BooleanValue = @FALSE = 0  on failure.

         File access rights must be create, write, read.


 - camArrayFromList
      This function takes a delimited list, and creates a one- or more-dimension
      array with the same number of elements as the number of items in the list,
      setting each element to the value of the corresponding item in the list.
      It converts a delimited list to an array of Dim1..Dim5 depending
      on the delimiter chars which can be defined accordingly.
      Mostly it will be used to create Dim2 tables.

      This function is the counterpart to "camArrayToList".

      Syntax:
         a:Array = camArrayize (s:String, s:DimDelimChars, i:Mode)

         Mode = 1 ==> Acts like standard WinBatch Arrayize function.
                      Respects trailing delimiter and adds empty array item.

                      For example:
                      Arrayize("test.",".") converts a WinBatch list
                      of two items, delimited by a point character.
                      This gives an Dim1-array with two array elements.

         Mode = 0 ==> Discard trailing empty item.

      Example:
         camArrayFromList ("1|apple|1.10@2|pear|2.20@3|banana|3.30@", "@|", 0)

            gives an array 3x3:
               +---+--------+-------+
               ! 1 ! apple  ! 1.10  !
               ! 2 ! pear   ! 2.20  !
               ! 3 ! banana ! 3.30  !
               !---+--------+-------+


 - camArrayToList
      This function creates a delimited list from a one- or multi-dimension
      array with the same number of items as the number of elements in the array,
      setting each list item to the value of the corresponding array element.
      Delimiter chars can be choosen by the user.

      This function is the counterpart to "camArrayFromList".

      Syntax:
         s:String = camArrayToList (a:Array, s:DimDelimChars, i:Mode)

         Mode = 1 ==> Add trailing Dim1-delimiter.
         Mode = 0 ==> No  trailing Dim1-delimiter.

      Example:
         camArrayToList (array, "@|", 1)

            takes an array 3x3:
               +---+--------+-------+
               ! 1 ! apple  ! 1.10  !
               ! 2 ! pear   ! 2.20  !
               ! 3 ! banana ! 3.30  !
               !---+--------+-------+

            gives a string:
               "1|apple|1.10@2|pear|2.20@3|banana|3.30@"


 - camArrayFlip
      Swaps row (Dim1) and column (Dim2) of an array, creating a new Dim2 array.

      Syntax:
        a:ArrayB = camArrayFlip (a:ArrayA)

        Example:
           Given array 4x3:

                  B0  B1       B2
                +---+--------+-------+
             A0 ! 1 ! apple  ! 1.10  !
             A1 ! 2 ! pear   ! 2.20  !
             A2 ! 3 ! prune  ! 3.30  !
             A3 ! 4 ! banana ! 4.40  !
                !---+--------+-------+

           Returns an array 3x4:

                  B0      B1     B2      B3
                +-------+------+-------+--------+
             A0 ! 1     ! 2    ! 3     ! 4      !
             A1 ! apple ! pear ! prune ! banana !
             A2 ! 1.10  ! 2.20 ! 3.30  ! 4.40   !
                +-------+------+-------+--------+


- camArrayMerge
      Creates a Dim2-array by merging two Dim1- or Dim2-arrays.

      Merging means, that 'columns' of array B are inserted into array A.
      The columns to be inserted can be a consecutive range of columns
      starting at a specified start column with count column width.

      The new array will be proper sized to take over all elements
      from the specified columns.

      Syntax:
         a:Array = camArrayMerge (a:ArrayA, i:InsertCol, a:ArrayB, i:StartCol, i:Count)


 - camArrayShrink
      Deletes one or more columns from a Dim2-array.

      If deletion of an an entire Dim2 vector occurs, then the function
      returns a Dim1-array with one element of undefined vartype.

      Syntax:
        a:Array = camArrayShrink (a:ArrayA, i:StartCol, i:Count)


 - camArrayRange
      Extracts a specified region of cells from a given array,
      creating a new array.

      Syntax:
        a:ArrayB = camArrayRange (a:ArrayA, s:RangeMaskFrom, s:RangeMaskTo)

        RangeMask is a comma delimited list of integer numbers,
        referring to an array coordinate.

        An asterisk can be used as a placeholder in each dimension
        to force using subranges of cells, that means using of indexes
        in a range from lower bound resp. to upper bound of the specified dimension.

           Given array 3x3:

                  B0  B1       B2
                +---+--------+-------+
             A0 ! 1 ! apple  ! 1.10  !
             A1 ! 2 ! pear   ! 2.20  !
             A2 ! 3 ! banana ! 3.30  !
                !---+--------+-------+

        Example 1:
           RangeMaskFrom = "1,1"
           RangeMaskTo   = "2,2"

           Returns an array 2x2:

                  B0       B1
                +--------+-------+
             A0 ! pear   ! 2.20  !
             A1 ! banana ! 3.30  !
                !--------+-------+


        Example 2:
           RangeMaskFrom = "*,1"   ("*" ==> from element A[lower bound])
           RangeMaskTo   = "*,1"   ("*" ==> to element   A[upper bound])

           Returns an array 1x3:

                +--------+
             A0 ! apple  !
             A1 ! pear   !
             A2 ! banana !
                !--------+


        Example 3:

           RangeMaskFrom = ""   (Note: "" is the same as "*,*,*,*,*")
           RangeMaskTo   = ""

           Returns a full copy of the given array.


 - camArrayRangeCast
      Performs typecasting on the specified region of cells.

      Syntax:
        i:Result = camArrayRangeCast (a:ArrayA, s:RangeMaskFrom, s:RangeMaskTo, i:CastMode)

        CastMode:
        @CAST_ANY_TO_UNDEF  (=0)
        @CAST_STR_TO_NUM    (=1)
        @CAST_NUM_TO_STR    (=2)
        @CAST_FLOAT_TO_INT  (=3)
        @CAST_INT_TO_FLOAT  (=4)


 - camArrayRangeFill
      Fills the specified region of cells with the same value of integer, float or string.

      Syntax:
        i:Result = camArrayRangeFill (a:ArrayA, s:RangeMaskFrom, s:RangeMaskTo, ifs:Value)


 - camArrayRangeMath
      Performs statistical related math functions on the specified region of cells.
      Returns a WinBatch Dim1-array of 11 elements, which contains the set of
      result values solved by the implemented statistical math functions.

      Syntax:
        a:ArrayB = camArrayRangeMath (a:ArrayA, s:RangeMaskFrom, s:RangeMaskTo)

      Math functions:
      @MATH_COUNT            (=0)  Count                            (=Anzahl)
      @MATH_MIN              (=1)  Min                              (=Minimum)
      @MATH_MAX              (=2)  Max                              (=Maximum)
      @MATH_SUM              (=3)  Sum                              (=Summe)
      @MATH_SUM_SQ           (=4)  Sum of Squares                   (=Summe der Quadrate)
      @MATH_MEAN             (=5)  Mean                             (=Mittelwert)
      @MATH_SUM_SQ_MEAN_DEV  (=6)  Sum of Squared Mean Deviation    (=Summe der quadrierten Abweichungen vom Mittelwert)
      @MATH_VAR              (=7)  Variance N-1                     (=Varianz (N-1))
      @MATH_STD_DEV          (=8)  Standard Deviation N-1           (=Standardabweichung (N-1))
      @MATH_VAR_N            (=9)  Variance N                       (=Varianz (N))
      @MATH_STD_DEV_N        (=10) Standard Deviation N             (=Standardabweichung (N))


 - camArrayPrintf
      The function formats and stores a series of array values and additional literals into a string.
      The returning string is formatted accordingly to the corresponding
      format specification in the format string.
      The function works much like the native windows C runtime printf function.

      Syntax:
        s:String = camArrayPrintf (a:ArrayA, s:FormatString)


 - camGUID
      Returns a GUID string.

      Syntax:
         s:GUIDString = camGUID ()


 - camUrlEncode
      Returns an UrlEncoded string.
      Translation of special characters into their hexadecimal representation,
      e.g. @TAB (which is a Num2Char(9)) becomes "%09".

      Syntax:
         s:UrlEncodedString = camUrlEncode (s:String)


 - camUrlDecode
      Returns an UrlDecoded string.
      Translation of hexadecimal character representation into char value,
      e.g. "%09" becomes @TAB.

      Syntax:
         s:UrlDecodedString = camUrlDecode (s:UrlEncodedString)


 - camGetDelim
      Returns a set of reasonable delimiter characters depending on the given input string.
      The set of delimiter characters can be presented in a string variable or in an array variable.

      Syntax:
         s/a:Delimiter = camGetDelim (s:String, i:Count, i:Mode [, s:Default]


 - Constants:
      @INSERTSORT             (=0)
      @SHELLSORT              (=1)
      @QUICKSORT              (=2)
      @SORT_INSERTSORT        (=0)
      @SORT_SHELLSORT         (=1)
      @SORT_QUICKSORT         (=2)
      @MATH_COUNT             (=0)
      @MATH_MIN               (=1)
      @MATH_MAX               (=2)
      @MATH_SUM               (=3)
      @MATH_SUM_SQ            (=4)
      @MATH_MEAN              (=5)
      @MATH_SUM_SQ_MEAN_DEV   (=6)
      @MATH_VAR               (=7)
      @MATH_STD_DEV           (=8)
      @MATH_VAR_N             (=9)
      @MATH_STD_DEV_N         (=10)
      @CAST_ANY_TO_UNDEF      (=0)
      @CAST_ANSI_TO_OEM       (=1)
      @CAST_OEM_TO_ANSI       (=2)
      @CAST_STR_TO_LOWER      (=3)
      @CAST_STR_TO_UPPER      (=4)
      @CAST_STR_TO_NUM        (=5)
      @CAST_NUM_TO_STR        (=6)
      @CAST_INT_TO_FLOAT      (=7)
      @CAST_FLOAT_TO_INT      (=8)
      @CAST_INT_TO_BIN        (=9)
      @CAST_BIN_TO_INT        (=10)
      @CAST_INT_TO_OCT        (=11)
      @CAST_OCT_TO_INT        (=12)
      @CAST_INT_TO_HEX        (=13)
      @CAST_HEX_TO_INT        (=14)

-------------------------------------------------------------------------------
 No warranty at all. Use it on your own risk. Feel free to return feedback.
-------------------------------------------------------------------------------


Article ID:   W16866
File Created: 2019:08:14:08:57:56
Last Updated: 2019:08:14:08:57:56