Template to access VIEW that is created by the Browse template?

Is there a way in template to access VIEW that is created by the Browse template?

In help there is Symbols Dependent on %View section, but %ViewFile template variable is always empty, and attribute is read only. Also, I could not find example in templates that are using %ViewFile.

The View and Fields are %Variables of the Browse Template so you need to REQ(Browse( ABC or Clarion ) ) to access them. You need to look at ABBrowse.TPW or Browse.TPW to see the %Variables. E.g. you want %ListView .

#SET(%ListView,%InstancePrefix & ':View:Browse')

An example of using the Browse View is in CTLHtml.TPW that makes HTML from a Browse. It uses the View and Fields. It is Legacy but would work the same as ABC.

#CONTROL(BrowseToHTML,'Create a HTML page from a CW browse box'),PROCEDURE,REQ(BrowseBox(Clarion))

%InstancePrefix:ReadNextPage ROUTINE
  LOOP HTMLLineCounter = 1 TO 10
    NEXT(%ListView)    <=== The Browse VIEW
      DO %InstancePrefix:CloseHTML
      TARGET{Prop:Timer} = 0
1 Like

@CarlBarnes thank you. Your answer helped me. Especialy REQ part.

I saw this in ABBrowse:

#SET(%ListView,%InstancePrefix & ':View:Browse')

but I was getting error that it is not defined. When I changed from #PROCEDURE to #CONTROL error was gone, and I could access other variables. So, it needs to be “attached” to browse for access.

Also, if somebody else gets stuck, #CONTROL template requires to have CONTROL section defined and also to have something inside. Or the IDE will crash when you add template. I have added image, with hidden attribute. What I mean is:

#CONTROL(SomeTemplate, 'Something...'),REQ(BrowseBox(ABC))

Again, thank you for help.

Instead of #CONTROL template you should create an #EXTENSION:

#EXTENSION(MyBrowseBoxExt,'My browse ext'),PROCEDURE,REQ(BrowseBox(ABC))

1 Like

Carl is correct that REQ would be a good approach, especially if this template is used only with an existing BrowseBox.

And Mike is correct that if you don’t need an additional control on the window for your template, then you should use an #EXTENSION rather than a #CONTROL template.

A couple of additional points:

Once you’ve created your extension, you have to populate it into your procedure. Go to the Extension tab, highlight the existing browse control, then add your new extension. That’s how the REQ fits in. (The process is different if it’s a #CONTROL template. In that case, the IDE automatically attaches your new control template to the existing browse. If there are multiple browse boxes, it will prompt you.)

If your template is useful without the BrowseBox, but benefits if it’s there, then you don’t have to use REQ for that. In this situation you can still access the other template’s symbols. You can use %ActiveTemplate and %ActiveTemplateInstance, along with #CONTEXT. This is a rather advanced approach, though. If you need to do this, I can throw an example together. In most cases, though, REQ is the most appropriate solution.


@Mike_Duglas, this is better from my primary solution. I do not need CONTROL part. Thank you.

@BoxSoft, thanks for detail explanation, and for mentioning #CONTEXT. There is section about it in help. For now, REQ is perfect solution for my need.

Once again, thank you all. You really helped me.

1 Like