How Can I loading the file to table?

I want to load the coordinate from the text file into the table? any refer here? thanks!

You can use John Beebe's library or Crawlspacelib for that.
There are several other examples in the Share your code section.

Like this :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function loadTable(fp, baseDirectory)     
        local path = system.pathForFile( fp, baseDirectory or system.DocumentsDirectory)
        
        file = io.open(path, "r")
      
    local myTable = {}  
                
        if file then
                myTable = json.decode( file:read("*a")) 
                io.close(file)
                return myTable
        else
                return nil
        end
end
 
--To use
loadTable("myTable.data") -- for instance

Danny's example is spot on, except that it requires the data being read to be stored in JSON format (which I highly recommend you use to store your data anyway).

views:2283 update:2012/2/13 9:11:28
corona forums © 2003-2011