﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
3722	StdoutRead example is incorrectly parsing input and outputs incomplete information	anonymous	Jos	"The current example of StdoutRead is parsing the input of the Run-command wrong.
It's this block in particular.
{{{
; Use StringSplit to split the output of StdoutRead to an array. All carriage returns (@CRLF) are stripped and @CRLF (line feed) is used as the delimiter.
Local $aArray = StringSplit(StringTrimRight(StringStripCR($sOutput), StringLen(@CRLF)), @CRLF)
}}}

The comment is wrong too. All carriage returns are stripped but carriage returns are @CRs not @CRLFs.
@CRLF (line feed) is also wrong.

If you break up the commands line by line it looks like this:
{{{
Local $sStrippedCR = StringStripCR($sOutput)

Local $sTrimmed = StringTrimRight($sStrippedCR, StringLen(@CRLF))

Local $aArray = StringSplit($sTrimmed, @CRLF)
}}}

What happens?

L 1: All @CRs are removed from the string
L 2: 2 characters are removed from the right side of the string although only @LFs are left therefore resulting in cutting away one character from the last array entry (which gets created now)
L 3: Split the array with @CRLF. Since no third parameter is provided $STR_CHRSPLIT is provided which results in a still-decently-split array.

The error probably wasn't noticed due to $STR_CHRSPLIT still splitting the array (with @CR and @LF) and the very last character missing of the array entry which you only see if you pay attention.

I don't know who came up with the wrong line but he must have been on drugs or something.
Windows (AutoIt doesn't run natively on other operating systems) uses @CRLF by standard and we are parsing from a windows command anyway.
Instead of complicating the whole operation with StringStripCR we could've made it so much easier:

How to fix?
{{{
Local $aArray = StringSplit(StringTrimRight($sOutput, StringLen(@CRLF)), @CRLF, $STR_ENTIRESPLIT)
}}}"	Bug	closed	3.3.15.1	Documentation	3.3.14.2	None	Fixed	StdoutRead	
