Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Could be using XML or plain text files a workaround for a database? — Gideros Forum

Could be using XML or plain text files a workaround for a database?

MikeHartMikeHart Guru
edited December 2011 in Game & application design
My wife wants me to create an app with her. It will contain a lot of text data that has to be displayed. Basically like in a book. As gideros doesn't support databases, I am thinking about plain text files or maybe XML. The first approach would be much more simple to implement. How would you tackle such a problem?

Dislikes: DarkPixel, ExCx

Tagged:
+1 -1 (+0 / -2 )Share on Facebook

Comments

  • atilimatilim Maintainer
    edited December 2011
    I would put Lua tables in a .txt file and load them with loadfile function http://pgl.yoyo.org/luai/i/loadfile

    (also there are good XML readers in plain Lua. http://lua-users.org/wiki/LuaXml I like the one written by Alexander Makeev)
  • Can you please explain "put Lua tables in a text file"? I have no clue how this works.
  • atilimatilim Maintainer
    edited December 2011
    You're right :)

    First create a text file (just make sure that the extension of this file is not .lua because we don't want to execute it automatically)

    In this file, return a proper Lua table:
    -- file data.txt
    return {
        page1 = "this is first page",
        page2 = "this is second",
        page3 = "and so on....",
        page4 = {"maybe you have...", "multiple lines"},
    }
    Than load this data.txt file and call as a function:
    -- loadfile compiles the chunk and returns the compiled chunk as a function
    -- in case of errors, loadfile returns nil plus the error message
    -- assert is used to raise an error if loadfile fails
     
    local func = assert(loadfile("data.txt")) -- load the chunk as a function
    local data = func()  -- call the function to get the data
     
    -- print data
    for k,v in pairs(data) do
        print(k, v)
    end

    Likes: MikeHart

    +1 -1 (+1 / -0 )Share on Facebook
  • Thank you very much. That is exactly what I will need. And it is wicked cool!
  • Hello,

    I don't know if this may help you, but I have worked with a NoSQL database called CouchDB for some time now. It's API is completely RESTful, so you can perform CRUD and query it with simple HTTP requests. It can be installed locally (there are binaries for both Android and iOS), or connect to a web server instance in the cloud (Linux/Windows/Mac servers are available - managed Cloud services as well). See my tutorial series here if you want to learn more: http://averydc.com/ee/index.php/blog/couchdb_extjs4_a_winning_combination/

    Anyway, to fully utilize CouchDB's api, Gideros' URLLoader class will need to support two additional HTTP verbs (PUT and DELETE). Is it bold of me to ask that this be added to a future release? If it is added, then it may be drop dead simple to add full database support to your framework.

    Thanks.

    Likes: atilim, Daimyo21

    +1 -1 (+2 / -0 )Share on Facebook
  • While it is a great suggestion, espercially for saving information on a web server and retrieving it, I would not want to rely on a network connection for this app. But your suggestion is great. Thank you!
  • @MikeHart,

    CouchDB is designed from the ground up for "ground computing" (working while not connected to the Internet). Therefore, no network connection is required. CouchDB can be installed locally and accessed from its own built-in web server on localhost. It can be wrapped up in your Android or iOS project and installed along with your app in one package. Best of all, the entire engine is only about 4.5MB (on Android platform, anyway).

    One of the beauty's of CouchDB is the power of its replication. You can run CouchDB instances from anywhere and sync up with them however you like (client/server, peer to peer, etc.). The replication is easy to set up, automatic, and efficient. So, if you did have a CouchDB/web server in the cloud set up, your phone app can sync with it in the background when an Internet connection is available, but not hinder the operation of your app whether connected or not. This may open up new opportunities for your app.

    Please read J. Chris Anderson's blog here: http://blog.couchbase.com/j , as he is heading up development of CouchDB for mobile devices. You will find the current state of development and can download and play with it (all for free). If you are doing a "storybook" app, this may may be a way of adding content to your story without having to continue to release new apps.

    Shane
Sign In or Register to comment.