GameSalad

Birthday Table

smurftedsmurfted Posts: 416Member, PRO

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 Posts: 2,720Member, PRO

    @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 Posts: 416Member, PRO

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

    Cheers @Hopscotch

  • JapsterJapster Posts: 362Member, PRO
    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 Posts: 8,960Member, Sous Chef, PRO, Bowlboy Sidekick GameSalad Employee

    Here's a video tutorial!

  • smurftedsmurfted Posts: 416Member, PRO

    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 Posts: 2,720Member, PRO
    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 Posts: 416Member, PRO

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

  • smurftedsmurfted Posts: 416Member, PRO

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

Sign In or Register to comment.