How to get the browser column dynamically?

Posted by venky_suv on 20-Feb-2013 01:20

Suppose if there are 54 columns we can loop through using:

DO WHILE cnt < 54:  ( means 54 columns in the browse)

============================================

In the same way can we loopthrough the thing dynamically using Num-Entries(....)

If So pls explain the same.

All Replies

Posted by Marko Myllymäki on 20-Feb-2013 05:26

Something like this should do the trick:

DEF VAR hBrowse AS HANDLE.

DEF VAR hColumn AS HANDLE.

...

hColumn = hBrowse:FIRST-COLUMN.

DO WHILE VALID-HANDLE(hColumn):

     hColumn = hColumn:NEXT-COLUMN.

END.

or to directly reference a certain column by using column index:

hColumn = hBrowse:GET-BROWSE-COLUMN(col-index).

Posted by venky_suv on 20-Feb-2013 05:48

Thanks for ur reply Marko.

I wil explain my query below.

DEFINE VARIABLE loc_Width_tmp AS INTEGER   NO-UNDO EXTENT 54.
DEFINE VARIABLE tempdata      AS CHARACTER INITIAL '1' NO-UNDO.
DEFINE VARIABLE cnt           AS INTEGER   INITIAL 1   NO-UNDO.

OUTPUT STREAM a TO VALUE( i_filnamn ).

repeat while i
  for each printdata where printdata.column = i no-lock.
    if length(printdata.data) > length(tempdata) then
      tempdata = printdata.data.
    else.
    i = i + 1.
  end.
end.

==============================================

In the above example I did a sample code till 54 columns.

Now i have to make it a generic one. ie i should replace 54 with generic code since the columns of the browse will not be fixed through out the application.

Hw can it be done ?

Posted by Marko Myllymäki on 20-Feb-2013 06:26

I'm not sure if I understand your need but if you simply need the number of columns of a browse, you can get it with hBrowse:NUM-COLUMNS.

So you could use it like this:

do i = 1 to hBrowse:NUM-COLUMNS:

  for each printdata where printdata.column = i no-lock.
    if length(printdata.data) > length(tempdata) then
      tempdata = printdata.data.
    else.
  end.
end.

And you can define extent variables dynamically like this:

DEFINE VARIABLE loc_Width_tmp AS INTEGER NO-UNDO EXTENT.

EXTENT(loc_Width_tmp) = hBrowse:NUM-COLUMNS.

Hope this helps.

Posted by venky_suv on 21-Feb-2013 00:43

Perfect Marko !!! This was the kind of thing i was trying for !

Thanks

This thread is closed