Indigo Rose Software
Indigo Rose Software
Log in to the Customer Portal Customer Login
Software Development Discussion Forums Forums
+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2008
    Posts
    167

    Read a table from the bottom upwards?

    I have this:
    Entries = TextFile.ReadToTable(OggsString);
    EveryThreeLines = {};
    for I = 1, Table.Count(Entries), 7 do
    table.insert(EveryThreeLines, Entries[I]);
    1 = Entries[1]
    2 = Entries[2]
    3 = Entries[3]
    4 = Entries[4]

    end
    Last edited by ronwilliams; 07-29-2010 at 01:05 AM.

  2. #2
    Join Date
    Jun 2007
    Location
    Delphi II
    Posts
    1,347
    OMG, please put tags around your code people....

    Now, what exactly are you trying to do? Is that a seven step for a table called EveryThreeLines? I'm entirely confused.
    Action Plugins
    AllOn | Box | Class | Cursor | DXML | Error | Frames | GlobalPaths | Goto | Group | INIPlus | KeyLock | MathEx | Menu | Project | Resize | StatusBar
    Download

  3. #3
    Join Date
    Jun 2008
    Posts
    167
    Sorry, I would like to read a text file to a table and then read and remove the the lines from that table starting at the bottom, not the top.
    Hope that makes more sense.
    Ron
    Last edited by ronwilliams; 07-29-2010 at 01:43 AM.

  4. #4
    Join Date
    Jun 2007
    Location
    Delphi II
    Posts
    1,347
    Ok,
    So if I had a table like this (assuming it has already been read from the text file)

    PHP Code:
    local tTable = {};
    tTable[1] = "First Entry";
    tTable[2] = "Second Entry";
    tTable[3] = "Third Entry";
    tTable[4] = "Fourth Entry";
    tTable[5] = "Fifth Entry"
    I would do something like this...

    PHP Code:
    local tNewTable = {};

    if 
    tTable then
    local nTotal 
    Table.Count(tTable);

        for 
    1nTotal do
        -- 
    I left 'nIndex' here as a local so you can see
        
    -- what is going on and in case you want to create sub tables.
        
    local nIndex = (nTotal x) + 1
        
    tNewTable[x] = tTable[nIndex];
        
    end

    end 
    This is air code...make sure ya test it. Hope that helps.
    Action Plugins
    AllOn | Box | Class | Cursor | DXML | Error | Frames | GlobalPaths | Goto | Group | INIPlus | KeyLock | MathEx | Menu | Project | Resize | StatusBar
    Download

  5. #5
    Join Date
    Oct 2009
    Posts
    541
    Code:
    local tTable = {"First Entry", "Second Entry", "Third Entry", "Fourth Entry", "Fifth Entry"};
    
    local tReversed = {};
    
    for K = #tTable, 1, -1 do
    	table.insert(tReversed, tTable[K]);
    end
    Tested here, seems to work.

  6. #6
    Join Date
    Jun 2008
    Posts
    167
    Thanks guys! It works. Sorry for the confusion! Will try and structure my questions better in the future.
    Ron

  7. #7
    Join Date
    Jun 2007
    Location
    Delphi II
    Posts
    1,347
    Wow! That is too cool. You always have some neat little lua trick up your sleeve dontcha, Sakuya?
    Action Plugins
    AllOn | Box | Class | Cursor | DXML | Error | Frames | GlobalPaths | Goto | Group | INIPlus | KeyLock | MathEx | Menu | Project | Resize | StatusBar
    Download

  8. #8
    Join Date
    Apr 2004
    Location
    Vancouver, Canada
    Posts
    1,790
    Quote Originally Posted by Centauri Soldier View Post
    Wow! That is too cool. You always have some neat little lua trick up your sleeve dontcha, Sakuya?
    Its not a trick, its in the help file under for loops. Its just looping backwards.
    Dermot

    I am so out of here

  9. #9
    Join Date
    Jun 2007
    Location
    Delphi II
    Posts
    1,347
    So it is. I mustv'e read that section a hundred times, but long ago before I knew anything about proper coding. Although I use the help file often for specific functions, it appears I need a refreshing overview of some of the highlight sections again.
    Action Plugins
    AllOn | Box | Class | Cursor | DXML | Error | Frames | GlobalPaths | Goto | Group | INIPlus | KeyLock | MathEx | Menu | Project | Resize | StatusBar
    Download

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Indigo Rose Software