01-26-2021, 12:46 PM (This post was last modified: 01-26-2021, 12:53 PM by redbull2k.)
This is my take on it
str aa=
lable1
run "notepad" ;;comment
;run "notepad" ;;comment2
_i+1
if _i=3
ret
goto lable1
;coment3
ARRAY(str) result
str line
foreach line aa
str pattern= ";\D*."
line.replacerx(pattern "")
if(line.len)
result[]=line
str answer= result
answer.replacerx("$[]" "")
out answer
When im pasting its adding ;
so here is an image to show
Thanks for your help
It doesn't work in the actual test In the following code, I use the function aa.getsel, select the target code [Macro comment test] and test it
out
_s.getsel str s ss int i ARRAY(str) result if _s.len ,findrx(_s "goto(\s.+)"08 s 1); s.rtrim() ,foreach ss _s ,,if(StrCompareEx(ss s 1)<>0) ,,,ss.replacerx("^\040.+$|\040\;\;.+""") ,,if ss.len ,,,result[]=ss ,out result else ,out"nothing is selected" #ret ;lable1 run"notepad";;comment ;run "notepad" ;;comment2
_i+1 if _i=3 ,ret goto lable1 ;coment3
out
_s.getsel str s ss int i ARRAY(str) result if _s.len ,findrx(_s "goto(\s.+)"08 s 1); s.rtrim() ,foreach ss _s ,,if(StrCompareEx(ss s 1)<>0) ,,,ss.replacerx("^\040.+$|\040\;\;.+""") ,,if ss.len ,,,result[]=ss ,mes result else ,mes"nothing is selected" #ret function# hDlg message wParam lParam
ret ;messages2 sel wParam ,caseIDOK , , ,caseIDCANCEL , , , ret1
At present, there is only one problem
Using the following code, empty lines are removed:
______________________________________________________
ss.replacerx("^\040.+$|\040\;\;.+" "")
ss.replacerx("^\040.+$|\040\;\;.+|\011\040.+" "") ______________________________________________________
01-29-2021, 04:26 AM (This post was last modified: 01-29-2021, 05:02 AM by Kevin.)
actually it is not the replacerx line at all that is removing the line
it is this line
if ss.len
because the line len value is 0
I will recode this as there are a lot more issues that haven't come up yet that need to be fixed.
will post in a few minutes.
sorry for the delay got a phone call.
this covers a lot more but still doesn't cover everything.
out opt clip 1
_s.getsel if _s.len ,str s ss result ,int i j fn length1 length2 ,ARRAY(str) labels a b ,a=_s ,if(findrx(_s "goto(\s.+)"04 b 1)>0) ,,for i 0 b.len ,,,ss.formata("%s[]" b[0 i].rtrim) ,,ss.rtrim ,,labels=ss ,,ss.fix(0) ,if(findrx(_s "(?s) BEGIN DIALOG(.+?)''*'' '''' '''' ''''"01 s)<>-1) ,,foreach ss s ,,,labels[]=ss ,for(i a.len-1-1-1) ,,for(j 0 labels.len) ,,,if(a[i] = labels[j]) ,,,,fn=1 ,,,,j=labels.len ,,,else ,,,,fn=0 ,,if fn<>1 ,,,length1=a[i].len ,,,a[i].replacerx("^\040.+|\040\;\;.+|\011\040.+") ,,,length2=a[i].len ,,,if(length1!=0and length2=0) ,,,,a.remove(i) ,result=a ,result.rtrim;;remove extra emptyline at end of result that array adds on ,result.replacerx("(?:(?:(?!\n)\s)*\n){2,}""[][]");;replace multiple blank lines to 1 ,ShowText3"Results" result 02;;show the result in qm format else ,mes"Nothing is Selected!" #ret function# hDlg message wParam lParam
;Everything is the same as with <tip "#ShowText">ShowText</tip>, except: ;;;flag 1 (nonmodal) unavailable.
opt waitmsg 1 int i he=id(3ShowText(caption text hwndowner flags|1)) CHARFORMAT cf.cbSize=sizeof(CHARFORMAT)
cf.dwMask=CFM_FACE|CFM_SIZE strncpy(&cf.szFaceName "Courier New"12) long twips=12*20
cf.yHeight=twips ;;twips SendMessage he EM_SETCHARFORMATSCF_ALL&cf rep ,0.01 ,if(!IsWindow(he))break ret
if dont want comment out this line in above function