Browsing arrays

Post Reply
Gilbert
Posts: 74
Joined: Thu Oct 20, 2005 4:30 pm
Location: Canada

Browsing arrays

Post by Gilbert »

Hi all,

I have a situation where I need to browse an array. The problem is that it can be a one or two dimension array. At the time the array is passed to my function I still don`t know what type of array the function will have to browse and how many columns it includes.

So I want the function to determine this by itself and display all the elements and columns. So far I partly solved the problem execpt for oLbx:bLine where I have no idea of how I can display all columns.

Any ideas

Regards, :!:
Gilbert Vaillancourt
turbolog@videotron.ca
User avatar
Detlef Hoefner
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany
Contact:

Post by Detlef Hoefner »

Gilbert,

as far as i know you can not browse one dimensional arrays.
At least not with TWBrowse and TSBrowse.

One dimension you can list in a normal listbox.

Regards,
Detlef
Gilbert
Posts: 74
Joined: Thu Oct 20, 2005 4:30 pm
Location: Canada

Post by Gilbert »

Hi Detlef,

Sorry to tell you that I have browse array with TWBrowse without any problems in many of my applications so far.

That is not my problem. My real problem is that in the application under developpement I need to browse a 2 dimensions array not knowing how many column I will need. If the array was a fixed structure that would be no problem, but it the lenght of the second dimension change depending on what the user does.

Since all the columns must be predefine when calling TWBrowse I cannot use a loop to create the needed columns. That is my problem.


Regards,
Gilbert Vaillancourt
turbolog@videotron.ca
User avatar
Detlef Hoefner
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany
Contact:

Post by Detlef Hoefner »

Gilbert,

if you need a variable number of columns try this:

Code: Select all

   DEFINE DIALOG oDlg NAME "STATBROWSE" ;
          TITLE OemToAnsi( cTitle );
          of oWnd

   REDEFINE COLUMN BROWSE oBrow ID 40 OF oDlg

   oBrow:SetArray( gaStatArr )
   oBrow:nFreeze := 1


   ADD COLUMN TO oBrow ARRAY ELEM 1;
      HEADER  aHeader[1];
      SIZE    aSize[1];
      PICTURE aPict[1];
      NOBAR;
      LEFT

   for n := 2 to len( aHeader )
      oBrow:AddColumn( TCColumn():New(;
            OemToAnsi( aHeader[ n ] ), MakeBlock( n, oBrow ),;
            aPict[ n ],,, If( !.T., "LEFT", Upper( "RIGHT" ) ), aSize[ n ], .F., .F.,,,, .F. ) )
   next

   ADD COLUMN TO oBrow ;// ARRAY ELEM 1;
      HEADER  " ";
      SIZE    16;
      PICTURE NIL;
      NOBAR;
      LEFT
...
...
...

//////////////////////////////////
STATIC FUNCTION MakeBlock(n, oBrw)
//////////////////////////////////
RETURN ( {|x| if(pcount() > 0, oBrw:aArray[oBrw:nAt][n] := x, oBrw:aArray[oBrw:nAt][n])} )
This is sample when i use TSBrowse.
Maybe this could help you?

Best regards,
Detlef
Gilbert
Posts: 74
Joined: Thu Oct 20, 2005 4:30 pm
Location: Canada

Post by Gilbert »

Hi Biel,


At first look it seem like that`s what I was looking for. I will get on it this coming weekend.

Thanks

Gilbert
Gilbert Vaillancourt
turbolog@videotron.ca
Post Reply