abi>>forums

abi>>forums (http://www.anythingbutipod.com/forum/index.php)
-   Zen X-Fi2 Applications & Development (http://www.anythingbutipod.com/forum/forumdisplay.php?f=221)
-   -   File Handling Help (http://www.anythingbutipod.com/forum/showthread.php?t=62832)

jbob182 04-29-2011 11:04 AM

File Handling Help
 
I have a couple of questions on file handling. The first is can anyone tell me why I am getting this error:
Quote:

20: bad argument #1 to 'read' (invalid format)
for this code:

Code:

function collision(file,p,mapmax)
    local collisiontable={};
    Collisionmap = io.open(file,"r");
    if p.lr == "left" then
        Collisionmap:seek("set",p.x);
    else
        Collisionmap:seek("set",p.x+p.maxx);   
    end
    for i=1,28 do
        table.insert(collisiontable,{});
        collisiontable[#collisiontable].type = Collisionmap:read("*n");
        Collisionmap:seek("cur",mapmax);
    end
    io.close(Collisionmap);
    return collisiontable
end

This was working before but now I do not know why it crashes ("*n") is a proper format.


Second question, i am trying to create a temporary file and this works to an extent:

Code:

tmpcol = assert(io.tmpfile())
tmpcol:close();

If you are wondering why assert is there it is because without assert it prints out the error:
Quote:

tmpcol is a nil value
if you put it there:
Quote:

Permission is denied
This happens with the adk, if you do not run as administrator ( vista/windows 7).

Does anyone know of a better way to create a temporary file?


All times are GMT -5. The time now is 03:20 PM.