mmikeww / AHK-v2-script-converter

AHK v1 -> v2 script converter
https://autohotkey.com/boards/viewtopic.php?f=6&t=25100
The Unlicense
551 stars 43 forks source link

Assignment line not translated well when using double quotes #111

Closed parlevjo2 closed 7 months ago

parlevjo2 commented 1 year ago

This v1 line

Clipboard := "Powershell -command ""Get-CimInstance -ClassName win32_operatingsystem | Select-Object CSName, LastBootUpTime | FT -Autosize""" is translated to v2 line A_Clipboard := "Powershell -command ""Get-CimInstance -ClassName win32_operatingsystem | Select-Object CSName, LastBootUpTime | FT -Autosize""" Must be using escaped quote otherwise it gives an autohotkey error A_Clipboard := "Powershell -command"Get-CimInstance -ClassName win32_operatingsystem | Select-Object CSName, LastBootUpTime | FT -Autosize""

Banaanae commented 7 months ago

working on this here

Banaanae commented 7 months ago

So currently, I have this regex with matches only strings in an assignment and this code which doesn't fully work

      else if RegexMatch(Line, "i)^([\s]*[a-z_][a-z_0-9]*[\s]*:=\s*)(.*)", &Equation) ; Line is a variable assignment, check for ""
      { ; Replace "" with `", see #111
         Line := Equation[1]
         pos := RegExMatch(Equation[2], "`"((?:`"`")?(?:[^`"]*(?:`"`")?[^`"]*?)*?(?:`"`")?)`"", &match) ; https://regex101.com/r/RMoJ06/2
         if pos != 0
            Line .= "`"" RegExReplace(match[1], "`"`"", "```"") "`""
      }

So it still doesn't add in variables or other strings if multiple