Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Programming Tool - Similar To OutVar but for Exe
#1
Hello All

I find I am always having to manually type out this out statement for logging various variable values in my code:


Code:
Select All      Help
str SampleVar = "Test"
str FuncName.getmacro(getopt(itemid 3) 1)
out F"[FuncMacro: {FuncName}]: SampleVar: '{SampleVar}'"

-->
Quote:[FuncMacro: Macro121]: SampleVar: 'Test'


I have thought there must be an easier way, like passing to a function to format and repaste - the problem is that this function OutVar doesn't work in exe. See below
So I rewrote it as a triggered function in QM editor. Two versions - one which is triggered by Double Right Click anywhere in variable name. Other triggered by keyboard command eg. WinP
Note that this is very fast as you don't have to select the variable, only have your cursor somewhere in the variable name characters. It will expand out to word boundaries and make new line for the output statement without breaking up even very long line of code.
Note however, this simplified super quick method only works for simple variable names. If the variable is part of an string or int ARRAY (eg. arrSampleArray[0 9] or is a member of a custome variable type eg. TYPE SampleType x.SampleMember, then you can still use this function. You will just have to select out entire variable, and then do same trigger. If will test if there is any selection and if not, select out to word border. If yes, then it will just go with the selection.

I couldn't figure out a way to add a trigger on to the QM RightClick Menu, similar to adding to Shell Menu. Is it possible?

Here is the code:

Function FStringOutFormat_KbTrigger
Trigger Wp /QM     Help - how to add the trigger to the macro
Code:
Select All      Help
str VarName.getsel    
if empty(VarName)
,dou
,VarName.getsel(0 0 child);;focused control,
key EDHYU;;moves to next line, create new line for paste
str QuotationMarks = "''"
QMITEM q
qmitem("" 1 &q 1)
str OutFormat = F"out F{QuotationMarks}[FuncMacro: {q.name}]: {VarName} = '{{{VarName}}'{QuotationMarks}"
paste OutFormat
Function FStringOutFormat_DouRClickTrigger
Trigger ##R /QM     Help - how to add the trigger to the macro
Code:
Select All      Help
key Z           ;; Esc;;gets rid of Edit popup menu in QM Editor
str VarName.getsel    
if empty(VarName)
,dou
,VarName.getsel(0 0 child);;focused control,
key EDHYU;;moves to next line, create new line for paste
str QuotationMarks = "''"
QMITEM q
qmitem("" 1 &q 1)
str OutFormat = F"out F{QuotationMarks}[FuncMacro: {q.name}]: {VarName} = '{{{VarName}}'{QuotationMarks}"
paste OutFormat

I hope this is helpful for others. Or if there is much easier way already available, let me know!
Thanks,
S
#2
Quote:I couldn't figure out a way to add a trigger on to the QM RightClick Menu, similar to adding to Shell Menu. Is it possible?
Directly to the menu - no.


Forum Jump:


Users browsing this thread: 1 Guest(s)