Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get a list of all AutoText files in the left pane
#82
How to use regular expressions, Replace the item fields in the Autotext (Divided into three segments, each with a tab indent), As the picture below looks like

How to modify?
"(?m)^(?:#sub +(\w+))"   


The following code has a minor problem that will be reordered, for example,
The original order of the items is
Sub3
Sub2
Sub1
Sub4

But after processing, the order becomes
Sub1
Sub2
Sub3
Sub4

How to save the original order?

 
Code:
Copy      Help
#sub gotoitemedit
function~ ~name
str s.getmacro(name 0); if(!s.len) ret

ARRAY(CHARRANGE)+ a; int i
if(0=findrx(s "(?m)^(?:#sub +(\w+))" 0 4 a)) ret

str items t
for i 0 a.len
int isBM=s[a[0 i].cpMin]!='#'
CHARRANGE& r=a[1+isBM i]
int n=r.cpMax-r.cpMin; if(n>0) t.get(s r.cpMin n); t.trim; else t=""
items.formata("%i %s[]" isBM t)

ret items

Autotext test
Trigger $t     Help - how to add the trigger to the macro
Code:
Copy      Help
/b/i/c/m
ta :sub.Sub3 ;;tc Comment
ta :sub.Sub2 ;;tb Comment
ta :sub.Sub1 ;;ta Comment
ta :sub.Sub4 ;;td Comment


#sub Sub1 m
_s=
F
;ta test
PasteAutoInputDialog(_s)


#sub Sub2 m
_s=
F
;tb test
PasteAutoInputDialog(_s)


#sub Sub3 m
_s=
F
;tc test
PasteAutoInputDialog(_s)


#sub Sub4 m
_s=
F
;td test
PasteAutoInputDialog(_s)


Attached Files Image(s)
   


Messages In This Thread
RE: How to get a list of all AutoText files in the left pane - by win - 04-18-2019, 03:43 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)