Dynamic Queue Field Creation 
Author Message
 Dynamic Queue Field Creation

Hi there!

Can the following be done?

---------------------------
BigQ  Queue
placeholder  long
      .
---code--
Loop I# = 1 to  FieldsNeeded
   case fieldtype[i#]
   of 'Long'
     BigQ.NewFld = New(Long)
   of 'String'
     BigQ.NewFld = New(String(80))
   ....
   else
     BigQ.NewFld = New(ANY)
   end
end

and then eventualy
  ?NiceList{Prop:From} = BigQ

The general idea is to
  1)  Create all fields needed in the queue at runtime
  2)  Use list control on window to display it
  3)  Allow user to specifiy what fields he want on screen.

But how do one use BigQ.NewFld, or rather how do one tell the compiler
you want a new/extra field in the queue.
---------------
Currently I'm doing it as follow..
---------------
BigQ  Queue
Fld1  String(80)
Fld2  String(80)
Fld3  String(80)
...
Fld50  String(80)
      End

And I use the Prop:Format property, to decide what heading names, etc will be.

-------------------
Any help will be appreciated.
-------------------



Fri, 30 Jul 2004 20:07:10 GMT  
 Dynamic Queue Field Creation
Hi Wanda,

AddfieldsToQueue  Routine

   bigQ.Fld1    = YourfirstValue
   .
   .
   .
   bigQ.Fld50   = YourLastValue
   add(bigQ)

Quote:

> Hi there!

> Can the following be done?

> ---------------------------
> BigQ  Queue
> placeholder  long
>       .
> ---code--
> Loop I# = 1 to  FieldsNeeded
>    case fieldtype[i#]
>    of 'Long'
>      BigQ.NewFld = New(Long)
>    of 'String'
>      BigQ.NewFld = New(String(80))
>    ....
>    else
>      BigQ.NewFld = New(ANY)
>    end
> end

> and then eventualy
>   ?NiceList{Prop:From} = BigQ

> The general idea is to
>   1)  Create all fields needed in the queue at runtime
>   2)  Use list control on window to display it
>   3)  Allow user to specifiy what fields he want on screen.

> But how do one use BigQ.NewFld, or rather how do one tell the compiler
> you want a new/extra field in the queue.
> ---------------
> Currently I'm doing it as follow..
> ---------------
> BigQ  Queue
> Fld1  String(80)
> Fld2  String(80)
> Fld3  String(80)
> ...
> Fld50  String(80)
>       End

> And I use the Prop:Format property, to decide what heading names, etc will be.

> -------------------
> Any help will be appreciated.
> -------------------



Sat, 31 Jul 2004 18:05:33 GMT  
 Dynamic Queue Field Creation
Sorry,

should have read more carefully before writing some nonsens.
You want to create fields, not put in some data.

Ralf

Quote:

> Hi there!

> Can the following be done?

> ---------------------------
> BigQ  Queue
> placeholder  long
>       .
> ---code--
> Loop I# = 1 to  FieldsNeeded
>    case fieldtype[i#]
>    of 'Long'
>      BigQ.NewFld = New(Long)
>    of 'String'
>      BigQ.NewFld = New(String(80))
>    ....
>    else
>      BigQ.NewFld = New(ANY)
>    end
> end

> and then eventualy
>   ?NiceList{Prop:From} = BigQ

> The general idea is to
>   1)  Create all fields needed in the queue at runtime
>   2)  Use list control on window to display it
>   3)  Allow user to specifiy what fields he want on screen.

> But how do one use BigQ.NewFld, or rather how do one tell the compiler
> you want a new/extra field in the queue.
> ---------------
> Currently I'm doing it as follow..
> ---------------
> BigQ  Queue
> Fld1  String(80)
> Fld2  String(80)
> Fld3  String(80)
> ...
> Fld50  String(80)
>       End

> And I use the Prop:Format property, to decide what heading names, etc will be.

> -------------------
> Any help will be appreciated.
> -------------------



Sat, 31 Jul 2004 20:47:33 GMT  
 Dynamic Queue Field Creation
Quote:

> Hi Wanda,

> AddfieldsToQueue  Routine

>    bigQ.Fld1    = YourfirstValue
>    .
>    .
>    .
>    bigQ.Fld50   = YourLastValue
>    add(bigQ)

---
 Hi Ralf, thanks for your help.

 I'm doing it like that at the moment. But I want to re-use same procedure
 for files with 10, 20, 40  or 50 columns, therefore sometimes I need
  bigQ.Fld1 to bigQ.Fld10, but other times I need bigQ.Fld1 to bigQ.Fld50
 I want to dynamically add columns to my queue - using NEW.

 I feel silly creating a queue with 50 fields, even though I can over an
  array onto it, and load the stuff via a loop. Still feel WRONG.



Sat, 31 Jul 2004 22:42:15 GMT  
 Dynamic Queue Field Creation
Wanda,

You could use a queue of queue pointers.  It works, but you have to be
careful about how you create, add, dispose and delete things to avoid memory
leaks.  Read the help on Queues, Reference Variables, NEW, ADD, DISPOSE, and
DELETE carefully and thoroughly.  Also, you can't put an array over it and
it takes more coding.

SmallQueue    QUEUE,PRE(SQ)
OneElement        STRING(20)  !or whatever
              END
LargeQueue    QUEUE,PRE(LQ)
ThisQueue         &SmallQueue
              END

For example, if you need 10 fields, you would create a bunch of SmallQueues
with 10 records.  LargeQueue would hold pointers to each SmallQueue.
--

Jay Guengerich
Reliable Development Corp.

C5EEb ABC, CW2.003, CFD 3.102



Sun, 01 Aug 2004 11:02:23 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Runtime field creation and dynamic assignment

2. pointer to pointer to field / dynamic field

3. table creation , queues, groups ect

4. CLASSes and QUEUEs (was: Re: QUEUE in QUEUE)

5. Dynamic class creation

6. Dynamic Class Creation

7. q: dynamic creation of editfields and menuitem.enabled

8. Dynamic control creation (side note)

9. Dynamic control creation

10. Dynamic class creation

11. Dynamic class creation

12. Dynamic creation of menu separator

 

 
Powered by phpBB® Forum Software