NetTalk Central

Author Topic: best way to populate In Memory table  (Read 4846 times)

jking

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
    • Email
best way to populate In Memory table
« on: November 21, 2018, 06:43:13 PM »
Bruce,

     I have an study enrollment tps table in a NT 10 app.  I want to get some of this data into a Memory Table that I have added to my dictionary.  This data will be mainly dates of enrollment, so I can give users a weekly accounting of enrollment activity.  All users should have access so I don't think it is necessary for me to add a thread/user field at this point.  The key is that if other users add to the enrollment, then all users should be able to see the newest data.  I typically would do this with a queue but I want to display this data in a NetWebBrowse procedure, thus I am using the Memory Table. 
     I have placed the code to extract this data into many embeds of the NetWebBrowse procedure, but it seems this code gets called multiple times, filling the Memory Table with duplicate data.  So, what is the best embed to use?  Or, is there another technique I should use to populate the Memory Table?  Ideally, I want to load/re-load the memory table only when the specific NetWebBrowse procedure is called.

Thanks,

Jeff King

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: best way to populate In Memory table
« Reply #1 on: November 21, 2018, 11:51:13 PM »
The browse is an Event Handler - so it's called a lot for lots of events.

Frankly I'm not sure you should be populating it in the Browse at all - but perhaps that's a conversation for the user group webinar.

If you did do it in the browse, I recommend the GenerateBrowse routine - but be careful when loading it to make sure you don't double-up on entries that are already there.

cheers
Bruce

jking

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
    • Email
Re: best way to populate In Memory table
« Reply #2 on: November 23, 2018, 07:56:28 PM »
Bruce,

     I do have this working by placing my code in the Take Event - 1 Before Generate embed.  I only need the mem table populated when the browse procedure is called, as this is the only browse that will use it, and only certain users will have access to the procedure.  However, you indicated the browse may not be the place to populate it.  Ca you recommend a better place to do this?
   
     In addition, with the working code I have, I noticed that the browse showing this mem table will duplicate records on each refresh of the browser (Chrome in this case).  I suspect the mem table needs to be cleared but have been unsuccessful in doing this.  Can you suggest a solution for this?

Thanks,

Jeff

Jane

  • Sr. Member
  • ****
  • Posts: 372
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: best way to populate In Memory table
« Reply #3 on: November 24, 2018, 02:50:54 PM »
Jeff,

I picked this procedure some years ago (think it may have been posted by Arnor).  It just closes, deletes, and recreates a memory table.  (Or any table, for that matter).

Obviously, you will need to open() and usefile afterwards if your code is expecting the table to be open.

The parameter is the name of the file manager object.  EmptyIMDDtable(access:Invoices)



EmptyIMDDtable       PROCEDURE  (FileManager pFM)          ! Declare Procedure

  CODE
   
        Loop pFM.GetOpened() TIMES
            pFM.close()
        end ! loop
        remove(pFM.File)
        create(pFM.File)
        return

jking

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
    • Email
Re: best way to populate In Memory table
« Reply #4 on: November 24, 2018, 05:22:00 PM »
Jane,

     Thanks!  Using the appropriate close with remove has done what I need.

Jeff