Posts: 1,058
Threads: 367
Joined: Oct 2007
With some 4000 user's qm-items in my qml file I was getting trouble in identifying messages, in that it concerns locating the qm-item which it gives the relevant output message. Therefore, I used the following (sample) technique in all my qm-items. Any comments and/or other more elegant techniques will be mostly appreciated. Best regards.
Function
tempf10
str si.getmacro(getopt(itemid) 1)
str caller.getmacro(getopt(itemid 1) 1);err caller=si
int i=17
_s=F"Sample message to display : {i}"
min 0; err out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
ret
Posts: 12,078
Threads: 141
Joined: Dec 2002
Function
outt
;/
function $s [caller]
;Shows text in QM output, like out, but with prefix "<time> : <link to outt call place> - ".
;s - text. Can contain <help #IDP_F1>tags</help>.
;caller - if 1, adds link to caller's caller, not to the direct caller. It is useful if the direct caller is another 'outX' function. Can be > 1 to use another caller in the call stack.
;EXAMPLE
;int i=17
;outt F"i is {i}"
DateTime t.FromComputerTime
str st=t.ToStr(2|4)
#if EXE&&(QMVER<=0x2040303)
GetCallStack _s 1
_s.getl(_s 2+caller) ;;get caller ("<>[]this[]caller[]...")
out "<>%s : %s - %s" st _s s
#else
lpstr si=getopt(itemname -(1+caller))
if(!si) ret
if si[0]='<' ;;sub-function
,int iid=getopt(itemid -(1+caller)) ;;gets sub-function id
,_s.getmacro(iid 1) ;;gets sub-function parent name
,si=_s.from(_s ":" si+findc(si '>')+1)
int pos=Statement(1+caller)
out "<>%s : <open ''%s /%i''>%s</open> - %s" st si pos si s
#endif
Posts: 1,058
Threads: 367
Joined: Oct 2007
Perfect ! Many thanks indeed.
Posts: 12,078
Threads: 141
Joined: Dec 2002
Added parameter caller.
Added &&(QMVER<=0x2040303).
Posts: 1,058
Threads: 367
Joined: Oct 2007
Let me report that if using "Statement" it can not locate the line if used in a sub function, for example :
Macro
temp01
Trigger
SF7
outt "Main"
sub.func
outt "End"
#sub func
outt "sub"
ret
No problem if using the "GetCallStack" method.
Please advice.
Posts: 12,078
Threads: 141
Joined: Dec 2002