Jump to content

Hashing function written


Recommended Posts

In my previous post, it appeared as if I had a problem nobody else had ever encountered. I guess this means that the attached code won't help anyone, but just in case...

(Non-comprehensive) Hash usage example:

#include <Hash.au3>

;--------- Single hash demo --------
;Notice that you don't need a key...

_HashF_KillAll();
_HashF_NewInstance();
$testlen = 26;
For $i = 1 to $testlen
   ;Put in letters
    _HashF_Put( Chr( $i + 64 ), Chr( $i + 96 ) );
Next
;Replace "m" with Easter Egg
_HashF_Put( Chr( 77 ), "   **FOO**   " );
$keys = "";
$vals = "";
For $i = 1 to $testlen
    $keys = $keys & Chr( $i + 64 ) & " ";
    $vals = $vals & _HashF_Get( Chr( $i + 64 ) ) & " ";
Next
MsgBox( 0, "KEYS", $keys );
MsgBox( 0, "VALS", $vals );


;--------- Multiple hash demo --------
; Notice that you now need keys
_HashF_KillAll();
$names = _HashF_NewInstance();
$autos = _HashF_NewInstance();

_HashF_Put( "123-45-6789", "Joe Smith", $names );
_HashF_Put( "223-45-6789", "Bob Jones", $names );

_HashF_Put( "123-45-6789", "big car", $autos );
_HashF_Put( "223-45-6789", "small car", $autos );

MsgBox( 0, "123-45-6789", _HashF_Get( "123-45-6789", $names ) & " drives a " & _HashF_Get( "123-45-6789", $autos ) );
MsgBox( 0, "223-45-6789", _HashF_Get( "223-45-6789", $names ) & " drives a " & _HashF_Get( "223-45-6789", $autos ) );


;--------- A very "Perl-ish" script --------
_HashF_KillAll();
_HashF_NewInstance();
$ab = "abbababbbbaababbbbbbabbababbabbbabbababab";
$chars = StringSplit( $ab, "" );
For $i = 1 to $chars[0]
    _HashF_Put( $chars[$i], ( _HashF_Get( $chars[$i] ) + 1) );
Next

MsgBox(0, "a count =", _HashF_Get("a") );
MsgBox(0, "b count =", _HashF_Get("b") );

Put this in your "include" directory:

#include-once

;--------------------------------------------------------------------------------
;AutoIt Version: 3x
;Language:     English
;Platform:     All
;Author:         mrider
;   
;Script Function:
;   Creates a simple hash function.  This hash is best suited for small data
;   sets - because the algorithm searches through the arrays looking for
;   a matching key, then returns the value found there.
;   
;   Naming conventions used in this code:
;   $_HashG_xxx = Global variable.
;   $_HashC_xxx = Constant.
;   _HashF_xxx  = Function
;   Avoid this name patern if you wish to avoid name collisions.
;   
;NOTES:
;   This code is VERY brute force.  This script can grab lots of memory
;   and can bring a computer to its knees in short order if there is a problem,
;   such as uncontrolled recursion.  It will also cause problems with really
;   large datasets.
;--------------------------------------------------------------------------------

;Constants
Const $_HashC_NoError = 0;
Const $_HashC_NotInitialized = 1;
Const $_HashC_InvalidPointer = 2;
Const $_HashC_KeyNotFound = 4;
Const $_HashC_UnknownError = 1024;

;Global variables
Global $_HashG_initSize = 10;
Global $_HashG_resizeAdder = 5;
Global $_HashG_container = 0;
Global $_HashG_lastPointer = 0;


;--------------------------------------------------------------------------------
;Function Name:  _HashFKillAll()
;
;Description:   Destroys all hash entries and returns hash to unitialized state.
;
;Parameter(s):   none
;
;Returns:       nothing
;--------------------------------------------------------------------------------
Func _HashF_KillAll()
    $_HashG_Container = 0;
    $_HashG_lastPointer = 0;
EndFunc


;--------------------------------------------------------------------------------
;Function Name:  _HashF_NewInstance()
;
;Description:   Creates a pointer to a new hash.
;
;Parameter(s):   none
;
;Returns:       A pointer to the new hash, suitable for all functions which
;               require a pointer.
;--------------------------------------------------------------------------------
Func _HashF_NewInstance()
   ;NOTE: There're two overhead entries - the zero'th element of each hash.
   ;Element $_HashG_container[?][0][0] = pointer to last element in hash.
   ;Element $_HashG_container[?][0][1] = external hash pointer (see "$ptr")
    If ( $_HashG_container == 0 ) Then
        Dim $_HashG_container[1][$_HashG_initSize + 1][2]
    Else
        Local $numHashes = UBound( $_HashG_container, 1 );
        Local $numElements = UBound( $_HashG_container, 2 );
        ReDim $_HashG_container[$numHashes + 1][$numElements][2];
        $_HashG_lastPointer = $_HashG_lastPointer + 1;
    EndIf
    $_HashG_container[UBound($_HashG_container,1) - 1][0][0] = 0;
    $_HashG_container[UBound($_HashG_container,1) - 1][0][1] = $_HashG_lastPointer;
    
    Return $_HashG_lastPointer;
EndFunc


;--------------------------------------------------------------------------------
;Function Name: _HashF_Put($key, $val [,$ptr])
;
;Description:   Puts a value in the hash.  Creates a space for the value if
;               the key does not already exist, overwrites the value if it does.
;               
;               $ptr is not necessary in cases where only one hash set exists.
;
;Parameter(s):   $key - the key to the value
;               $value - the value associated with the key
;               [$ptr] - pointer to a hash (optional).
;
;Returns:       Nothing
;--------------------------------------------------------------------------------
Func _HashF_Put( $key, $val, $ptr = 0 )
    Local $err = _HashF_ValidatePtr( $ptr );
    If ( $err <> 0 ) Then
        SetError( $err );
        Return;
    EndIf
    
   ;Get the index to our pointer
    Local $index = _HashF_FindIndex( $ptr );
    
   ;Try easy thing first - see if there are no elements in hash
    If ( $_HashG_container[$index][0][0] == 0 ) Then
        $_HashG_container[$index][1][0] = $key;
        $_HashG_container[$index][1][1] = $val;
        $_HashG_container[$index][0][0] = 1;
        Return;
    EndIf
    
   ;Check to see if key already exists
    Local $keyIndex = _HashF_FindKey( $index, $key );
    If ( $keyIndex <> -1 ) Then
        $_HashG_container[$index][$keyIndex][1] = $val;
        Return;
    EndIf
    
   ;If we're here, we're adding a new key
    
   ;Check to see if hash is full
    If ( $_HashG_container[$index][0][0] == UBound( $_HashG_container, 2) - 1 ) Then
        _HashF_Grow();
    EndIf
    
   ;Add key and value to hash - "$lastVal" is the pointer to the last value
    Local $lastValPtr = $_HashG_container[$index][0][0] + 1;
    $_HashG_container[$index][$lastValPtr][0] = $key;
    $_HashG_container[$index][$lastValPtr][1] = $val;
    $_HashG_container[$index][0][0] = $lastValPtr;
    Return;
EndFunc


;--------------------------------------------------------------------------------
;Function Name:  _HashF_Get( $key [,$ptr] )
;
;Description:   Looks in the hash pointed to by $ptr, and finds the value
;               associated with the key provided.  Returns the value "0" and
;               sets @ERROR value to bitwise map if a problem is encountered.
;               See the constants above.
;               
;               $ptr is not necessary in cases where only one hash set exists.
;
;Parameter(s):   $key - key to the a value
;               [$ptr] - pointer to a hash (optional).
;
;Returns:       The value associated with the key (if any)
;--------------------------------------------------------------------------------
Func _HashF_Get( $key, $ptr = 0 )
    Local $err = _HashF_ValidatePtr( $ptr );
    If ( $err <> 0 ) Then
        SetError( $err );
        Return( 0 );
    EndIf
    
    Local $index = _HashF_FindIndex( $ptr );
    Local $keyIndex = _HashF_FindKey( $index, $key );
    If ( $keyIndex == -1 ) Then
        SetError( $_HashC_KeyNotFound );
        Return( 0 );
    Else
        SetError( $_HashC_NoError );
        Return( $_HashG_container[$index][$keyIndex][1] );
    EndIf
EndFunc


;--------------------------------------------------------------------------------
;Function Name:  _HashF_RemoveHash( $ptr )
;
;Description:   Removes an entire hash
;               
;Parameter(s):   $ptr the pointer to the hash to remove
;
;Returns:       nothing - (note: fails silently if $ptr is invalid)
;--------------------------------------------------------------------------------
Func _HashF_RemoveHash( $ptr )
    Local $index = _HashF_FindIndex( $ptr );
    If ( $index == -1 ) Then
        Return;
    Else
        If ( ( UBound( $_HashG_container, 1 ) - 1 ) == 0 ) Then
            _HashF_KillAll();
            _HashF_NewInstance();
        Else
            If ( $index < Ubound( $_HashG_container, 2 ) ) Then
                Local $lastIndex = Ubound( $_HashG_container, 1 ) - 1;
                For $i = 0 to Ubound( $_HashG_container, 2 ) - 1
                    $_HashG_container[$index][$i][0] = $_HashG_container[$lastIndex][$i][0];
                    $_HashG_container[$index][$i][1] = $_HashG_container[$lastIndex][$i][1];
                Next
            EndIf
            ReDim $_HashG_container[UBound( $_HashG_container, 1 ) - 1][Ubound($_HashG_container, 2 ) - 1][2];
        EndIf
    EndIf
EndFunc


;--------------------------------------------------------------------------------
;Function Name:  _HashF_RemovePair( $key [,$ptr] )
;
;Description:   Removes a key value pair from the indicated hash
;               
;Parameter(s):   $key - key to the a value
;               [$ptr] - pointer to a hash (optional).
;               
;Returns:       nothing - (Note: fails silently if $key or $ptr is invalid)
;--------------------------------------------------------------------------------
Func _HashF_RemovePair( $key, $ptr = 0 )
    Local $index = _HashF_FindIndex( $ptr );
    If ( $index == -1 ) Then
        Return;
    EndIf
    
    Local $keyIndex = _HashF_FindKey( $index, $key );
    Local $lastIndex = Ubound( $_HashG_container, 2 ) - 1;
    If ( $_HashG_container[$index][$keyIndex][0] == 0 ) Then
        Return;
    EndIf
    
    If ( $keyIndex == $lastIndex ) Then
        $_HashG_container[$index][$keyIndex][0] = 0;
        $_HashG_container[$index][$keyIndex][1] = 0;
    Else
        For $i = $keyIndex to ( $lastIndex - 1 )
            $_HashG_container[$index][$i][0] = $_HashG_container[$index][$i + 1][0];
            $_HashG_container[$index][$i][1] = $_HashG_container[$index][$i + 1][1];
        Next
    EndIf
    $_HashG_container[$index][0][0] = $_HashG_container[$index][0][0] - 1;
EndFunc


;--------------------------------------------------------------------------------
;Function Name:  _HashF_Grow( [$adder] )
;
;Description:   Increases the size of the hash by the amount in $adder.
;               The default resize value is used if $adder is not supplied, or
;               if the value supplied is invalid.
;               
;               This method is called automatically when an element is added
;               to a hash which is full.  If needed, it can also be called by
;               hand just before adding a large number of elements.
;
;Parameter(s):   [$adder] - the number of empty slots to add to the hash
;
;Returns:       The number of slots in the new hash
;
;See Also:     _HashF_DefaultResizeAmt
;--------------------------------------------------------------------------------
Func _HashF_Grow( $adder = 0 )
   ;Make sure adder is a number - and is greater than zero
    $adder = $adder + 0;
    If ( $adder < 1 ) Then $adder = $_HashG_resizeAdder;
    
   ;Figure out old hash
    Local $oldSize = UBound( $_HashG_container, 2 );
    Local $numHashes = UBound( $_HashG_container, 1 );
    Local $newSize = $oldSize + $adder;
    
   ;Resize
    ReDim $_HashG_container[$numHashes][$newSize + 1][2];
    
    Return( $newSize )
