Posts: 1,031
Threads: 246
Joined: Jul 2022
04-03-2023, 10:15 AM
(This post was last modified: 04-05-2023, 11:35 PM by Davider.)
What is the equivalent QM code for the following C++ code
#1 (For statement section)
int pos = SendEditor(SCI_GETCURRENTPOS);
int nPrevLinePos = SendEditor(SCI_POSITIONFROMLINE,line-1);
int c = ' ';
for(int p = pos-2;
p>=nPrevLinePos && isspace(c);
p--, c=SendEditor(SCI_GETCHARAT,p));
#2 (Char type variable definition section)
char space[1024];
memset(space,' ',1024);
space[nIndent] = 0;
SendEditor(SCI_REPLACESEL, 0, (sptr_t)space);
Posts: 1,031
Threads: 246
Joined: Jul 2022
04-04-2023, 09:50 PM
(This post was last modified: 04-05-2023, 11:37 PM by Davider.)
About For statement
I still haven't converted successfully. I found some sample code below
;QM
for i 0 5
,code
;C++, C#
for(i=0; i<5; i++)
{
,code
}
________________________________
;QM
rep 5
,code
;C++, C#
for(int i=0; i<5; i++)
{
,code
}
Posts: 1,031
Threads: 246
Joined: Jul 2022
Result of using ChatGPT conversion: It's all wrong
#1
int pos = SendEditor(SCI_GETCURRENTPOS);
int nPrevLinePos = SendEditor(SCI_POSITIONFROMLINE, line-1);
int c = ' ';
for (int p = pos - 2; p >= nPrevLinePos && isspace(c); p--) {
c = SendEditor(SCI_GETCHARAT, p);
}
#2
str space="";
for (int i=0; i<nIndent; i++) {
space+=" ";
}
SendMessage(sci, SCI_REPLACESEL, 0, &space);