Function AutoInputDialog
Function KeyAutoInputDialog
AID_var example
Function AID_var
AID_sel example
Function AID_sel
example
Macro Macro365
;/
function'str $template [int&nLeft]
;Shows an auto-created dialog containing Edit and ComboBox controls specified in template text like $inp_Label$.
;Returns template text where these substrings are replaced with user input.
;Also can contain variables like $var_Name$ that are replaced by your callback function.
;REMARKS
;Special substrings:
;$inp_Label$ - creates an Edit control and static text Label.
;$sel_Label$ - creates a ComboBox control and static text Label. To get ComboBox items, calls your function named AID_sel. See examples there.
;$var_Name$ - calls your function named AID_var. See examples there.
;$set_CaretHere$ - removes and sets nLeft = the number of Left keys to move the caret (text cursor) here.
;On Cancel ends this thread.
;Example - code in function KeyAutoInputDialog.
;In scripts you'll probably use KeyAutoInputDialog, not this function. Use this function only to create functions similar to KeyAutoInputDialog, for example to use paste instead of key.
ARRAY(str) a
if(!findrx(template "\$(?:inp|sel)_(.+?)\$" 0 4 a)) ret template
ARRAY(str) c.create(a.len+1)
c[0]="3"
str dd
dd.formata("BEGIN DIALOG[]0 '''' 0x90C80AC8 0x0 0 0 224 %i ''Manual Text Input''[]" a.len*30+40)
int i idEdit(3) idStatic(503) y(8)
for i 0 a.len
,dd.formata("%i Static 0x54000000 0x0 8 %i 214 10 ''%s''[]%i " idStatic y a[1 i].escape(1) idEdit)
,sel a[0 i][1]
,,case 'i'
,,dd.formata("Edit 0x54030080 0x200 8 %i 208 13[]" y+12)
,,case 's'
,,dd.formata("ComboBox 0x54230242 0x0 8 %i 208 213[]" y+12)
#ifdef AID_sel
,,c[i+1]=a[0 i]
,,AID_sel c[i+1]
#endif
,if(i) c[0].formata(" %i" idEdit)
,y+30
,idEdit+1
,idStatic+1
y+10
dd.formata("1 Button 0x54030001 0x4 116 %i 48 14 ''OK''[]2 Button 0x54030000 0x4 168 %i 48 14 ''Cancel''[]END DIALOG" y y)
;out dd
if(!ShowDialog(dd 0 &c[0])) end
str r
ARRAY(POINT) b
findrx(template "\$(?:inp|sel)_.+?\$" 0 4 b)
int j
for i 0 b.len
,POINT& p=b[0 i]
,r.geta(template j p.x-j)
,int u=0; if(template[p.x+1]='s') val(c[i+1] 0 u); u+1
,r+c[i+1]+u
,j=p.y
r.geta(template j)
#ifdef AID_var
REPLACERX k2.frepl=&sub.RRX
r.replacerx("\$var_\w+\$" k2)
#endif
if &nLeft
,nLeft=0
,i=find(r "$set_CaretHere$")
,if i>=0
,,r.remove(i 15)
,,for(i i r.len) if(r[i]!13) nLeft+1
ret r
#sub RRX
function# REPLACERXCB&x
AID_var(x.match)
;/
function $template
;Calls <help>AutoInputDialog</help> and types the text. Also sets caret if need.
;EXAMPLE
;_s=
;F
;;Dear Mr. $inp_Customer$,
;;
;;thank you for contacting us. The price is $$inp_Price$. Let's meet next $inp_Day$.
;;
;;Thanks and best regards,
;;$set_CaretHere$
;;
;;$var_ShortDate$
;;
;KeyAutoInputDialog(_s)
int nLeft
str s=AutoInputDialog(template nLeft)
spe 10
key (s)
if(nLeft) key L(#nLeft)
AID_var example
Function AID_var
;/
function str&s
sel s
,case "$var_ShortDate$"
,s.timeformat("{D}")
,
,case "$var_PcName$"
,GetUserInfo s 1
;add more case "$var_Something$" if need
AID_sel example
Function AID_sel
;/
function str&s
sel s
,case "$sel_Call$"
,s="Mrs[]Mr"
,
,case "$sel_Country$"
,s="United States[]United Kingdom[]France"
;add more case "$sel_Something$" if need
example
Macro Macro365