Uniface on GitHub
Fixes and Updates
Is there a proc function that can determine which trigger/proc entry code is executing from? I've designed a global message generation routine in which I pass in the Trigger Name and Entry Name (if applicable). However, if I move the code to a different trigger and/or change the Entry name, I'll have to remember to change that info.
Example: I have an Entry in Entity_Name Local Proc Modules named GetUserInfo. In this entry I determine I want to log some information so I pass a list of something like $EntName;"Local Proc Modules";"GetUserInfo" to my global messaging routine.
Ideally, I'd like to pass Uniface-generated information instead (something like $EntName;$Trigger;$EntryName").
There are compile time constants for at least two of those.
"<$entname>" will produce the entity name.
"<$triggerabbr>" will produce the trigger abbreviation.
"<$fieldname>" will produce the field name.
Alternatively, you can look at the $proccontext("STACK"), which shows the entire call stack as a list of lists.
Depending where you look at this (inside your global routine (Global proc?) then the point which called it is the second or third entry in the list.
We have a global proc for logging which basically decodes the entire stack to save the point in the program at which the error occurs, and how it got there.
You need to look at the values in there for different points in the program (component triggers/operations/lpms, entity triggers/operations/lpms and field triggers/operations/lpms.
The $proccontext has the advantage of being coded once in the error routine, rather than in the call.
Perfect. I wanted to do it all in the messaging routine anyway but didn't know that functionality existed. I'll parse the stack. Thanx!
Sample output. I can work with this! (wish Uniface wouldn't UpperCase everything tho):
LIN=SPROCCONTEXT = $ProcContext("STACK")
Be aware the value of <$triggerabbr> is the name of the container which, in version 10, has changed - see <$triggerabbr> for more info.
This is very logical In UnifAce 10 there is only one big "pot" of proccode for each component/entity<$triggerabbr> is the name of this container and not the name of a specific TRIGGER, OPERATION, ENTRY, ...UnifAce should change "<triggerabbr>" to "<containerabbr>" to clearify thsi Ingo
There were many discussions at the time about what to do with <$triggerabbr> in the context of Uniface 10 code containers. One option was to change the name of the constant; however, as this would cause incompatibilities in existing applications, we decided to keep the name but allow it to be redefined. The new #startdefine and #enddefine precompiler directives were, in part, introduced to limit the scope of this constant.
#startdefine is nice, but ... The question was not, how could I use precompiler constants in a local context but how to get info about the "trigger" in which I'm doing my codinge.g on have a global include to check wether the component got focus or loose it, so you put this include in FRGF resp. FRLFIn this include there is a line like this call GP_DO_IT("<triggerabbr>")
Perfect in UnifAce 9 but in UnifAce 10, this not longer a usefull statement
This is a global function wich I did implement to get the caller instance.If you want to get the entry just one step up, you have to modify this routine a little bit Ingo
v_PROCCONTEXT_STACK = $proccontext("STACK")
FORLIST v_ITEM IN v_PROCCONTEXT_STACK
IF(v_INSTANCE="" & $item("OBJTYPE",v_ITEM)="APS") v_INSTANCE="*APS"
IF(v_INSTANCE!="" & v_INSTANCE!=v_INSTANCE_M)
$status=-57 ; UACTERR_NO_INSTANCE
END ; GF_CALLER_INS
© 2020 Uniface Privacy & Cookies | Privacy Statement | Legal