1. (Skip ahead to -SKIP- if you want to skip the explanation of what I'm trying to do)

    I recently decided to start a guild and decided to use my own hosting computer to do the website. With this decision I wanted some features that I thought would be cool to have on the website (ie: officers having access to the guild bank transaction logs while they're not on WoW, etc). I couldn't find an addon that did this for me and since I have a background in various scripting languages I thought I'd take a jab at writing an addon to get the info that I wanted so I could parse it through a tcl script, blah blah blah. I've got a small script right now (37 lines total) that loops through GetNumGuildBankTabs doing a QueryGuildBankLog(i) so that I could then loop through GetNumGuildBankTransactions, store the output in a saved variable for processing.

    -SKIP-

    Here's the issue: GetNumGuildBankTransactions and GetNumGuildBankMoneyTransactions are not updating until I click on log (then each tab) or money log. Wowwiki doesn't show these functions as protected, just needing to be at the guild bank for QueryGuildBankLog. Is it something I'm misunderstanding or possibly misinformed about? I looked all of the related functions up here but didn't get any more information so anything that anyone can tell me would be very appreciated!

    Here's the issue: GetNumGuildBankTransactions and GetNumGuildBankMoneyTransactions are not updating until I click on log (then each tab) or money log. Wowwiki doesn't show these functions as protected, just needing to be at the guild bank for QueryGuildBankLog. Is it something I'm misunderstanding or possibly misinformed about? I looked all of the related functions up here but didn't get any more information so anything that anyone can tell me would be very appreciated!

    Once you have called QueryGuildBankLog you have to wait for the correct event before you can actually query the APIs. You can do this all programatically by selecting the correct tab, querying the log and then waiting for the event. Then the information should be available to you. Let me know if you need more information.

    Awesome, thanks for the reply! Just one quick question then I'll get back to that part of the addon.. when you query for a specific tab I'm assuming the UPDATED event will trigger for only that tab, is there a way to have the function wait for all logs to be updated or pass the tab # to the function so that I know which tab I should be looping through info for? Or does it only trigger when all logs have been updated?

    Nevermind, I think I found a way to do it (probably not the best way to) .. here's my idea.. simply put in an if statement that checks to see if any of the GetNumGuildBankTransactions(tab) or GetNumGuildBankMoneyTransactions returns 0.. if one does stop processing.. if not, process away.. again thanks for the help! I have a feeling I'm gonna be asking a few more questions when I get around to the guild calendar portion of it lol

    quassi, i am lookign for some script or addon like that do you think u could share with ,me?

    I'm doing something similar... the current working logic is something like: {NOTE: this is not what my code looks like exactly, but I snipped some pieces together...}

    1. register for the two events

       this:RegisterEvent("GUILDBANKFRAME_OPENED");
       this:RegisterEvent("GUILDBANKLOG_UPDATE"  );
      
    2. when the guild bank is opened, process the event by starting a chain of queries..

        -- When the bank is opened, send a server query on the money log... yeah,
        -- this might seem backwards, but its the sequence I wanted.  Note, the
        -- user tabs are 1..6, the money tab is maxtab+1 or 7.  Always.  After 
        -- the server request is sent, we're done with this event.  I probably
        -- should have a state flag saying query chain is in progress or something
        -- so we don't flake out and restart a new query sequence before finishing
        -- the last... or some means to kill off the current query or something.  After
        -- we send the server the query, we need to wait for all the data to come back.
        -- The update event is fired when all the data is ready on our (client) side.
          if (eventArg == "GUILDBANKFRAME_OPENED") then
                GBLogger.totalTabs = GetNumGuildBankTabs();
                GBLogger.thisTab = 7;
                QueryGuildBankLog(7);
          end
      
    3. when a query finishes, process it and kick off the next one...

        -- ok, we're being notified our client-side has all the query data, so
        -- we can process it... then kick off the next query in the sequence.
          if (eventArg == "GUILDBANKLOG_UPDATE") then
            if (GBLogger.thisTab == 7) then
                GBLogger:DumpLogMoney();
        --      Chain query to the next tab... the first one.
        --      should be more robust and check to see if there *is* a tab 1 available...
        --      but if not, then number of transactions will be 0 [no data], so for now
        --      no harm, no foul... future enhancement I guess.
                GBLogger.thisTab = 1;
                QueryGuildBankLog(1);
            end
            if (GBLogger.thisTab ~= 7) then
                GBLogger:DumpLogTab();
                GBLogger.thisTab = GBLogger.thisTab+1;
                if (GBLogger.thisTab <= GBLogger.totalTabs) then
                    QueryGuildBankLog(GBLogger.thisTab);
                end
            end
          end
      

      This worked for me. The reason the code you outlined works is that there is client side data cached from the last query from physically clicking a tab on the bank... you just don't know how stale it is. A query for the number of transactions is processed client side only -- so if there is no cached data available from some previous query, the count will return as 0. I suppose firing off all the queries at once and keeping a count of sent queries would work... maybe, it depends on how the API is written underneath. Anyway, send 4 client side queries? then the update event processor would count the number of events and not do anything until it recieves 4 acks/events. Otherwise you really don't know which query is finishing, as they could finish out of order depending on how much data had to be returned. All guesses, so I preferred the "safe" method of just chaining the queries like above.

    I've all of 3 hours experience with LUA, so I'm still learning its syntax. I know WHAT I want to do... just not HOW to do it yet. The final app will have a "name,qty,price" data file that is read in upon load. It will process the bank log for new events and compile which guildie owes the guild how much and then reconcile that against what was deposited. We have a pretty straight forward pricing policy, but only on certain high level items. Like level VII or above scrolls, level 70 potions, etc. so it isn't a huge list to be created/tracked. I suspect it will take me a looong time to learn how to detect new events, store them and maintain a running debit/credit database. The parsing is easy, the db part much harder for me based upon where I'm starting from.