Orphaned Embeds

I just noticed two orphaned embeds %ControlPostEventHandling and %ControlPreEventHandling. I have migrated to a couple Clarion releases and missed these at some point. I have no recollection of these. Can someone provide a little info?

That is a common embed point for handling control events.
Most likely a control was deleted from the window that had embed code.
If you look at the code inside the orphaned embed it might give you an idea of what it was doing.

Thanks. I can see the code, don’t know what it belonged to though. This happened at least 20 years ago. I found an back app from 2015 (Clarion 6). . .

Are these equivalent:

%Control Post Event Handling → %Control Handling, after event handling

%Control Pre Event Handling → %Control Handling, before event handling

Clarion 6 --------------------------------------- Clarion 9

If these are equivalent: I wonder if this could have come from Clarion 4 to Clarion 6.

This is what I have found in C6.

Search "%ControlPostEventHandling" (26 hits in 9 files of 268 searched)

  C:\Clarion6\Template\ABBROWSE.TPW (1 hit)
	Line 3055:                                            #!PROMPT('Advanced...',EMBEDBUTTON(%ControlPostEventHandling,%Control,'Accepted')),AT(100)

  C:\Clarion6\Template\ABWINDOW.TPW (3 hits)
	Line 639:   #EMBED(%ControlPostEventHandling,'Control Event Handling, after generated code'),%Control,%ControlEvent,LEGACY
	Line 1113:   #EMBED(%ControlPostEventHandling,'Control Event Handling, after generated code'),%Control,%ControlEvent,LEGACY
	Line 1156:   #EMBED(%ControlPostEventHandling,'Control Event Handling, after generated code'),%Control,%ControlEvent,LEGACY

  C:\Clarion6\Template\CTLBROWA.TPW (1 hit)
	Line 638:                                               #!PROMPT('Advanced...',EMBEDBUTTON(%ControlPostEventHandling,%Control,'Accepted')),AT(100)

  C:\Clarion6\Template\EXTENS.TPW (1 hit)
	Line 21: #AT(%ControlPostEventHandling)

  C:\Clarion6\Template\FIELD.TPW (2 hits)
	Line 86:       #PROMPT('Advanced...',EMBEDBUTTON(%ControlPostEventHandling,%Control,'Selected')),AT(100)
	Line 96:       #PROMPT('Advanced...',EMBEDBUTTON(%ControlPostEventHandling,%Control,'Accepted')),AT(100)

  C:\Clarion6\Template\ICONNECT.TPL (1 hit)
	Line 1176:     #EMBED(%ControlPostEventHandling,'Control Event Handling, after generated code'),%Control,%ControlEvent
  
  C:\Clarion6\Template\STANDARD.TPW (3 hits)
	Line 138:   #EMBED(%ControlPostEventHandling,'Control Event Handling, after generated code'),%Control,%ControlEvent
	Line 153:     #EMBED(%ControlPostEventHandling,'Control Event Handling, after generated code'),%CancelControl,'Accepted'
	Line 173:     #EMBED(%ControlPostEventHandling,'Control Event Handling, after generated code'),%Control,%ControlEvent

  C:\Clarion6\Template\wbgrp.tpw (1 hit)
	Line 319:     #EMBED(%ControlPostEventHandling,'Control Event Handling, after generated code'),%Control,%ControlEvent
Search "%ControlPreEventHandling" (23 hits in 7 files of 268 searched)
  C:\Clarion6\Template\ABWINDOW.TPW (3 hits)
	Line 617:   #EMBED(%ControlPreEventHandling,'Control Event Handling, before generated code'),%Control,%ControlEvent,LEGACY
	Line 1107:   #EMBED(%ControlPreEventHandling,'Control Event Handling, before generated code'),%Control,%ControlEvent,LEGACY
	Line 1150:   #EMBED(%ControlPreEventHandling,'Control Event Handling, before generated code'),%Control,%ControlEvent,LEGACY

  C:\Clarion6\Template\ICONNECT.TPL (1 hit)
	Line 1173:     #EMBED(%ControlPreEventHandling,'Control Event Handling, before generated code'),%Control,%ControlEvent

  C:\Clarion6\Template\MCRTREE.TPL (3 hits)
	Line 1413: #AT(%ControlPreEventHandling,%mTreeControl,'NewSelection')
	Line 1418: #AT(%ControlPreEventHandling,%mTreeControl,'Expanded')
	Line 1423: #AT(%ControlPreEventHandling,%mTreeControl,'Contracted')

  C:\Clarion6\Template\STANDARD.TPW (3 hits)
	Line 135:   #EMBED(%ControlPreEventHandling,'Control Event Handling, before generated code'),%Control,%ControlEvent
	Line 149:     #EMBED(%ControlPreEventHandling,'Control Event Handling, before generated code'),%CancelControl,'Accepted'
	Line 170:     #EMBED(%ControlPreEventHandling,'Control Event Handling, before generated code'),%Control,%ControlEvent

  C:\Clarion6\Template\wbgrp.tpw (1 hit)
	Line 316:     #EMBED(%ControlPreEventHandling,'Control Event Handling, before generated code'),%Control,%ControlEvent

  C:\Clarion6\Template\WIZARD.TPL (1 hit)
	Line 596:   EMBED %%ControlPreEventHandling

