First of all, StrSplit results in an
Array, not an PseudoArray (compare docs). You are actually accessing the array with object syntax (an array is an object)
In the second example, you are suffering syntax problems - you are defining
inputString as a string including the
"s. You can check with
msgbox % inputstring
Either do
inputString = foo bar baz instead ("legacy" method for backwards compatibility with older AHK versions), or, better
inputString := "foo bar baz"
(notice the
: ) - then you will put the string
foo bar baz as contents of the variable.
The latter ("expression") syntax is the preferred method for variable assigments and rather future-proof for AHK v2, afaik. See
https://autohotkey.com/docs/Variables.htm
That said, you are missing the syntax of
StringSplit:
Delimiters contains one or more characters (case sensitive), each of which is used to determine where the boundaries between substrings occur in InputVar. Since the delimiter characters are not considered to be part of the substrings themselves, they are never copied into OutputArray.
Thus, you are taking
literal " and
space as delimiters ( which will be excluded from the resulting strings).
Instead do this: For a
space character, better use the built-in AHK variable
A_space:
Code: Select all
inputString := "foo bar baz"
msgbox % inputstring
stringSplit, pseudoArray, inputString, %A_Space%
firstItem = %pseudoArray1%
; firstItem = %pseudoArray2%
msgBox, %firstItem%