EndFunc


;--------------------------------------------------------------------------------
;Function Name: _HashF_Shrink
;
;Description:   Decreases the size of the hash container.  Useful for times 
;               where one wants to reduce memory usage after removing a large
;               number of elements.
;               
;               There are two possibilities for the amount to shrink: 
;               0) Shrink to the next larger even size after the amount
;                   of elements in the largest hash - DEFAULT
;               
;               1) Shrink to (num elements)
;
;Parameter(s):   [$shType] - choice 0 or 1 
;
;Returns:       nothing
;
;See Also:     _HashF_DefaultResizeAmt
;--------------------------------------------------------------------------------
Func _HashF_Shrink( $shType = 0 )
   ;Get shrink type
    If ( ( $shType <> 0 ) AND ( $shType <> 1 ) ) Then 
        $shType = 0;
    EndIf
    
   ;Get new size
    Local $newSize = 0;
    Local $largest = 0;
    For $i = 0 To UBound( $_HashG_container, 1 ) - 1
        If ( $_HashG_container[$i][0][0] > $largest ) Then
            $largest = $_HashG_container[$i][0][0];
        EndIf
    Next
    
   ;Add empty spaces at end if needed
    If ( $shType == 0 ) Then
        $newSize = ( int( $largest / $_HashG_initSize ) * $_HashG_initSize ) + $_HashG_initSize + 1;
    Else
        $newSize = $largest + 1;
    EndIf
    
   ;Shrink the container
    Local $numHashes = UBound( $_HashG_container, 1 );
    ReDim $_HashG_container[$numHashes][$newSize][2];
EndFunc


;--------------------------------------------------------------------------------
;Function Name:  _HashF_DefaultResizeAmt
;
;Description:   Changes the default amount (5) of additional slots added to the
;               hash whenever it is necessary to grow the hash.  Normally this
;               isn't needed, but it can add a bit of a performance boost if
;               items are added in known size groups.  For example, if items
;               are found in groups of ten, then setting the resize amount to
;               ten will guarantee that enough slots to hold a group is added
;               at each automatic resize.
;               
;               Note that a large number will reduce the number of times that
;               the hash is resized, but will increase memory usage - and
;               vice versa.
;
;Parameter(s):   $amt - the amount to adjust (must be greater than zero)
;
;Returns:       Nothing
;--------------------------------------------------------------------------------
Func _HashF_DefaultResizeAmt ( $amt )
    $amt = $amt + 0;
    If ( $amt > 0 ) Then 
        $_HashG_resizeAdder = $amt;
    EndIf
EndFunc


;--------------------------------------------------------------------------------
;Function Name:  _HashF_KeyPairCount
;
;Description:   Simple method to get the number of elements in the hash.  Will
;               return -1 and sets @ERROR to bitwise map of problem if an
;               invalid pointer is supplied.
;
;               NOTE: This method returns -1 rather than 0 in the event of a
;               problem because 0 is a perfectly legitimate answer.
;
;Parameter(s):   [$ptr] - Pointer to a hash (optional)
;
;Returns:       The number of key->value pairs currently in the hash.
;--------------------------------------------------------------------------------
Func _HashF_KeyPairCount ( $ptr = 0 )
    Local $err = _HashF_ValidatePtr( $ptr );
    If ( $err <> 0 ) Then
        SetError( $err );
        Return( -1 );
    EndIf
    
    Local $index = _HashF_FindIndex( $ptr );
    Return( $_HashG_container[$index][0][0] );
