So when looking at the help documentation for #Call and #Insert, apart from #Insert having the extra NoIndent attribute, they look identical, but they are not and the help docs dont elucidate their differences.
#INSERT was the original, and always injected code at the current indent position. Thatâs why it has the NOINDENT option.
#CALL was added later, and is essentially the same as #INSERT,NOINDENT.
So why was #CALL added? Itâs considered a convention now that #INSERT should be used to denote the generation of code by the referenced #GROUP, whereas #CALL is used only for execution of template code.
I find that distinction helpful, as I want the intent of my code to be as readable and clear as possible. Regardless, you can use both as you see fit.
As I mentioned, #INSERT existed first, so itâs used more often than it needs to be. I still use #INSERT within the #PROMPT area, as youâre suggesting. In a sense, I consider it as âgeneration of template codeâ, rather than âgeneration of Clarion codeâ.
Where I use #CALL is when I want to execute some template logic, and the called logic will not directly generate any code.
Donât forget that thereâs a third way to invoke a groupâby using it in a template expression:
#SET(%MyVar, %MyGroup())
Alternatively, you could do that same thing using #CALL:
#CALL(%MyGroup), %MyVar
If your group had parameters, the alternate syntaxes vary accordingly:
The Help shows #INSERT can return a value, but I searched the shipping templates and did not find any. I would guess it calls the same template library âthingâ as #CALL so would work identically except NONDENT default.
Another way to get a kind of return value is passed by address *%Var
And when a CSV approach perhaps encapsulated with double quotes is employed for clarity to a single parameter Cstring passed by address, one starts to question if the single parameter is a single parameter for other parts of the template language like #RunDll.
#Group(%grpParseEquate,*%pIO1,*%pIO2)
#! This calls a procedure which passes a csv string back which is parsed into the two vars from
#! "WhenAccepted( %grpParseEquate(%EquateName,%EquateValue)"
#!
#Declare(%csvString)
#Declare(%commaPos)
#Declare(%csvStringLen)
#Set(%csvString,clip(%pIO1) &','& clip(%pIO2))
#RUNDLL('myrundll.dll', 'PROC3@FRsc',%csvString), release, win32
#Set(%commaPos,instring(',',%csvString,1,1) )
#Set(%csvStringLen,Len(Clip(%csvString)) )
#Set(%pIO1,Sub(%csvString,1,%commaPos-1) )
#Set(%pIO2,Sub(%csvString,%commaPos+1,%csvString - (%commaPos + 1) ) )