Birthday Table

smurftedsmurfted Member, PRO Posts: 581

So i was wondering if anyone has worked out the best way to store and look through a table for a specific date.

For a birthday list?

Comments

  • HopscotchHopscotch Member, PRO Posts: 2,782

    @smurfted

    store the date as text, e.g. 19760421 (yyyymmdd)

    Then use the very fast tableSearch function. It the returns the row the value was found in. If nothing was found then it stays 0.

  • smurftedsmurfted Member, PRO Posts: 581

    Oh my goodness that function looks scary. I will have a bash and see if i can get it going...

    Cheers @Hopscotch

  • JapsterJapster Member Posts: 672
    edited November 2016

    @smurfted said:
    Oh my goodness that function looks scary. I will have a bash and see if i can get it going...

    Cheers @Hopscotch

    (EDIT - Stupid browser kept trying to populate my post with Hopscotch's tag every time I pressed ENTER, argh... )

    It's worth learning it though @smurfted- it's VERY fast/instant - the confusing stuff in there (for me initially) was understanding they just simply wanted "ROW" OR "COL" etc, and when I saw "[ROW|COL]" etc etc, I was wondering "WTH?!":- ie...

    tableSearch(table,key,"[row|col]",targetRowCol,startRange,endRange,"(not)[exact|beginsWith|endsWith|contains]")

    • looks daunting alright, but once you get one example working, it kind of falls into place, then you'll wonder how you got by without it!... :smiley:
  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    Here's a video tutorial!

  • smurftedsmurfted Member, PRO Posts: 581

    That is epic, thank you boys. This forum is still top class.

    Its only a basic start but its working.

    http://arcade.gamesalad.com/games/139211

    One question though, if two results come back true it just shows the first result, how can i get around that?

  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited November 2016

    @smurfted said:
    One question though, if two results come back true it just shows the first result, how can i get around that?

    Use a loop, but let it jump from found to found row instead of touching each row.
    If there are only 2 correct occurrences in a 1000 row table, the following loop will only cycle 3 times.
    Very fast and finds every occurrence of what you are looking for.

    Fast as in finding +-40 correct occurrences in a 1000 row table in ONE draw cycle. Woot GS!

    Set the "max loops/frame" to about as many correct rows as you expect, but less than 40.

    Change Attribute: self.loopIndex = 1
    
    Loop: While self.loopIndex <= tableRowCount(game.Table)
             Change Attribute: self.foundAtRow = 0
             Change Attribute: self.foundAtRow = tableSearch(game.Table,"key","col",1,self.loopIndex,tableRowCount(game.Table),"exact")
             Rule: self.foundAtRow > 0 then
                      * do what you need to do to that found row *
                      Change Attribute: self.loopIndex = self.foundAtRow+1
             Otherwise:
                      Change Attribute: self.loopIndex = tableRowCount(game.Table)+1
             End Rule
    End Loop
    
  • smurftedsmurfted Member, PRO Posts: 581

    Excellent, but I'm gonna give it a try in the morning.

  • smurftedsmurfted Member, PRO Posts: 581

    I know its been a while but wow, it works like a dream & its lighting fast...

Sign In or Register to comment.