Page 1 of 1

Add the with keyword

PostPosted: Sat Mar 18, 2017 7:56 am
by kyjdp
I hope that QM in the future version, can be better compatible with VBA syntax, such as add with keywords

E.g;

VBA:(Find replacement of define content)

With Selection.Find
.ClearFormatting
.Text = "hi"
.Replacement.ClearFormatting
.Replacement.Text = "hello"
.Execute Replace:=wdReplaceAll, Forward:=True, _
Wrap:=wdFindContinue
End With

QM:

Macro Macro4     ?
;/exe 1

typelib Word {00020905-0000-0000-C000-000000000046} 8.0
Word.Application app._getactive
app.Selection.Find.ClearFormatting()
app.Selection.Find.Text = "hi"
app.Selection.Find.Replacement.ClearFormatting()
app.Selection.Find.Replacement.Text = "hello"
VARIANT vForward=1
VARIANT vWrap=Word.wdFindContinue
VARIANT vReplaceAll=Word.wdReplaceAll
app.Selection.Find.Execute(@ @ @ @ @ @ vForward vWrap @ @ vReplaceAll)
app.ActiveDocument.Save


change to: :idea:

Macro Macro4     ?
;/exe 1

typelib Word {00020905-0000-0000-C000-000000000046} 8.0
Word.Application app._getactive
With app.Selection.Find
,ClearFormatting()
,Text = "hi"
,With Replacement
,,ClearFormatting()
,,Text = "hello"
VARIANT vForward=1
VARIANT vWrap=Word.wdFindContinue
VARIANT vReplaceAll=Word.wdReplaceAll
app.Selection.Find.Execute(@ @ @ @ @ @ vForward vWrap @ @ vReplaceAll)
app.ActiveDocument.Save

Re: Add the with keyword

PostPosted: Sat Mar 18, 2017 8:06 am
by Gintaras
Nothing new will be added to the QM2 language. QM3 will use C# instead. C# does not support 'with', except when creating new object with 'new'.

Re: Add the with keyword

PostPosted: Sat Mar 18, 2017 8:10 am
by kyjdp
I hope that the future version of QM3, VBA support, more easy to understand :D

Re: Add the with keyword

PostPosted: Sat Mar 18, 2017 8:20 am
by kyjdp
like this? :P

Code: Select all
User u = new User()
{
   ID = 123456,
   Name = "test",
   Password = "test"
};

Warning: The code possibly is invalid because some important characters (tabs, spaces) disappeared. Read more.


or:
using abc = a.b.c.d;
abc.xxx = "xxx";
abc.yyy();

Re: Add the with keyword

PostPosted: Sat Mar 18, 2017 8:23 am
by Gintaras
yes

Re: Add the with keyword

PostPosted: Sat Mar 18, 2017 8:24 am
by kyjdp
I google search for the code, in fact, I do not understand C #, only understand point VBA :D

Re: Add the with keyword

PostPosted: Sat Mar 18, 2017 10:18 am
by kyjdp
Just found the AHK code, I hope QM developers also learn from the AHK syntax advantage, in the future version to improve the QM :idea:

Four lines of code, control word, the syntax is very simple

AHK Code:

Word := ComObjCreate("Word.Application")
Doc := Word.Documents.Add
Doc.SaveAs("C:\test.doc")
Word.Quit

Re: Add the with keyword

PostPosted: Sat Mar 18, 2017 10:29 am
by kyjdp
QM Code :
Use the following code to run unsuccessfully :shock:

Macro Run Word, open file     ?
typelib Word {00020905-0000-0000-C000-000000000046} 8.0
Word.Application app._create
Word.Documents doc=app.Documents.Add
doc.SaveAs("C:\test.doc")
app.Quit