froginfo Posted March 16, 2012 Share Posted March 16, 2012 Hi all,I am new to programming and now starting with AutoIt.I have the following script which is expected to parse dumped PCI inforamtion into 2 different array.To dump the PCI configuration space, I create a 30x4096 array, which should have sufficient space.But everytime I try to parse the dumped file, I get a error message saying:"Array variable has incorrect number of subscripts or subscript dimension range exceeded." at line #54Would anyone suggest anything I can check or did I do anything wrong in the code?I also attach the file I am dealing with as a reference.Any advice is much apprecaited.expandcollapse popup#include <sendmessage.au3> #include <file.au3> #Include <Array.au3> #Include <String.au3> #Include <Date.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #region Data Parser Global $file_handle,$PCI_Device_status,$PCI_Device,$PCI_Device_data,$PCI_Device_data[30][10],$PCI_Config_Raw[30][4100],$index_value $file_handle = FileOpenDialog("Data Source","D:\1_Projects\DEVCON_PCI_scan_test","") _FileReadToArray($file_handle,$PCI_Device_status) for $i = 1 To $PCI_Device_status[0] Select Case StringInStr($PCI_Device_status[$i],"Type") ; Bus Device Function $PCI_Device = $PCI_Device + 1 $Type = _StringBetween($PCI_Device_status[$i],"Type:","Bus") $Bus = _StringBetween($PCI_Device_status[$i],"Bus","Device") $Device = _StringBetween($PCI_Device_status[$i],"Device","Function") $Function = _StringBetween($PCI_Device_status[$i],"Function","") $PCI_Device_data[$PCI_Device][2] = $Bus[0] $PCI_Device_data[$PCI_Device][3] = $Device[0] $PCI_Device_data[$PCI_Device][4] = $Function[0] MsgBox(0,"test entry",$PCI_Device) Case StringInStr($PCI_Device_status[$i],";Bus") ; Device Name $Name = _StringBetween($PCI_Device_status[$i],"-","") $PCI_Device_data[$PCI_Device][0] = $Name[0] Case StringInStr($PCI_Device_status[$i],";Device/Vendor ID") ; Vendor ID Device ID $VID = _StringBetween($PCI_Device_status[$i],"0x","") $PCI_Device_data[$PCI_Device][5] = StringRight($VID[0],4) $PCI_Device_data[$PCI_Device][6] = StringLeft($VID[0],4) Case StringInStr($PCI_Device_status[$i],";Interrupt Pin") ; Interrupt Pin $PCI_Device_data[$PCI_Device][7] = StringRight($PCI_Device_status[$i],4) Case StringInStr($PCI_Device_status[$i],";Interrupt Line") ; Interrupt Line $PCI_Device_data[$PCI_Device][8] = StringRight($PCI_Device_status[$i],5) Case StringInStr($PCI_Device_status[$i],";Subsystem ID") ; SSID $SSID = _StringBetween($PCI_Device_status[$i],"0x","") $PCI_Device_data[$PCI_Device][9] = $SSID Case StringInStr($PCI_Device_status[$i],"=") ;or StringInStr($PCI_Device_status[$i],"0000="); RAW Config Space $line = _StringExplode($PCI_Device_status[$i]," ") For $x = 0 to 7 $index_value = _StringExplode($line[$x],"=");$index_value[0] = index, [1]=value $index = $index_value[0] $value = $index_value[1] $PCI_Config_Raw[$PCI_Device][Dec($index)] = $value Next EndSelect Next MsgBox(0,"Device Number", $PCI_Device & " PCI/ PCIe Devices detected") _ArrayDisplay($PCI_Device_data) _ArrayDisplay($PCI_Config_Raw)Dump_PCIdata.zip Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 16, 2012 Moderators Share Posted March 16, 2012 froginfo,When I run your script on your data, it fails at the line ";Codec Address = 0" which of course does not give the correct results when you _StringExplode it twice. You need to do some more errorchecking before you assign the return from the exploded line to $PCI_Config_Raw. Top Tip: Check the content of the data you are manipulating to make sure that it actually what you think it is. it took me a single run of the script to find that problem. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
froginfo Posted March 16, 2012 Author Share Posted March 16, 2012 @M23,Thanks a lot, the advice is great helpful.I add "Case StringInStr($PCI_Device_status[$i],"=",0,6)" to ensure capturing the correct line.I think I lack the ability to trace the code so I didn't notice the failure is actually at line ";Codec Address = 0".Will work on this.Thanks again~ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 16, 2012 Moderators Share Posted March 16, 2012 froginfo,I lack the ability to trace the codeAll I did was to use ConsoleWrite to show the line being worked on. I debug using a combination of the following:- ConsoleWrite (which does not pause the script)- _ArrayDisplay and MsgBox (which do pause it)- #AutoIt3Wrapper_Run_Debug_Mode (which actually shows the lines being run in the SciTE console) - for this you need the full SciTE4AutoIt3 download. You can turn this on and off so you only get the lines of interest shown.There is also a graphical debugger in the Examples section but I have never used it. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now