How can I move data around quickly?

Is there a way to move every byte of data in a 200K file to a new location, like a Big Endian file to a Small Endian, and write it back out quickly?

I am using string functions now, should I be using tables? How would I?

My method is taking over several seconds, but it must be preceived as instant. Any ideas?

io.file( file, "r" ); local str1 = ""; str1 = file:read(*a); io.close( file )
local str2 = ""; local str1Len = string.len(str1)
-- now the slow part --
for i=0, str1Len-1, 2 do
str2 = str2 .. str1:sub(str1Len-i-1, str1-i)
end

file2 = io.open( file2, "w" );
file2:write( str2 );
io.close( file2 )

Why are you doing this? File operations in Corona are probably not the tool you want.

I am trying to manipulate small portions of audio. I don't see how to play audio, without moving it back to a file first.

Never do batch concatenation in Lua as strings are immutable...instead, put every value into the row of a table, and then do a final table.concat at the end....will be instantaneous

Thanks dgaedcke, that definitely improves it.

views:1352 update:2011/10/5 21:23:48
corona forums © 2003-2011