Jump to content

An error regarding Array variable has incorrect number of subscripts or subscript dimension range exceeded


Recommended Posts

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 #54

Would 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.

#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

  • Moderators

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. :bye:

You need to do some more errorchecking before you assign the return from the exploded line to $PCI_Config_Raw. :oops:

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. :doh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

@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

  • Moderators

froginfo,

I lack the ability to trace the code

All I did was to use ConsoleWrite to show the line being worked on. :bye:

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. :oops:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...