And if you want to know how to use the #EmptyEmbed, #PreEmbed, #PostEmbed

this is one way I use it, its implemented differently in the C6 shipping templates to how I use it.

#Application( 'ClassWriter' ) 
#EmptyEmbed( %grpCWAppEmptyEmbed( %Module, %Procedure, %EmbedID, %EmbedDescription, %EmbedParameters, %BytesOutput, %OutputIndent, %OutputColumn, %CommentColumn ), %CWAppDebugEmptyEmbedShow ) 
#PreEmbed( %grpCWAppPreEmbed( %Module, %Procedure, %EmbedID, %EmbedDescription, %EmbedParameters, %BytesOutput, %OutputIndent, %OutputColumn, %CommentColumn ), %CWAppDebugPreEmbedShow ) 
#PostEmbed( %grpCWAppPostEmbed( %Module, %Procedure, %EmbedID, %EmbedDescription, %EmbedParameters, %BytesOutput, %OutputIndent, %OutputColumn, %CommentColumn ), %CWAppDebugPostEmbedShow ) 
#Prepare 
#IF( NOT %CRLF = '<32,10>' ) 
#Set( %CRLF, '<32,10>' ) 
#EndIF
#EndPrepare 
#!
#Prompt( 'Show #EmptyEmbeds', Check ), %CWAppDebugEmptyEmbedShow, Default( %False ), AT( 10,,, ) 
#Prompt( 'Show #PreEmbeds', Check ), %CWAppDebugPreEmbedShow, Default( %False ), AT( 10,,, ) 
#Prompt( 'Show #PostEmbeds', Check ), %CWAppDebugPostEmbedShow, Default( %False ), AT( 10,,, )
#Display( '%CRLF' ) 
#Prompt( '', @s255 ), %CRLF 
#Group( %grpCWAppEmptyEmbed, %pModule, %pProcedure, %pEmbedID, %pEmbedDescription, %pEmbedParameters, %pBytesOutput, %pOutputIndent, %pOutputColumn, %pCommentColumn ), Auto 
#Declare( %pString, String ) 
#Set( %pString, '#EmptyEmbed %Module:' & %pModule & ' %Procedure:' & %pProcedure & ' %EmbedID:' & %EmbedID &' %EmbedDescription:' & %EmbedDescription & ' %EmbedParameters:' & %EmbedParameters & ' %BytesOutput:' & %pBytesOutput & ' %OutputIndent:' & %pOutputIndent & ' %OutputColumn:' & %pOutputColumn & ' %CommentColumn:' & %pCommentColumn ) 
#RunDLL( 'C6TemplateDebugView.dll', 'SendDbgView@Frsc', %pString ), Release, Win32 
#Return %pString 

#Group( %grpCWAppPreEmbed, %pModule, %pProcedure, %pEmbedID, %pEmbedDescription, %pEmbedParameters, %pBytesOutput, %pOutputIndent, %pOutputColumn, %pCommentColumn ), Auto 
#Declare( %pString, String ) 
#Set( %pString, '#PreEmbed %Module:' & %pModule & ' %Procedure:' & %pProcedure & ' %EmbedID:' & %EmbedID &' %EmbedDescription:' & %EmbedDescription & ' %EmbedParameters:' & %EmbedParameters & ' %BytesOutput:' & %pBytesOutput & ' %OutputIndent:' & %pOutputIndent & ' %OutputColumn:' & %pOutputColumn & ' %CommentColumn:' & %pCommentColumn ) 
#RunDLL( 'C6TemplateDebugView.dll', 'SendDbgView@Frsc', %pString ), Release, Win32 
#Return %pString 

