04-19-2017, 04:52 PM
Better use dialog, not autotext.
Function dialog_paste_text_from_templates_123
Function dialog_paste_text_from_templates_123
;Shows dialog where you can select texts and replace keywords such as LOCATION. OK pastes the text.
;Need to edit something. The TODO lines show where and what.
;TODO: add more texts. Edit if need. It is CSV format. For " use "". For new line use new line.
str csvTexts=
;anm = "comes in today concerned about acne on his LOCATION. He reports having the acne for DURATION. During that time, he has used PAST TREATMENTS. He is currently using CURRENT TREATMENTS."
;anf = "comes in today concerned about acne on her LOCATION. She reports having the acne for DURATION. During that time, she has used PAST TREATMENTS. She is currently using CURRENT TREATMENTS. Patient reports the acne DOES/DOES NOT flare around her menstrual cycle."
;arm = "is following up for acne on the LOCATION. He was last seen on DATE, and prescribed TREATMENT. He reports his acne is (IMPROVED, WORSENED, STABLE). Patient admits to TAKING/NOT TAKING his medication(s) as prescribed. Pt DENIES/ADMITS side effects from the medication(s)."
;arf = "is following up for acne on the LOCATION. She was last seen on DATE, and prescribed TREATMENT. She reports her acne is (IMPROVED, WORSENED, STABLE). Patient admits to TAKING/NOT TAKING her medication(s) as prescribed. Pt DENIES/ADMITS side effects from the medication(s)."
;TODO: add more words and replacements. It is CSV too. In replacement lists use | as separator.
str csvWords=
;LOCATION = "face|face and chest|face and back|and so on"
;DURATION = "several days|several months|and so on"
;_______________________________
ICsv xt._create
xt.Separator="="
xt.FromString(csvTexts)
ICsv xw._create
xw.Separator="="
xw.FromString(csvWords)
xw.InsertColumn(2)
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 390 188 "Paste text"
;4 Static 0x54000000 0x0 4 60 48 13 "Text"
;5 ListBox 0x54230101 0x200 4 76 124 80 "tex"
;6 Static 0x54000000 0x0 136 60 48 13 "Word"
;7 ListBox 0x54230101 0x200 136 76 96 80 "wor"
;8 Static 0x54000000 0x0 240 60 54 13 "Replacement"
;9 ComboBox 0x54230241 0x0 240 76 144 82 "rep"
;1 Button 0x54030001 0x4 8 168 48 14 "OK"
;2 Button 0x54030000 0x4 64 168 48 14 "Cancel"
;3 RichEdit20A 0x54233044 0x0 4 4 380 48 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040500 "*" "" "" ""
str controls = "5 7 9 3"
str lb5tex lb7wor cb9rep re3
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
paste re3
#sub DlgProc v
function# hDlg message wParam lParam
int i c
str s r
ARRAY(str) a
sel message
,case WM_INITDIALOG
,c=id(5 hDlg)
,for(i 0 xt.RowCount) LB_Add c xt.Cell(i 0)
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
;OutWinMsg message wParam lParam
sel wParam
,case IDOK
,case IDCANCEL
,
,case LBN_SELCHANGE<<16|5 ;;texts
,_i=LB_SelectedItem(lParam); if(_i<0) ret
,s=xt.Cell(_i 1); s.setwintext(id(3 hDlg))
,c=id(7 hDlg)
,SendMessage c LB_RESETCONTENT 0 0
,for(i 0 xw.RowCount) if(findw(s xw.Cell(i 0))>=0) LB_Add c xw.Cell(i 0)
,SendMessage id(9 hDlg) CB_RESETCONTENT 0 0
,
,case LBN_SELCHANGE<<16|7 ;;words
,_i=LB_SelectedItem(lParam); if(_i<0) ret
,c=id(9 hDlg)
,SendMessage c CB_RESETCONTENT 0 0
,tok xw.Cell(_i 1) a -1 "|"
,for(i 0 a.len) CB_Add c a[i]
,
,case CBN_SELCHANGE<<16|9
,PostMessage hDlg message CBN_EDITCHANGE<<16|9 lParam
,case CBN_EDITCHANGE<<16|9
,;save the replacement in xw third column
,r.getwintext(lParam); if(!r.len) ret
,_i=LB_SelectedItem(id(7 hDlg)); if(_i<0) ret
,xw.Cell(_i 2)=r
,;get original text
,_i=LB_SelectedItem(id(5 hDlg)); if(_i<0) ret
,s=xt.Cell(_i 1)
,;replace
,for i 0 xw.RowCount
,,r=xw.Cell(i 2)
,,if(r.len) s.findreplace(xw.Cell(i 0) r 2)
,s.setwintext(id(3 hDlg))
ret 1
#sub Replace
function str&s str&var $name
TO_CBGetItem var
s.findreplace(name iif(var.len var name) 2)