Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect quoting of parameters #6

Open
Lexikos opened this issue Jun 21, 2021 · 5 comments
Open

Incorrect quoting of parameters #6

Lexikos opened this issue Jun 21, 2021 · 5 comments

Comments

@Lexikos
Copy link

Lexikos commented Jun 21, 2021

Loop Read, % filename  ; old
Loop "Read", filename  ; new (incorrect)
Loop Read, filename  ; correct

FileRead html, % filename  ; old
FileRead "html", filename  ; new (incorrect)
html := FileRead(filename)  ; correct

Sleep, m_Interval  ; old
Sleep "m_Interval"  ; new (incorrect)
Sleep m_Interval  ; correct

For identifying which command parameters accept expressions by default, you may refer to g_act. For example:

	, {_T("ControlMove"), 0, 9, 9, {2, 3, 4, 5, 0}}

This indicates the 2nd, 3rd, 4th and 5th parameter are expressions, with 0 just terminating the list.

For identifying which parameters are output variables, you may refer to ArgIsVar. The "heuristic" for translating output vars is described in v2-changes:

If the command's first parameter is an output variable and the second parameter is not, it becomes the return value and is removed from the parameter list.
The remaining output variables are handled like ByRef parameters (for which usage and syntax has changed), except that they permit references to writable built-in variables.

@FuPeiJiang
Copy link
Owner

currently, I see no difference between output variable and expression, I parse them the same


some pseudocode (for me)

const commandParamInfo={'controlmove':[9,{2:true, 3:true, 4:true, 5:true}]}
const [howManyParams,v2ParamObj] = commandParamInfo[lowerValidName]

//loop howManyParams
for (let whichParam = 1; whichParam <= howManyParams; whichParam++) {
  if v2ParamObj[whichParam] {
    //v2Expression
  } else {
    //v1Expression
    if (whichParam === howManyParams) {
      //literal comma = true
    }
  }
}

is there a c++ parser ? :) so I can extract paramInfo from g_act, that'd be crazy, I'll just use regex

@Lexikos
Copy link
Author

Lexikos commented Jul 11, 2021

currently, I see no difference between output variable and expression, I parse them the same

Output variable parameters are basically a subset of the expression syntax, but output variables do not survive the transition from v1 to v2 without change. Some output variables become the return value, and the rest (for recent v2 alphas) need the & reference operator added.

@FuPeiJiang
Copy link
Owner

@Lexikos, thank you for ArgIsVar

If the command's first parameter is an output variable and the second parameter is not, it becomes the return value and is removed from the parameter list.

I got all these, but for example ACT_ADD : ADD wasn't a command nor a function,
can you explain why ACT_ADD is in there ?

so I got all the filenames in https://github.com/Lexikos/AutoHotkey_L-Docs/tree/v2/docs/commands
and, I take what's in both lists

and this is what I got

getkeystate
controlgetfocus
controlgettext
statusbargettext
random
iniread
regread
fileread
filegetattrib
filegettime
filegetsize
filegetversion
wingettitle
wingetclass
wingettext
sysget
envget
formattime
sort
inputbox
pixelgetcolor

inputbox and pixelgetcolor can't be converted like this


I had to convert some ahk to ah2 and WinGetTitle wasn't implemented, now I'm doing the whole "command first param to func outputVar"

@Lexikos
Copy link
Author

Lexikos commented Jul 25, 2021

ACT_ADD corresponds to EnvAdd and Var += Value, TimeUnits.

@FuPeiJiang
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants