Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loging special conditions in a code like QM Errors
#1
When an error occurs, special variable _error is filled with information about the error.

I am wondering whether there exists a way to log in a similar way special conditions of interest within a code, ie to simulate non QM errors. Most particularly I am in need of the place (offset of the statement in macro text) and/or the line (the statement).

Thanks in advance
#2
Macro Macro1188
Code:
Copy      Help
min 0; err out _error.place
#3
Dear Gintatas,

Many thanks, very useful indeed.

Regards
Simos
#4
I created the following dll function, and probably will add it to the next QM. Do you have suggestions, eg what more info it could get?

Macro Macro1189
Code:
Copy      Help
dll "qm.exe" #Statement [caller] [statOffset] [str*statement] [*itemId] [flags]

;Gets current statement info.

;caller - 0 current function, 1 caller, 2 caller's caller, and so on.
;statOffset - 0 current statement, 1 next, -1, previous, etc. If out of range, gets nearest (first or last) statement. Note that some statements, eg declarations, are not used at run time. To see used statements, run the macro in debug mode.
;statement - receives the statement. Can be 0 if not needed (faster).
;itemId - receives QM item id. Can be 0 if not needed.
;flags: 1 include indirect callers. Direct caller is macro or function that called current function by name.

;On success, returns offset of the statement in code.
;On failure, returns:
;-1 there is no caller at the specified depth.
;-2 the QM item is deleted or encrypted. Gets only itemId.

;Note that the results may be incorrect if you changed code after compiling it.
;Note that the caller's statement not necessary begins with current function's name. For example, it may be "var=CurFunc(1)" or "ret CurFunc(1)" or "AnotherFunc CurFunc(1) 2".
;Unavailable in exe.
;Added in QM 2.3.1.

;example
_i=0
_i=1
OutPrevStatement "Warning"

Function OutPrevStatement
Code:
Copy      Help
;/
function [$prefix] [statOffset]

str s sn; int i iid
i=Statement(1 iif(statOffset statOffset -1) &s &iid)
if(i<0) ret
sn.getmacro(iid 1)
out "<>%s%s<open ''%s /%i''>%s</open>: %s" prefix iif(empty(prefix) "" " in ") sn i sn s


Forum Jump:


Users browsing this thread: 1 Guest(s)