EndFunc


;--------------------------------------------------------------------------------
;Function Name:  _HashF_Keys
;
;Description:   Simple method to get a list of keys in the hash - $array[0]
;               contains the number of elements in the array.  Will return
;               a one dimensional array with the value "0" in the zero'th
;               element if the hash is empty.  Will return a one dimensional
;               array with the value -1 in the zero'th element if the pointer
;               is invalid.
;               
;               Example:
;               $array[0] = 7  : 7 keys in hash $array[1] -> $array[7] = keys
;               $array[0] = 0  : no keys in hash
;               $array[0] = -1 : pointer passed was invalid
;
;Parameter(s):   [$ptr] - Pointer to a hash (optional)
;
;Returns:       A one dimensional array of the keys.
;--------------------------------------------------------------------------------
Func _HashF_Keys( $ptr = 0 )
    Return _HashF_Stuff( $ptr, 0 );
EndFunc


;--------------------------------------------------------------------------------
;Function Name:  _HashF_Values
;
;Description:   Simple method to get a list of values in the hash - $array[0]
;               contains the number of elements in the array.  Will return
;               a one dimensional array with the value "0" in the zero'th
;               element if the hash is empty.  Will return a one dimensional
;               array with the value -1 in the zero'th element if the pointer
;               is invalid.
;               
;               Example:
;               $array[0] = 7  : 7 vals in hash $array[1] -> $array[7] = vals
;               $array[0] = 0  : no vals in hash
;               $array[0] = -1 : pointer passed was invalid
;
;Parameter(s):   [$ptr] - Pointer to a hash (optional)

;Returns:       A one dimensional array of the values.
;--------------------------------------------------------------------------------
Func _HashF_Values( $ptr = 0 )
    Return _HashF_Stuff( $ptr, 1 );
EndFunc


;--------------------------------------------------------------------------------
;Function Name:  _HashF_Entries
;
;Description:   Returns the key->value pairs in the hash pointed to by $ptr.
;               Follows same basic rules as _HashF_Keys and _HashF_Values as 
;               regards the overhead entries in the hashes, except that both
;               zero'th elements contain the overhead information.
;               
;               Example use:
;               <code>
;               _HashF_Put( "a", "A" );
;               _HashF_put( "b", "B" );
;               $array = _HashF_Entries();
;               
;               This produces the following result:
;               $array[0][0] contains 2
;               $array[0][1] contains 2
;               $array[1][0] contains "a"
;               $array[1][1] contains "A"
;               $array[2][0] contains "b"
;               $array[2][1] contains "B"
;               
;
;Parameter(s):   [$ptr] - Pointer to a hash (optional)
;
;Returns:       A two dimensional array with the keys and values.
;--------------------------------------------------------------------------------
Func _HashF_Entries( $ptr = 0 )
    Local $keys = _HashF_Stuff( $ptr, 0 );
    Local $vals = _HashF_Stuff( $ptr, 1 );
    Local $retVal[1][2];
    
    If ( ( UBound( $keys ) <> UBound( $vals ) ) Or ( $keys[0] <> $vals[0] ) ) Then
       ;Something is FUBAR
        MsgBox( 8208, "Hash Entries Error", "Fatal error encountered in hash" );
        $retVal[0][0] = -1;
        $retVal[0][1] = -1;
        SetError( $_HashC_UnknownError );
        Return( $retVal );
    EndIf
    
    ReDim $retVal[UBound( $keys )][2];
    For $i = 0 To $keys[0]
        $retVal[$i][0] = $keys[$i];
        $retVal[$i][1] = $vals[$i];
    Next
    Return( $retVal );
EndFunc


