2

How can i get an array of all objects in specific band, Detail or Header for example?

I success to get all objects using:

dw_1.Describe("datawindow.objects")
Hugh Brackett
  • 2,706
  • 14
  • 21
gilhanan
  • 335
  • 1
  • 6
  • 16

2 Answers2

1

You need to get the datawindow.visualobjects property that lists all the visible objects and for each object, you ask object_name.band to check if you want it.

An example that reuses the PbniRegex (that provides the uo_regex object in the code below) to simplify the properties parsing :

public function long of_get_band_controls (string as_band_name, ref string as_controls[]);
string ls_empty[]
int i, j
as_controls[] = ls_empty[]

uo_regex lnv_regex
lnv_regex = create uo_regex
lnv_regex.initialize( "([^\t]+)", true, false)
i = lnv_regex.search( describe("Datawindow.visualobjects") )
for j = 1 to i
    if describe( lnv_regex.match( j ) + ".band" ) = as_band_name  then
        as_controls[ upperbound(as_controls[])+1 ] = lnv_regex.match( j )
    end if
next
destroy lnv_regex

return upperbound( as_controls[] )
end function

That code comes from a datawindow herited object, hence it gets direct access to the describe method.

Seki
  • 11,135
  • 7
  • 46
  • 70
  • Sebastien, AFAIK `visualobjects` is for some reason undocumented, and therefore not formally supported. [I once asked about that](https://groups.google.com/d/topic/sybase.public.powerbuilder.datawindow/iZ3ZjtLQ6us/discussion) in a Sybase newsgroup, and was advised not to use it. I doubt there will ever be a problem with it, but I think whoever uses it should at least be aware of that possibility. – Eran Jul 21 '11 at 11:00
  • @eran, Oh, it's undocumented ? It must be a property that we found by chance when using the [DW debug machine](http://geni.embeddingperl.com/index.php?post/2011/06/06/My-Datawindow-DebugMachine) that lists all dw attributes through the `datawindow.attributes` property. Well, as the PB Classic virtual machine is phasing out, I suppose that it won't hurt to use it. – Seki Jul 21 '11 at 13:42
0

I don't know of any direct way to get that list, but once you have the complete list of objects, you can go over them and check each one's band:

ls_Obj = GetNextObjectFromList(ls_AllObjectsList)
ls_Band = dw_1.Describe(ls_Obj + ".band")
choose case ls_Band
  case "detail"
    // handle detail band objects
  case "header"
    // handle header band objects
  // etc.
end choose
Eran
  • 21,632
  • 6
  • 56
  • 89
  • What is the `GetNextObjectFromList()` that you use in your example ? You use it to parse the list of DW visual objects ? – Seki Jul 21 '11 at 09:09
  • @Seki, yes. Just a simple parser to obtain the next object from the list. No such built-in function, of course. – Eran Jul 21 '11 at 09:12