#Group( %grpCWAppPostEmbed, %pModule, %pProcedure, %pEmbedID, %pEmbedDescription, %pEmbedParameters, %pBytesOutput, %pOutputIndent, %pOutputColumn, %pCommentColumn ), Auto 
#Declare( %pString, String ) 
#Set( %pString, '#PostEmbed %Module:' & %pModule & ' %Procedure:' & %pProcedure & ' %EmbedID:' & %EmbedID &' %EmbedDescription:' & %EmbedDescription & ' %EmbedParameters:' & %EmbedParameters & ' %BytesOutput:' & %pBytesOutput & ' %OutputIndent:' & %pOutputIndent & ' %OutputColumn:' & %pOutputColumn & ' %CommentColumn:' & %pCommentColumn ) 
#RunDLL( 'C6TemplateDebugView.dll', 'SendDbgView@Frsc', %pString ), Release, Win32 
#Return %pString 

The #RunDll 'SendDbgView@Frsc' uses Frsc aka *Cstring when its a hand coded project DLL and FRsc still *Cstring when its an AppGen created DLL.

C6TemplateDebugView .prj .clw

    Program

    Map
        Module('WinAPI')
            OutputDebugStringA(*cstring),Raw,Pascal,Name('OutputDebugStringA')
        End
        SendDbgView (*cstring dbgvwmsg)
    End

  Code

SendDbgView      Procedure (*cstring dbgvwmsg)
    Code
    OutputDebugStringA(dbgvwmsg)

To get the DLL’s to work you need to edit the windows environment path

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Clarion6\BIN;C:\Clarion6\3rdparty\Bin;

basically adding C:\Clarion6\3rdparty\Bin to the end of the %Path%

and edit the clarion Redirection file.

[Common]
*.dll = .;%ROOT%\bin; %ROOT%\3rdparty\Bin

where C:\Clarion6\3rdParty\Bin is the folder holding all my DLL’s that are used in my templates.

Adjust for C7+ folder layouts accordingly.

If you want to quickly open the Clarion template file in a separate text editor like in this image.

This is the code. Add the code from #Prepare to #EndButton to all the shipping template #Procedure’s and it will popup the template file in a text editor. BUT you will need to swap out the "' & LongPath() & '\' & %Procedure & '.tpw"' and find a way to find the template name, perhaps by getting %ProcedureTemplate and finding the physical file containing the value in %ProcedureTemplate using a modified DLL to the one below.

#Procedure(Template_Group,'Template: Group','Template')
#Prepare 
#Set( %RunCommand, '"C:\Program Files\Notepad++\NotePad++" "' & LongPath() & '\' & %Procedure & '.tpw"' ) 
#EndPrepare 
#Prompt( '', Text ), %RunCommand 
#Display( '%Run Command' ) 
#Button( 'View Source' ), WhenAccepted( %TB4grpRUN( %RunCommand ) ), AT( ,, 175, ) 
#EndButton 
#Embed(%EmbedTemplateGroup,'010 Group Embed'), Label, NoIndent 
#Embed(%EmbedTemplatePrepare,'020 Prepare Embed'), Label, NoIndent 
#Embed(%EmbedTemplateControls,'030 ControlsEmbed'), Label, NoIndent 
#Embed(%EmbedTemplateEmbedsAndGeneratedCode,'040 Embeds and Generated Code Embed'), Label, NoIndent 
#Group( %TB4grpRUN, *%pRunCommand ), Auto 
#RunDLL( 'C6Run.dll', 'RUNCOMMAND@FRsc', %pRunCommand ), Release, Win32 

C6Run.app compiled to DLL, first procedure is RunCommand and this is all the code to execute the command using the View Source embed editor view so its showing the embed text below as well.

RunCommand           PROCEDURE  (*Cstring pRunCommand)     ! Declare Procedure
Loc:CommandString    CSTRING(1024)                         !
! Start of "Data Section"
! [Priority 3500]

! End of "Data Section"
  CODE
! Start of "Add additional DebugHook statements"
! [Priority 5000]

! End of "Add additional DebugHook statements"
! Start of "Processed Code"
! [Priority 4000]
    !(*Cstring pRunCommand)
    Loc:CommandString = pRunCommand
    !Message( '"' & Loc:CommandString & '"' )
    Run( Loc:CommandString )

    Case RunCode()
    OF 0
        pRunCommand = 0
    OF -1
        pRunCommand = '-1'
    OF -2
        pRunCommand = '-2'
    OF -3
        pRunCommand = '-3'
    OF -4
        pRunCommand = '-4' & ',' & Error()
    Else
        pRunCommand = 'Unknown'
    End

    Return
! End of "Processed Code"
! Start of "Procedure Routines"
! [Priority 3500]

! End of "Procedure Routines"
! Start of "Local Procedures"
! [Priority 5000]

! End of "Local Procedures"