Sign in to follow this  
Followers 0
AcidCorps

Problem with getting Binary

3 posts in this topic

I'm working on a script that compares the binary information of multiple files

the following is a function that I am creating to add the binary information to an array

Func _FilesBinary($iFileArray)
    $iBinary = _ArrayCreate(UBound($iFileArray) - 1)
    For $i = 1 To $iBinary[0]
        $iRead = FileOpen($iFileArray[$i], 16)
        $iBinaryTemp = FileRead($iRead)
        _ArrayAdd($iBinary, $iBinaryTemp)
    Next
    Return $iBinary
EndFunc

I can't figure out what I did wrong but it only adds the information to the last element

Share this post


Link to post
Share on other sites



I'm working on a script that compares the binary information of multiple files

the following is a function that I am creating to add the binary information to an array

Func _FilesBinary($iFileArray)
    $iBinary = _ArrayCreate(UBound($iFileArray) - 1)
    For $i = 1 To $iBinary[0]
        $iRead = FileOpen($iFileArray[$i], 16)
        $iBinaryTemp = FileRead($iRead)
        _ArrayAdd($iBinary, $iBinaryTemp)
    Next
    Return $iBinary
EndFunc

I can't figure out what I did wrong but it only adds the information to the last element

I would try something like this.

CODE
Func _FilesBinary($iFileArray)

$iBinary = _ArrayCreate(UBound($iFileArray))

For $i = 1 To $iBinary[uBound($iFileArray) - 1]

$iRead = FileOpen($iFileArray[$i], 16)

$iBinaryTemp = FileRead($iRead)

_ArrayAdd($iBinary, $iBinaryTemp)

Next

Return $iBinary

EndFunc

I believe that when you are calling $iBinary[0] it is only doing the last element in the array, but I could be wrong.

Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

Share this post


Link to post
Share on other sites

It works fine for me. To test, I used..

#include "Include\corz_essentials.au3"
#include <Array.au3>
$FileArray = RecurseDir("I:\work\dev\autoit\test\smallfiles", "*.*")
PrintArray($FileArray,  "$foo")
$foo = _FilesBinary($FileArray)
PrintArray($foo,  "$foo")

Func _FilesBinary($iFileArray)
    $iBinary = _ArrayCreate(UBound($iFileArray) - 1)
    For $i = 1 To $iBinary[0]
        $iRead = FileOpen($iFileArray[$i], 16)
        $iBinaryTemp = FileRead($iRead)
        _ArrayAdd($iBinary, $iBinaryTemp)
    Next
    Return $iBinary
EndFunc
exit

;o)

(or


nothing is foolproof to the sufficiently talented fool..

Share this post


Link to post
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
Sign in to follow this  
Followers 0