Get the entityname for an unqualified fieldname
Author: i2stiller@gmx.de (istiller)
Hi Freaks Is it possible to get the entityname for an unqualified fieldname? Say there are four entities painted: ENT_1A,ENT_2A and ENT_1B,ENT_2B In both entities ENT_1A and ENT_1B there is a field FIELD_1 In both entities ENT_2A and ENT_2B there is a button *----- ENT_1A -------------------------------* * * * *--- ENT_2A --* * * FIELD_1 * <button> * * * *------------------* * * * *------------------------------------------------* *----- ENT_1B -------------------------------* * * * *--- ENT_2B --* * * FIELD_1 * <button> * * * *------------------* * * * *------------------------------------------------* the button calls a global procedure to do something with FIELD_1
GP_GLOBAL
FIELD_1="xyz"
END
Uniface will access the next best FIELD_1, but how could I get this information by proccode? Maybe one would write some code to get the "rights" of a field (as an example)
GF_HAS_RIGHT returns boolean params string v_FLD:IN endparams variables string v_ENT endvariables v_ENT= ??? SELECTCASE "%%v_FLD%%%.%%v_ENT%%%" CASE "FIELD_1.ENT_1A" RETURN(1) CASE "FIELD_1.ENT_1B" RETURN(0) ENDSELECTCASE END
$fieldname("FIELD_1") will result in "FIELD_1" (not giving the entityname) $entname() will give "ENT_2A" resp. "ENT_2B" Is there a $fieldentname ??? Regards Ingo
3 Comments
Local Administrator
Hi Freak
First of all, it's not really recommended to deal with ambiguous field names. It's just not a good idea to let Uniface guess what you are trying to do.
Results might be unpredictable.
Anyways, I did a quick test here and there might be a small detour that should give you the required info. But this comes not for free. You could use the statement callfieldtrigger to call a extended field level trigger. So when you define a trigger for both fields FIELD_1 and use callfieldtrigger with the unqualified field name (FIELD_1) then the same field should be accessed. E.g.
trigger getEntName $result = $entname end;-trigger getEntName Now your GF_HAS_RIGHT would look like this:
GF_HAS_RIGHT returns boolean params string v_FLD:IN endparams variables string v_ENT endvariables callfieldtrigger "getEntName", v_FLD v_ENT= $result SELECTCASE "%%v_FLD%%%.%%v_ENT%%%" CASE "FIELD_1.ENT_1A" RETURN(1) CASE "FIELD_1.ENT_1B" RETURN(0) ENDSELECTCASE END Okay, it's not pretty, but it should do the job.
Regards, Daniel
Author: diseli (daniel.iseli@uniface.com)
Local Administrator
Think you are not using $entname in your trigger, but the precompiler constant for $entname. Perhaps using $properties to hold the "fieldentityname" would be a more direct approach with less overhead?
Author: ulrich-merkel (ulrichmerkel@web.de)
Local Administrator
You could also pass the name of the entity as parameter to the global proc. $entinfo($entname, "OUTER") might be worth a try in your case. Regards Jean-Luc
Author: lejolyjl (jean-luc.lejoly@labsolution.lu)