Skip to content

Instantly share code, notes, and snippets.

@davebrny
Last active February 18, 2019 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davebrny/f7cbde0d89a5c99cec554e46ba94db11 to your computer and use it in GitHub Desktop.
Save davebrny/f7cbde0d89a5c99cec554e46ba94db11 to your computer and use it in GitHub Desktop.
(autohotkey) - get the parameters that have been passed to the script
passed() {
global 0
loop, %0%
params .= (params ? a_space : "") . %a_index%
return params
}
/*
[script info]
description = get the parameters that have been passed to the script
*/
@davebrny
Copy link
Author

@davebrny
Copy link
Author

davebrny commented Nov 28, 2017

loop, %0%
    params .= (params ? a_space : "") . %a_index%

expanded example:

number_of_parameters = %0%      ; get the number of parameters that have been passed to the script
loop, % number_of_parameters    ; loop that many times
    {
    this_loop_number = %a_index%      ; 1, 2, 3 etc
    value_in := %this_loop_number%    ; get the value stored in this loop number, %1% %2% %3%

    if (parameters != "")             ; if the variable already contains a parameter(s)
         space_before := a_space      ; then add a space between
    else space_before := ""           ; else its the first parameter so no space is needed

    parameters .= space_before . value_in    ; append to current parameters .=
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment