AHK v1 → AHK v2 Topic is solved

Discuss the future of the AutoHotkey language
xuezhe
Posts: 87
Joined: 06 Jan 2016, 11:02

AHK v1 → AHK v2

11 Dec 2017, 00:55

who can help me to change it to v2 .thx.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


https://github.com/Jim-VxE/AHK-Lib-JSON_ToObj
xuezhe
Posts: 87
Joined: 06 Jan 2016, 11:02

Re: AHK v1 → AHK v2

11 Dec 2017, 01:11

guest3456 wrote:this should help:
https://autohotkey.com/v2/v2-changes.htm

I have try to change it ,but error happens when runing the code after changing.
guest3456
Posts: 2298
Joined: 09 Oct 2013, 10:31

Re: AHK v1 → AHK v2

11 Dec 2017, 01:16

xuezhe wrote:I have try to change it ,but error happens when runing the code after changing.


so post your changes, and also post what error you get, and maybe someone can help you

User avatar
jeeswg
Posts: 4273
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AHK v1 → AHK v2

11 Dec 2017, 01:23

Issues I noticed with the script:
"""" -> "`"" or Chr(34)
is Number -> is "Number" (or use: Number := "Number", prior to: is Number)
StringReplace -> StrReplace
StringGetPos -> InStr
StringMid -> SubStr
'% ' -> remove '% ' from (the start of parameters in) Loop lines
`, -> ,

Link:
AHK v1 to AHK v2 conversion tips/changes summary - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=36787

Btw I hear that Coco's JSON library is quite good, and I have used it myself and like it.
xuezhe
Posts: 87
Joined: 06 Jan 2016, 11:02

Re: AHK v1 → AHK v2

11 Dec 2017, 01:27

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

xuezhe
Posts: 87
Joined: 06 Jan 2016, 11:02

Re: AHK v1 → AHK v2

11 Dec 2017, 01:37

jeeswg wrote:Issues I noticed with the script:
"""" -> "`"" or Chr(34)
is Number -> is "Number" (or use: Number := "Number", prior to: is Number)
StringReplace -> StrReplace
StringGetPos -> InStr
StringMid -> SubStr
'% ' -> remove '% ' from (the start of parameters in) Loop lines
`, -> ,

Link:
AHK v1 to AHK v2 conversion tips/changes summary - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=36787

Coco's JSON doesn't support ahk v2 ?
User avatar
jeeswg
Posts: 4273
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AHK v1 → AHK v2

11 Dec 2017, 01:39

What do the error messages say?
Or does the script run, but not as intended?
You may need to replace key with key.0, because RegExMatch returns objects in AHK v2.

I don't know if Coco's script supports AHK v2, or not, however, if you're going to make the effort to convert a script to AHK v2, it's worth considering which script you're going to convert.
xuezhe
Posts: 87
Joined: 06 Jan 2016, 11:02

Re: AHK v1 → AHK v2

11 Dec 2017, 04:25

jeeswg wrote:What do the error messages say?
Or does the script run, but not as intended?
You may need to replace key with key.0, because RegExMatch returns objects in AHK v2.

I don't know if Coco's script supports AHK v2, or not, however, if you're going to make the effort to convert a script to AHK v2, it's worth considering which script you're going to convert.

now I use the coco's script.it also works well in ahk v1,but error happens in ahk v2.
https://autohotkey.com/boards/viewtopic ... 67&t=41223
User avatar
jeeswg
Posts: 4273
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AHK v1 → AHK v2

11 Dec 2017, 04:55

Anyway, maybe the VxE script has advantages over the Coco script, I'm not sure. Anyhow, if you still want to convert the VxE script, do post any problems on this thread, and I'll try to help.

Btw you could change the titles of both threads to something like:
AHK v1 → AHK v2: VxE's JSON script
AHK v1 → AHK v2: Coco's JSON script

These are classic scripts that people will be curious about, i.e. whether they have been converted to AHK v2. And so, giving a thread an easy to find/remember title, will help people searching for information.
Last edited by jeeswg on 11 Dec 2017, 12:53, edited 1 time in total.
SirRFI
Posts: 367
Joined: 25 Nov 2015, 16:52

Re: AHK v1 → AHK v2  Topic is solved

11 Dec 2017, 12:38

Actually I updated Coco's library to v2.0-a081-cad307c as I needed it for private project. I mostly used the JXON one though.
I also suggested to add JSON support to AHK2 itself: https://autohotkey.com/boards/viewtopic ... 37&t=39309



JSON:

Code: [Select all] [Expand] [Download] (JSON.ahk2)GeSHi © Codebox Plus



JXON:

Code: [Select all] [Expand] [Download] (JXON.ahk2)GeSHi © Codebox Plus

Use [code=autohotkey] forum tag to share your code.
Click on (Accept this answer) on top-right part of the post if it has answered your question / solved your problem.
xuezhe
Posts: 87
Joined: 06 Jan 2016, 11:02

Re: AHK v1 → AHK v2

12 Dec 2017, 01:40

SirRFI wrote:Actually I updated Coco's library to v2.0-a081-cad307c as I needed it for private project. I mostly used the JXON one though.
I also suggested to add JSON support to AHK2 itself: https://autohotkey.com/boards/viewtopic ... 37&t=39309



JSON:

Code: [Select all] [Expand] [Download] (JSON.ahk2)GeSHi © Codebox Plus



thx very much.
but it doesn't support chinese(中文)
Msgbox show the following:
{"date":"2017.12.1","sites":[{"name":"\u767E\u5EA6","site":"www.baidu.com"},{"name":"\u8C37\u6B4C","site":"www.google.com"}]}
the fact is the following:
{"date":"2017.12.1","sites":[{"name":"百度","site":"www.baidu.com"},{"name":"谷歌","site":"www.google.com"}]}
User avatar
hoppfrosch
Posts: 314
Joined: 07 Oct 2013, 04:05
GitHub: hoppfrosch
Location: Rhine-Maine-Area, Hesse, Germany
Contact:

Re: AHK v1 → AHK v2

12 Dec 2017, 02:07

As you might not have seen: Coco himself already started porting to AHK2 - but did not continue his work to the latest AHK V2 version. He seemed to deprecate JXON.ahk.

I updated Coco's work to be compatible with currently latest AHK v2.0-a081 recently. I also made a pull request for my changes
User avatar
nnnik
Posts: 2789
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: AHK v1 → AHK v2

12 Dec 2017, 04:30

xuezhe wrote:thx very much.
but it doesn't support chinese(中文)
Msgbox show the following:
{"date":"2017.12.1","sites":[{"name":"\u767E\u5EA6","site":"www.baidu.com"},{"name":"\u8C37\u6B4C","site":"www.google.com"}]}
the fact is the following:
{"date":"2017.12.1","sites":[{"name":"百度","site":"www.baidu.com"},{"name":"谷歌","site":"www.google.com"}]}

http://json.org/
Recommends AHK Studio

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: No registered users and 1 guest