Moving things related to Control Templates to another Tab

I’ve done this twice in the past couple of months…

Needed to move something (in this case the list associated with a browsebox) to another tab. Ctrl-Xd it from where it was and Ctrl-Vd it on the tab I wanted it on.

Not a good idea…the immediate problem is that when you generate the queue related to the browse gets created without a name, so you can no longer compile the procedure. You can delete the list, but the GUI no longer recognizes it as attached to the control template, so you still have a bunch of half-wrong generated template code in your procedure.

Only option at that point, I think is to export to a TXA, delete everything related to that control instance, plus the file, reimport and start over.

Couple of things…1. don’t do it – moving it in the window text definition won’t cause you trouble. 2. If you do it is there any less messy way of recovering?

Maybe @Graham_Dawson the Clarionmag search wizard could find an article that I wrote about this kind of thing? May or may not be useful :slight_smile:

If you can get the template instance number then you can add the #SEQ(3) entries to the controls in the window text definition (where 3 is the template instance).
Also, if the #ORIG entries are deleted, you need to restore those. You can get that from the control template’s tpl/tpw file.
For example, here are two controls from an excel import/export template I have. You’ll want to restore the #SEQ(9) and #ORIG(?Import), #ORIG(?Export) values.

          BUTTON('Import'),AT(17,75,50,14),USE(?Import),LEFT,ICON('SpreadSheetImport.ico'), |
            HIDE,#ORIG(?Import),#SEQ(9),#ORDINAL(16)
          BUTTON('Export'),AT(16,92,50,14),USE(?Export),LEFT,ICON('SpreadSheetExport.ico'), |
            HIDE,#ORIG(?Export),#SEQ(9),#ORDINAL(17)

You can get the template instance from the TXA.

Not a recovery, but for future .

A) yes, if you want to move stuff from one tab to another doing it it the code (ie under the [Window …] code editor button) is fine or

B) don’t cut & paste the control. Rather drag and drop it. First drag it off the tab (i.e. off the sheet control). Say yes when it offers to move it off the tab. Then select the new tab and drag it back on (again select yes to move it onto the tab.)

Note that the top left corner of the control is what matters with regard to on or off.

You can do multiple controls together using this technique.

It works for between groups as well as tabs.

3 Likes

Tab order assistant it great for this sort of thing. Select the controls, either on the window or in the TOA. Then in the TOA drag and drop the selected lines on the desired tab.

Putting back the #SEQ on the control is a whole lot easier and more elegant than chopping bits out of the TXD and starting again. Thanks!

#ORIG() is usually not needed so I get rid of it as clutter, but I’m very careful Not to delete it if there is a #SEQ() as that can break generation for the Control template. I also get rid of #LINK().

A common one that needs #ORIG() with #SEQ() to generate would be the Browse Update buttons:

 BUTTON('&Insert'),AT(142,251,40,14),USE(?Insert:3),#ORIG(?Insert),#SEQ(3)
 BUTTON('&Change'),AT(185,251,40,14),USE(?Change:3),#ORIG(?Change),#SEQ(3)
 BUTTON('&Delete'),AT(227,251,40,14),USE(?Delete:3),#ORIG(?Delete),#SEQ(3)

If you wonder if #ORIG() is needed you can look in the TPW code to see if it uses the variable %ControlOriginal as seen in the BrowseUpdateButtons control template:

  #FOR(%Control),WHERE(%ControlInstance = %ActiveTemplateInstance)
    #CASE(%ControlOriginal)
    #OF('?Insert')
      #SET(%InsertControl,%Control)
      #SET(%InsertText,EXTRACT(%ControlStatement,'BUTTON',1))
      #SET(%InsertText,SUB(%InsertText,2,LEN(%InsertText)-2))
    #OF('?Change')
      #SET(%ChangeControl,%Control)
      #SET(%ChangeText,EXTRACT(%ControlStatement,'BUTTON',1))
      #SET(%ChangeText,SUB(%ChangeText,2,LEN(%ChangeText)-2))
    #OF('?Delete')
      #SET(%DeleteControl,%Control)
      #SET(%DeleteText,EXTRACT(%ControlStatement,'BUTTON',1))
      #SET(%DeleteText,SUB(%DeleteText,2,LEN(%DeleteText)-2))
    #ENDCASE
  #ENDFOR

#ORIG is important for Control templates.
#FIELDS is very important for Browse templates.

1 Like

Jon,
This is what I have been using for centuries (literally;)

Check the width/height of the window. Then make the window bigger. MOVE the control template controls out to the window and make sure that it ends up on the window - usually, you are prompted if you do want that. Create a new tab. MOVE all the stuff back from the window to the NEW tab. Reset the width/height of the window. Done :slight_smile:

The tab order assistant can also work, but on very complex windows it can get a bit confusing.

2 Likes

Anything like this I copy the procedure first in the appgen so I have a backup, before moving the list boxes from one tab to another but I always drag the list box off the sheet onto the window first then drag it onto the new tab ands it’s generally been ok for me.