NetTalk Central

Author Topic: Converting Q's to memory Tables  (Read 4174 times)

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Converting Q's to memory Tables
« on: October 20, 2009, 05:30:06 PM »
Hi All,

I'm going through the process of converting all my legacy Queues to Memory Tables for NTWS to work properly.

To make the job easier and also help with future maintenance I'm trying to reference the existing Q's (which I have renamed) rather than recreating them with all the fields etc

I tried this in the procedure which does not work but I was really just guessing and maybe it is not possible. Anyone know if this is possible?

EQueue2              FILE,DRIVER('MEMORY','/THREADEDCONTENT'),PRE(EXQ2),CREATE
                     &QUEUE(EQueue2_)
                     END
                     END
Cheers,

Kevin

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11183
    • View Profile
Re: Converting Q's to memory Tables
« Reply #1 on: October 20, 2009, 09:59:32 PM »
Hi Kevin,

Nice try, but no, I don't think a Queue is a valid data type inside a file structure.

Cheers
Bruce

ccordes

  • Sr. Member
  • ****
  • Posts: 384
    • View Profile
    • Email
Re: Converting Q's to memory Tables
« Reply #2 on: October 21, 2009, 01:56:48 PM »
No. BUT
You could do this -

MyFile  File,Driver('MEMORY'),PRE(MYF),CREATE
k1  KEY(MYF:Field1)
record  record
mygroup Group(myQueue)
    end
    end
    end

You could then load the mem table easily with a loop
loop j=1 to records(Myqueue)
Get(MyQueue,j)
MYF:MyGroup = MyQueue
add(MyFile)
end

JAT,
Chris
Real programmers use copy con newapp.exe

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Converting Q's to memory Tables
« Reply #3 on: October 21, 2009, 05:57:19 PM »
Thanks Chris. I tried the following and did not get any compile errors but have not tested in the app yet. I added a group to my Q but your example looks like I can just pop the Q into a group in the mem table. I just tested this and it consistently crashes the Clarion Compiler! Looks like it does not like a Q inside a Group unless I misunderstood your example.

BTW, by renaming the existing Q, all I need to do is open, create and close the mem table (which is now the same name as the original Q). All my existing code that loads and reads the Q now works on the mem driver without me changing any code which is a big time-saver for me as I loved Q's! If my example below works, it also means I can keep adding/changing fields on my Q's without having to remember to do it to the mem table instead.

EQueue1              FILE,DRIVER('MEMORY','/THREADEDCONTENT'),PRE(EXQ1),CREATE
Record                  Record,PRE()                       !
RecFields                     LIKE(EXQ1_:Record) !Record is a group in the Q
                     END
                     End

ccordes

  • Sr. Member
  • ****
  • Posts: 384
    • View Profile
    • Email
Re: Converting Q's to memory Tables
« Reply #4 on: October 21, 2009, 06:20:45 PM »
Remember to define the Queue before the Mem Table.
I had no problem compiling an example.

!Define the Queue
myQueue Queue
somefiled  struing(10)
someotherfield   long
etc     byte
 end
!Define the table
MyFile  File,Driver('MEMORY'),PRE(MYF),CREATE
k1  KEY(MYF:Field1)
record  record
mygroup Group(myQueue)
    end
    end
    end

CODE

Chris
Real programmers use copy con newapp.exe

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Converting Q's to memory Tables
« Reply #5 on: October 21, 2009, 09:30:02 PM »
Yep the Q was defined before the mem table. What version of Clarion are you using? I would love to get your method to work as it is time consuming adding a group into all the Q's as I need to add the group and then move all the fields 1 by 1 into the group as the Q was created in the IDE and not code.

ccordes

  • Sr. Member
  • ****
  • Posts: 384
    • View Profile
    • Email
Re: Converting Q's to memory Tables
« Reply #6 on: October 22, 2009, 01:26:39 PM »
I'm using 6.3 9056
Here is an example I used. Not Nettalk, but shows the idea. I'm not sure how you want to maintain sync between Q and Mem Table. I just let the Memtable take care of itself and display using the Q fields with Q=Mem before displaying.
See the SetQueueRecord in the Qtable browse.

chris

[attachment deleted by admin]
Real programmers use copy con newapp.exe

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Converting Q's to memory Tables
« Reply #7 on: October 25, 2009, 09:22:31 PM »
Thanks Chris,

I *think* the problem is that I am creating memory tables and Queues on the fly and not in the dictionary like you have done. I sure wish there was an easy way to do this.

Cheers,

Kevin

ccordes

  • Sr. Member
  • ****
  • Posts: 384
    • View Profile
    • Email
Re: Converting Q's to memory Tables
« Reply #8 on: October 26, 2009, 10:36:21 AM »
My first sample this was made on the fly.
I did this in the dictionary because I thought that was how you were working and just to see if I could stay within the limits of the templates and all.
This version -
Code: [Select]
!Define the Queue
myQueue Queue
somefiled  string(10)
someotherfield   long
etc     byte
 end
!Define the table
MyFile  File,Driver('MEMORY'),PRE(MYF),CREATE
k1  KEY(MYF:Field1)
record  record
mygroup Group(myQueue)
    end
    end
    end

CODE
was done just at the head of procedure.
What compiler error were you getting?

Real programmers use copy con newapp.exe

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Converting Q's to memory Tables
« Reply #9 on: October 26, 2009, 02:28:02 PM »


The error is more of a GPF.

"Clarion 6.3 32Bit Server has encountered a problem and needs to close...." It just leaves Clarion hanging and I have to use TaskManager to close it down.

Here is what I have:

TestQueue             QUEUE,PRE(TSTQ)                      !
Chart                STRING(18)                            !
Insu                 STRING(2)                             !
Free                 STRING(1)                             !
TaxCode              STRING(2)                             !
Desc                 STRING(210)                           !
Vouc                 STRING(6)                             !
Code                 STRING(2)                             !
Rec                  LONG                                  !RECONCILE
Invo                 STRING(15)                            !INVO
EmplCode             STRING(6)                             !
Tran                 ULONG                                 !
Trn2                 USHORT                                !
DISPOSAL             STRING(30)                            !DISPOSAL
SALEAMOUNT           DECIMAL(12,2)                         !SALEAMOUNT
                     END                                   !

MemQueue              FILE,DRIVER('MEMORY','/THREADEDCONTENT'),PRE(MEMQ),CREATE
K1                     KEY(MEMQ:Chart)
Record                 Record
RecGroup                Group(TestQueue)
                        End
                       End
                     End

ccordes

  • Sr. Member
  • ****
  • Posts: 384
    • View Profile
    • Email
Re: Converting Q's to memory Tables
« Reply #10 on: October 27, 2009, 05:09:11 AM »
The only thing wrong here is that the Queue needs to be global.
If you need it to be local, then create the queue global typed - NormalQ Queue, TYPE
and then you can define a queue locally TestQ Queue(NormalQ);end
The memory table can also be defined locally using the NormalQ data type as the record structure.

Originally, I thought you could have record record(NormalQ), but you do have to put in the group as a holder for it.

Chris
Real programmers use copy con newapp.exe

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Converting Q's to memory Tables
« Reply #11 on: October 27, 2009, 05:34:38 PM »
Hi Chris,

Thanks for your persistence on this thread.

Yes they need to be local and TYPE now gives me a clean compile!

Although I need to add in some hand code for the memory table, create it, open it, close it, rename the original Q and tick TYPE, this is a really fast way to convert all my Queues to Memory Tables without having to change any of my code that used the original Queue as I have simply given the mem table the original Queue name.

Cheers,

Kevin