Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Executes subfunctions within AutoText files by searching for comments
#1
Hi,

In the following example, some subfunctions have "one" or "two" in their comments
I want to find them by searching and then execute the subfunction of the selected item

I wrote the following code, but there are still three features that are not implemented

For better expression, I recorded the demo in the picture below
[Image: ab.gif]

Thanks in advance for any advice and help
david



Function Notepad_Dialog
Trigger Aw //Notepad_FF     Help - how to add the trigger to the macro
Code:
Copy      Help
;Note:
;When Notepad window opens, pressing hotkey Alt+W will popping up this dialog, Because it uses a filter function Notepad_FF

;Todo1:
;There are also two AutoText files use filter function Notepad_FF, Notepad_1 and Notepad_2, get all the items inside them
;Tip: In actual use, need to get all items in AutoText files that uses the same filtering function as the dialog
;The following code only gets the items in the Notepad_1 file, How to get another?(uses same filtering function as the dialog)

str name="Notepad_1"
str at=sub.atList(name)

ARRAY(str) aList=at
IQmDropdown ddl
int inERS

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x8 0 0 184 16 "Notepad_AutoText" "4"
;3 Edit 0x54030080 0x200 0 0 184 16 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""

str controls = "3"
str e3
if(!ShowDialog(dd &sub.DlgProc &controls)) ret

#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,;Todo2:
,;How to temporarily disable AutoText files except AT1 (because AT1 use global trigger $t)
,;to prevent others AutoText list popping up when typing
,;In this example, the files that should be disabled are: AT2, Notepad_1, Notepad_2 (They not use global trigger $t)
,
,__Font-- f.Create("Consolas" 14 0)
,f.SetDialogFont(hDlg "3")
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,;Todo3
,;How to execute the selected item's subfunction when the dialog box is closed
,
,case IDCANCEL
,
,case EN_CHANGE<<16|3 sub.OnTextChanged lParam
ret 1

#sub atList
function~ str'name

str pattern="(?m)(^.+) :sub.Sub\d+ ;;(.+)"
_s.getmacro(name 0)
str d
int i
ARRAY(str) a
findrx(_s pattern 0 4 a)
for i 0 a.len
,d.formata("%s - %s[]" a[1 i].trim a[2 i].trim)
ret d

#sub OnTextChanged v
function hEdit

if(inERS) ret
if(ddl) ddl.Close; ddl=0

str s.getwintext(hEdit)
if(!s.len) ret

ICsv x._create
x.AddRow1(0 "")
int i
for i 0 aList.len
,if(find(aList[i] s 0 1)<0) continue
,x.AddRow1(-1 aList[i])
if(!x.RowCount) ret

if(ShowDropdownList(x i 0 1 hEdit 0 0 0 ddl)&QMDDRET_SELOK=0) ret
s=x.Cell(i+1 0)

inERS=1
EditReplaceSel hEdit 0 s 1
inERS=0


Attached Files
.qml   Notepad.qml (Size: 7 KB / Downloads: 105)


Messages In This Thread
Executes subfunctions within AutoText files by searching for comments - by Davider - 12-08-2022, 12:21 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)