AutoV2Script > ChangeOrSuggest V2 code for V1 script Topic is solved

Discuss the future of the AutoHotkey language
ahklearner
Posts: 309
Joined: 23 Jan 2015, 01:49

AutoV2Script > ChangeOrSuggest V2 code for V1 script

31 Jul 2019, 08:05

Hi Community :wave:

I would like to suggest a script which can read a v1 script and suggest/make syntax changes in accordance with v2.

For example:
var = abc
to
var := "abc"

Thanks in advance for your help and support.
guest3456
Posts: 2676
Joined: 09 Oct 2013, 10:31

Re: AutoV2Script > ChangeOrSuggest V2 code for V1 script  Topic is solved

31 Jul 2019, 09:28

I spent a lot of time working on something like this a few years ago:

https://www.autohotkey.com/boards/viewtopic.php?f=6&t=25100

I haven't kept it up to date with the latest v2 changes. Last I remember, I wanted to change all of the commands into functions, I think after lexikos made the change where even the command syntax stopped taking literal text params and instead required expression params anyway. I think its only up to date as of the alpha 076 build, which is pretty old, I think we're at alpha 103 now. Maybe I'll try to update it again

ahklearner
Posts: 309
Joined: 23 Jan 2015, 01:49

Re: AutoV2Script > ChangeOrSuggest V2 code for V1 script

31 Jul 2019, 10:19

@guest3456 thanks a lot for your time and efforts, please try to update this script time to time, it will be a Big relief for all :)
just me
Posts: 6525
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: AutoV2Script > ChangeOrSuggest V2 code for V1 script

01 Aug 2019, 04:42

Hi ahklearner,

Code: Select all

var := "abc"
is valid v1 code. So you can change and test your scripts using v1. Some replacements per day and this part will be done, if you want to change to v2 one day.
User avatar
nnnik
Posts: 4276
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: AutoV2Script > ChangeOrSuggest V2 code for V1 script

01 Aug 2019, 05:19

There wont be a script available that automatically converts all v1 into v2 code. Some of it is already avilable but I wouldnt use automatic conversion.
Recommends AHK Studio
SOTE
Posts: 789
Joined: 15 Jun 2015, 06:21

Re: AutoV2Script > ChangeOrSuggest V2 code for V1 script

01 Aug 2019, 07:15

I don't think a 100% accurate "Auto V1 to V2 Conversion" script is necessary. If the script can simply analyze a V1 script and suggest changes to be V2 compatible, it would probably be highly useful. That would be like the 1st step. Then an actual conversion script (with some decent accuracy) would be like the 2nd step. The user could then choose which step, if they want to proceed with the "auto conversion" 2nd step or make the changes manually.
guest3456
Posts: 2676
Joined: 09 Oct 2013, 10:31

Re: AutoV2Script > ChangeOrSuggest V2 code for V1 script

01 Aug 2019, 07:39

SOTE wrote:
01 Aug 2019, 07:15
I don't think a 100% accurate "Auto V1 to V2 Conversion" script is necessary.
Its not whether its necessary, its just not POSSIBLE. Some changes are bigger than just syntax changes. There are functionality changes, which require users to consider design changes.
SOTE wrote:
01 Aug 2019, 07:15
If the script can simply analyze a V1 script and suggest changes to be V2 compatible, it would probably be highly useful. That would be like the 1st step. Then an actual conversion script (with some decent accuracy) would be like the 2nd step. The user could then choose which step, if they want to proceed with the "auto conversion" 2nd step or make the changes manually.
This is pretty much what that script above does. It converts with decent accuracy, for the bigger changes, and leaves some placeholders for the user to investigate further. It is a VERY tedious process to upgrade a larger script from v1 to v2, and a quick script converter is extremely convenient to get some of the more repetitive changes out of the way.

User avatar
nnnik
Posts: 4276
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: AutoV2Script > ChangeOrSuggest V2 code for V1 script

01 Aug 2019, 08:22

For the most part the real difficulty of converting comes from advanced changes that require you to analyze and change your script to adapt it.
The rest is just simple search and replace.
You can make a script to automate that, but its usefulness will be highly limited.
Recommends AHK Studio
guest3456
Posts: 2676
Joined: 09 Oct 2013, 10:31

Re: AutoV2Script > ChangeOrSuggest V2 code for V1 script

01 Aug 2019, 08:32

nnnik wrote:
01 Aug 2019, 08:22
For the most part the real difficulty of converting comes from advanced changes that require you to analyze and change your script to adapt it.
Yes, that's the real difficulty.
nnnik wrote:
01 Aug 2019, 08:22
The rest is just simple search and replace.
Its not a simple search and replace.

ahklearner
Posts: 309
Joined: 23 Jan 2015, 01:49

Re: AutoV2Script > ChangeOrSuggest V2 code for V1 script

01 Aug 2019, 11:22

I am greatly an AHK dependent, and I am from a non-programming background, more than writing code I do analyze codes written by others and learn from them doing small changes.

Till date, all of our codes are written in v1, if I need to test, learn, and analyze these scripts >>> I cant change codes manually all the time :( if something can be automated, we should, it would be a great help, please think of all the guys like me and future learners like me for whom AHK is or might be a breadwinner.
User avatar
nnnik
Posts: 4276
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: AutoV2Script > ChangeOrSuggest V2 code for V1 script

01 Aug 2019, 14:42

Yeah the thing is that automating the easy bits doesnt help you a lot.
If you can do the easy bits yourself you can also automate them to some degree.
If you cant do the easy bits you wont be able to do the hard bits either.
Im pretty sure that multiple people will try to make something like this but I also believe that the language currently is not stable enough to start planning and moving towards automating it.
guests script seems like a start. jeeswg also tried to make something but I didnt follow the progress.

The language keeps changing every other week.
If you really use scripts like you say you do then you should stick with v1 for now.
Recommends AHK Studio
iseahound
Posts: 465
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: AutoV2Script > ChangeOrSuggest V2 code for V1 script

01 Aug 2019, 14:57

There's definitely a usage for a v1 to v2 common library, something like

Code: Select all

Gui(command, p*) {
    if (command = "new")
       return GuiCreate(p*)
}
to map Gui New to GuiCreate()
User avatar
nnnik
Posts: 4276
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: AutoV2Script > ChangeOrSuggest V2 code for V1 script

01 Aug 2019, 17:49

It would be better to make the v2 gui object available in v1.
Recommends AHK Studio
User avatar
jeeswg
Posts: 6829
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AutoV2Script > ChangeOrSuggest V2 code for V1 script

01 Aug 2019, 17:54

I backported the AHK v2 Gui object, I'll try and upload it when I can. Plus my updated converter, and function backport library ...

Btw I'm a bit surprised about the doom and gloom re. conversion. From my experience, you can automate almost everything, and I've already completed all of my conversion tasks. StringSplit to StrSplit would need to be done manually (but you can use a Loop Parse workaround). VarSetCapacity to BufferAlloc would need to be done manually (you could just not do it though). So ... what specifically is so difficult to convert, that must be done manually?

OK, GUIs need to be done manually, although I expedited this with hotkeys to convert individual lines.

Link:
AHK v1 to AHK v2 conversion tips/changes summary - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=36787
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
nnnik
Posts: 4276
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: AutoV2Script > ChangeOrSuggest V2 code for V1 script

01 Aug 2019, 18:03

Everything that uses objects.
Functions that previously had a wrong amount of parameters when getting called or when calling them - now always causes errors.
Read the changelog for more info.
Recommends AHK Studio
User avatar
jeeswg
Posts: 6829
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AutoV2Script > ChangeOrSuggest V2 code for V1 script

01 Aug 2019, 18:39

The new object behaviour isn't determined yet.
There could be an option added to suppress the parameter count warning.
It depends on how AHK v2 anticipates and deals with these problems, we don't know yet.
Anything else?
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
ahklearner
Posts: 309
Joined: 23 Jan 2015, 01:49

Re: AutoV2Script > ChangeOrSuggest V2 code for V1 script

02 Aug 2019, 08:07

jeeswg wrote:
01 Aug 2019, 17:54
I backported the AHK v2 Gui object, I'll try and upload it when I can. Plus my updated converter, and function backport library ...
Thanks a lot, much delighted :)
bourdin07
Posts: 15
Joined: 23 Jun 2019, 12:57

Re: AutoV2Script > ChangeOrSuggest V2 code for V1 script

27 Sep 2019, 09:35

nnnik wrote:
01 Aug 2019, 17:49
It would be better to make the v2 gui object available in v1.
I'm totally agree

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: No registered users and 8 guests