;--------------------------------------------------------------------------------
;Function Name:  _HashF_ValidatePtr
;
;Description:   A simple method to ensure a hash pointer is valid.
;
;Parameter(s):   $ptr - the pointer to test
;
;Returns:       0 if pointer is valid - or a bit map of problems encountered.
;--------------------------------------------------------------------------------
Func _HashF_ValidatePtr( $ptr )
    If ( $_HashG_container == 0 ) Then
        Return( $_HashC_NotInitialized );
    EndIf
    
    Local $tester = $ptr + 0;
    If ( ( $tester <> $ptr ) Or ( $ptr < 0 ) ) Then 
        Return( $_HashC_InvalidPointer )
    EndIf
    
    Local $index = _HashF_FindIndex( $ptr );
    If( $index == -1 ) Then
        Return( $_HashC_InvalidPointer )
    Else
        Return (0);
    EndIf
EndFunc


;    PRIVATE STUFF - DON'T USE!! 

;--------------------------------------------------------------------------------
;Function Name:  _HashF_FindIndex
;
;Description:   A simple method that finds the hash within the list of hashes.
;
;Parameter(s):   $ptr - the pointer to test
;
;Returns:       The index of the pointer, or -1 if pointer invalid
;
;NOTE: This would be a private method if AutoIt used encapsulation.  Use this
;method at your own risk!!
;--------------------------------------------------------------------------------
Func _HashF_FindIndex( $ptr )
    For $i = 0 To UBound( $_HashG_container, 1 ) - 1
        If ( $ptr == $_HashG_container[$i][0][1] ) Then
            Return($i);
        EndIf
    Next
    Return(-1)
EndFunc


;--------------------------------------------------------------------------------
;Function Name:  _HashF_FindKey
;
;Description:   A simple method to find a key in a hash.  Note: The index is not
;               necessarily the same as the pointer.
;
;Parameter(s):   $index - the index number to the hash
;
;Returns:       -1 if pointer is valid
;
;NOTE: This would be a private method if AutoIt used encapsulation.  Use this
;method at your own risk!!
;--------------------------------------------------------------------------------
Func _HashF_FindKey( $index, $key )
    For $i = 1 To $_HashG_container[$index][0][0]
        If ( $_HashG_container[$index][$i][0] == $key ) Then
            Return($i);
        EndIf
    Next
    Return(-1);
EndFunc


;--------------------------------------------------------------------------------
;Function Name:  _HashF_Stuff
;
;Description:   Returns either the keys or values associated with a hash.
;
;Parameter(s):   [$ptr] - Pointer to a hash (optional)
;
;Returns:       A one dimensional array of the values.
;
;NOTE: This would be a private method if AutoIt used encapsulation.  Use this
;method at your own risk!!
;--------------------------------------------------------------------------------
Func _HashF_Stuff( $ptr, $type )
    Local $retVal[1];
    $retVal[0] = 0;
    Local $err = _HashF_ValidatePtr( $ptr );
    If ( $err <> 0 ) Then
        SetError( $err );
        $retVal[0] = -1;
        Return( $retVal );
    EndIf
    
    Local $index = _HashF_FindIndex( $ptr );
    Local $count = $_HashG_container[$index][0][0];
    If ( $count > 0 ) Then
        ReDim $retVal[$count + 1];
        $retVal[0] = $count;
        For $i = 1 To $count
            $retVal[$i] = $_HashG_container[$index][$i][$type];
        Next
    EndIf
    Return ( $retVal );
EndFunc

How's my riding? Dial 1-800-Wait-There

Trying to use a computer with McAfee installed is like trying to read a book at a rock concert.

Link to comment
Share on other sites

In my previous post, it appeared as if I had a problem nobody else had ever encountered.  I guess this means that the attached code won't help anyone, but just in case...

(Non-comprehensive) Hash usage example:

I guess I just don't understand what "hash" is....unless you mean the corned beef, potatoes and onions concoction that come in a can by Hormel. If you'd be able to break it down to me in Reader's Digest form?

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

I guess I just don't understand what "hash" is

Sorry. Depending on the programming language used, there are a number of terms:

"Hash"

"Associative Array"

"Map"

...

