> Le 11 janv. 2017 à 02:49, John DeSoi <[email protected]> a écrit :
>
> [...] It would be great if 4D had a function (e.g. Method name) that takes a
> *tokenized* method (not a string) and just returns the method name without
> executing it.
Hi John,
true, very often I would scratch my head: "is it called? where?"… until Vincent
de Lachaux saved my hair by showing a nice use of 'Method called on error' on
4dbb. Shortly, the method embeds its own error handler: simple, modular,
beautiful.
Example:
***
//ERR_method -> txt
C_TEXT($0)
C_LONGINT(myError_l)
$cmn_t:=Current method name
$errMethod_t:=Method called on error
If ($errMethod_t=$cmn_t) //context = error happened
myError_l:=ERROR
Else
$0:=$cmn_t //return my name as error handler
End if
//_
***
//test it
ON ERR CALL(ERR_method) //no quotes :-)
myError_l:=0
ARRAY TEXT($zzz;0)
$aaa:=$zzz{1} //ugly error
ON ERR CALL("")
ASSERT(myError_l#0)
//_
***
Other examples:
<http://forums.4d.fr/Post/FR/15999908/1/18591789#18591789>
<http://forums.4d.fr/Post/FR/16406246/1/16406247#16406247>
<http://forums.4d.fr/Post/FR/17359328/1/17359329#17359329>
--
Arnaud de Montard
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************