AcidCorps Posted October 19, 2007 Posted October 19, 2007 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
Kerros Posted October 19, 2007 Posted October 19, 2007 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. CODEFunc _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.
corz Posted October 19, 2007 Posted October 19, 2007 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..
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now