On Sunday, June 29, 2003, at 02:00 PM, T. R. Ponn wrote:
Thanks, but I forgot to mention I tried that...and surprisingly, it ran slower (about 27 seconds for that file):
if char 1 of memBank="0" then put "false" into toggle else put "true" into toggle
repeat for each char thisChar in fileContents
if toggle = false then put thisChar after bank0 else put thisChar after bank1
put not toggle into toggle
end repeat
I do have a fast computer (dual 1.25 GHz G4), but that time seems long. I can process an over-10MB file in that time using script local bank0 and bank1. Are you sure that's where your bottleneck is?
In case you are wondering, yes, putting a char after a long string in a variable is efficient.
You can speed this up by changing 'toggle = false' to 'toggle' and swapping initial toggle state, but then only about 15%.
Tim, if this is a big-endian, little-endian problem in the big picture, please mention that. I'm considering recommending that explicit byte order be added to binaryEncode and binaryDecode and would like to hear what you are doing to address this. Also, you might find some help with these functions in handling binary files in any case.
BINGO, Dar! That's exactly what I'm trying to do. 16b as 8b...big-endian, little-endian. I haven't yet figured out how to apply the binEncode/binDecode function to this. Sure wish there was a way...it would have to be faster than this.
Available is host byte order and network byte order. Do you remember which way network order is? Do you know know the order for your target computers? And if network and host are the same, how do you get the other order? I think the binaryEncode and binaryDecode functions are weak here.
They also can't do array or string accumulations for many data patterns such as even simple ones like yours. Well, I don't know how, anyway.
These are very powerful functions and are important in binary manipulation, but your example illustrates two weaknesses.
Off the top of my head... You might be interested in trying something like this:
function arrayFromFileImage @fileData
local signedInt16, a
repeat with i = 1 to length(fileData)/2
put binaryDecode("n",char i+i-1 to i+i of fileData,signedInt16) into numConverted
if numConverted is not 1 then exit repeat
put unsignedInt into a[i]
end repeat
return a
end arrayFromFileImage
This will return an array of numbers from an interpretation of the file as signed 16-bit ints in network order. I'll leave optimization and boundary review for another time/person. And remember, that is just an untested guess.
I'm going to suggest an enhancement to binaryDecode() that will allow this to be done in one binaryDecode for either of your byte orders. However, there is no special reason to think either RunRev or MC will agree or, if they did, there is no special reason to think this would be available soon.
Dar Scott
_______________________________________________ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
