Hello,
A little background on what I'm trying to do. We have a webapp that runs off of XML docs. These XML docs are kicked out of a system to a network location so that they can be rendered into PDF docs for shipping purposes. Sometimes these XML docs contain special ASCII characters that cause the rending to not be possible. When this happens, we have to manually go into the haystack and find that needle and replace it with a similar character that is renderable.
What I'm trying to do is open selected XML files in a specific location, Read them to an array and convert them back to string so that I can remove all the "good" characters from the string and return the "bad" character as a result. Below is my code with associated error. Keep in mind that I'm only to the FileRead() part of this process, so the code is incomplete for the concept.
Error Message: One file selected
Error Message: More than one file selected
I've confirmed that the variable being passed to FileRead() contains a valid file path. Any ideas on why I'm getting these errors?
A little background on what I'm trying to do. We have a webapp that runs off of XML docs. These XML docs are kicked out of a system to a network location so that they can be rendered into PDF docs for shipping purposes. Sometimes these XML docs contain special ASCII characters that cause the rending to not be possible. When this happens, we have to manually go into the haystack and find that needle and replace it with a similar character that is renderable.
What I'm trying to do is open selected XML files in a specific location, Read them to an array and convert them back to string so that I can remove all the "good" characters from the string and return the "bad" character as a result. Below is my code with associated error. Keep in mind that I'm only to the FileRead() part of this process, so the code is incomplete for the concept.
[ autoit ]
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> Global $readFile[100] getXMLFiles() readXMLFiles() Func getXMLFiles() Global $file = FileOpenDialog( "Select AutoBOL File", @WorkingDir & "\", "XML Files (*.XML)", 1 + 2 + 4) Global $stringArray = StringSplit( $file, '|', 1) Global $size = UBound($stringArray) EndFunc Func readXMLFiles() If $size = 2 Then Global $fileToRead = FileOpen( $stringArray[1]) If $fileToRead = -1 Then MsgBox(0, "Error", "Unable to open file ") EndIf Global $readFile[1] = FileRead( $stringArray[1]) FileClose( $fileToOpen) Else For $i = 1 To $size Step 1 Global $fileToOpen = $stringArray[1] & "\" & $stringArray[$i + 1] Global $fileToRead = FileOpen( $fileToOpen) If $fileToRead = -1 Then MsgBox(0, "Error", "Unable to open file ") EndIf Global $readFile[$i] = FileRead( $fileToOpen) Next FileClose( $fileToOpen) EndIf EndFunc
Error Message: One file selected
H:\!Projects\Incomplete\A~.au3 (23) : ==> Missing subscript dimensions in "Dim" statement.: Global $readFile[1] = FileRead( $stringArray[1]) Global $readFile[1] = ^ ERROR >Exit code: 1 Time: 7.316
Error Message: More than one file selected
H:\!Projects\Incomplete\A~.au3 (34) : ==> Missing subscript dimensions in "Dim" statement.: Global $readFile[$i] = FileRead( $fileToOpen) Global $readFile[$i] = ^ ERROR >Exit code: 1 Time: 7.321
I've confirmed that the variable being passed to FileRead() contains a valid file path. Any ideas on why I'm getting these errors?