The point is that one has a known "key" that stores a reference to a discovered "value". For example, suppose you are parsing a list of user info based on Social Security Number (for us colonists :( ). You could use the SSN as the key, and store the info found as the value. Later, you could look up the key and retrieve the value found.

[EDIT] As I said, it appears as if I have a problem nobody else has. Perl is big on Hashes - and that's how I normally aggregate my data. I'm trying NOT to use Perl this go-round though because it's difficult to get the Perl and AutoIt bits to cooperate. Freebie Perl compilers have a bit of difficulty digesting "use Win32::OLE;" - which complicates AutoItX. And I'd rather not have multiple executables - i.e "GetData.exe <- AutoIt", "ParseData.exe <- Perl", "Display.exe <- AutoIt".

Edited by mrider

How's my riding? Dial 1-800-Wait-There

Trying to use a computer with McAfee installed is like trying to read a book at a rock concert.

Link to comment
Share on other sites

Guest ytrewq1

I wouldn't complain if there were native support for such a data type as currently I use pairs of arrays (or 2 dimensional arrays) to simulate some of their behavior :-)

Link to comment
Share on other sites

I wouldn't complain if there were native support for such a data type as currently I use pairs of arrays (or 2 dimensional arrays) to simulate some of their behavior :-)

Agreed. If you look closely at my code, you'll see that I use a three dimensional array - where the first dimension increases for each hash pointer, the second dimension increases for each entry in the largest hash, and the final dimension is always two (key->value).

As I say in my original post, I could overcome the problem of having the entire structure sized to fit the largest single hash if I could figure out how to deal with anonymous arrays. I just can't wrap my head around all the problems caused by not having an actual reference to the array in AutoIt though.

This is a great addition. Thanks! I wish hash tables were a built-in part of the language.

Thanks. As I say earlier in this thread, I've reached a point where I'm tired of jumping through goofy hoops so I can mix Perl and AutoIt - for no other reason than to use Perl to aggregate data. Especially since the target client computers don't have the Perl environment installed.

FWIW, I'm working on sorts now. I intend to sort ascending or descending by key or value. The current Array sort algorithm does this, but I'm writing something specifically tuned for two dimensional arrays - and I'll use the Heap sort rather than Shell sort . I'll post the code here when done - possibly tomorrow.

How's my riding? Dial 1-800-Wait-There

Trying to use a computer with McAfee installed is like trying to read a book at a rock concert.

Link to comment
Share on other sites

Guest ytrewq1

As I say earlier in this thread, I've reached a point where I'm tired of jumping through goofy hoops so I can mix Perl and AutoIt - for no other reason than to use Perl to aggregate data.  Especially since the target client computers don't have the Perl environment installed.

I'm not familiar w/ the internals or design of AutoIt, but it seems like there's at least some chance that one could put together a programmatic interface [1] to some of AutoIt's functionality. That combined w/ one's favorite language might allow one to avoid reimplementing language features in AutoIt -- i.e. if there were a library that allowed access to some AutoIt functionality, perhaps it could be used via <insert-your-favorite-language> and some appropriate gluing [2].

I guess this approach wouldn't work for target client computers w/ no Perl environment -- but may be there's some way to make an executable that includes Perl (or a subset of its functionality) along w/ one's AutoIt-library-using-code and deploy that. I know there's something that does this for Python so I wouldn't be surprised if there were something similar for Perl.

Just some random musings :-)

[1] Unless there's one already.

[2] I guess for Perl there's the XS stuff -- it's literally been years since I've written glue code betweeen Perl and some non-Perl library so I don't remember the details.

Link to comment
Share on other sites

  • 3 weeks later...
  • 6 months later...

As i see, someone has the same idea what is the last and only thing missing in AutoIt - and it seems i've found another perl practicer.

I congratulate you for this solution. Must be some weekends of work. While searching for a hash solution i've found your include on

www.windows-unattended.de/forum/lofiversion/index.php/t3125.html

already B) so it seems im not the only one around which find hashes useful.

thanks for your work. It will save me a LOT of work in my own projects.

ThomasV

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...