Browsing arrays

Browsing arrays

Postby Gilbert » Tue Nov 07, 2006 12:36 am

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
Gilbert
 
Posts: 74
Joined: Thu Oct 20, 2005 4:30 pm
Location: Canada

Postby Detlef Hoefner » Fri Nov 10, 2006 5:49 pm

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
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Postby Gilbert » Mon Nov 13, 2006 7:50 pm

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
Gilbert
 
Posts: 74
Joined: Thu Oct 20, 2005 4:30 pm
Location: Canada

Postby Detlef Hoefner » Mon Nov 13, 2006 11:21 pm

Gilbert,

if you need a variable number of columns try this:

Code: Select all  Expand view
   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
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Postby Gilbert » Wed Nov 15, 2006 2:23 am

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
Gilbert
 
Posts: 74
Joined: Thu Oct 20, 2005 4:30 pm
Location: Canada


Return to FiveWin for CA-Clipper

Who is online

Users browsing this forum: No registered users and 3 guests

cron