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

for Todo3:
I thought of a way, 
Get the text of the subfunction first, then use function RunTextAsMacro, but it can be a bit complicated

for Todo2:
I found a piece of code on the forum, but it may need to be modified
 
Code:
Copy      Help
#sub DisableEnableAutoText
function mode [str'dati] [str&atItems] [str&atditems]
QMITEM q; int i
ARRAY(str) atn atd
rep
,i=qmitem(-i 1|16 &q 1)
,if(i=0) break
,if q.itype=4
,,atn[]=q.name
,,sel mode
,,,case 1 ;;disable
,,,if(dis(q.name)) atd[]=q.name
,,,else dis+ q.name
,,,case else ;;enable
,,,int fdat=findw(dati q.name 0 "[]")
,,,if fdat = -1
,,,,dis- q.name
if(mode <>1) ret
atn.sort(8)
atItems=atn
atditems=atd

The following can execute the code for sub.Sub1

Macro Macro1
Code:
Copy      Help
_s=
;/b/i/c/m
;aa :sub.Sub1 ;;1 one a
;bb :sub.Sub2 ;;2 one b
;cc :sub.Sub3 ;;3 two c
;dd :sub.Sub4 ;;4 two d
;
;#sub Sub1 m
;"one a"
;
;#sub Sub2 m
;"one b"
;
;#sub Sub3 m
;"two c"
;
;#sub Sub4 m
;"two d"

ARRAY(str) a
findrx(_s "(?s)#sub Sub1 m(.+?)#sub Sub" 0 1 a)

;out a[1].trim
RunTextAsMacro a[1].trim


Messages In This Thread
RE: Executes subfunctions within AutoText files by searching for comments - by Davider - 12-09-2022, 05:42 AM

Forum Jump:


Users browsing this thread: 5 Guest(s)