Sign in to follow this  
Followers 0
Amathian

Receiving a Weird Array Error

7 posts in this topic

#1 ·  Posted (edited)

I can't figure out why this is happening!  Any ideas or help?

Thanks!  Here's the code:

**As a note, I did some testing and saw that the section names are printing correctly (inireadsectionnames) but the i am either having problems with inireadsection or when i write to the console.  

** As another note .. the first section can read (in the inireadsection is it [1][0] and [1][1]) but once I hit the second section [2][0] and [2][1], this is where I have an error.

Oh. and the error I am receiving is :Array variable has incorrect number of subscripts or subscript dimension range exceeded

func Assessment()
   local $c = 0, $s, $q, $cn, $cf=1
   while $c <> 156
      $c = $c + 1
      $cn = IniReadSectionNames ("hipaa.ini")
      ConsoleWrite ($cn[$cf])
      $q = inireadsection ("hipaa.ini", $cn[$cf])
      consolewrite ($q[2][0] & $q[2][1])
      $cf = $cf + 1
   wend
EndFunc
Edited by Amathian

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If your error is your keyboard exploding and your keys are getting stuck in your brain. It is because you made the hamster god angry.

If you want a better answer your would be better off not making people you want to help you play guessing games.

But when using arrays, makes sure to use "if isarray" and use _arraydisplay to check if its contents are what you expect.

Edited by DicatoroftheUSA

Share this post


Link to post
Share on other sites

If your error is your keyboard exploding and your keys are getting stuck in your brain. It is because you made the hamster god angry.

If you want a better answer your would be better off not making people you want to help you play guessing games.

But when using arrays, makes sure to use "if isarray" and use _arraydisplay to check if its contents are what you expect.

Sorry. I edited it probably while you were looking t the page (I need sleep:P)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Tried it, worked successfully.

From this I learned that the array itself won't work.

Here is the updated code after testing and such

func Assessment()
   local $c = 0, $s, $q, $cn, $cf=1, $i
   while $c <> 156
      $c=$c+1
      $cn=IniReadSectionNames ("hipaa.ini")
      $q=IniReadSection ("hipaa.ini", $cn[$cf])
      ConsoleWrite($q[$cf][0] & $q[$cf][1])
      $cf =$cf+1
   WEnd
EndFunc 

And here is the error I'm receiving:

 

§164.308(a)(1)(i)Does your practice develop, document, and implement policies and procedures for assessing and managing risk to its ePHI?"C:UsersAdamDocumentstoolraw.au3" (28) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

ConsoleWrite($q[$cf][0] & $q[$cf][1])
ConsoleWrite(^ ERROR

 

From the tests you recommended and I ran, the problem is within the command:

ConsoleWrite($q[$cf][0] & $q[$cf][1])

The "inireadsectionnames" reads everything fine, the "inireadsection" reads everything fine. but when the array goes from [1][0] to [2][0] is where I receive the errors.  I also used a for loop in place of the while loop and everything worked just fine.  The problem is in that command for some reason ONLY when I use a while loop.  I would just use a for loops but it's not optimal for the project I want to do.  Any suggestions?

Edited by Amathian

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Amathian,

Using Iniread Section means that $q has 2 dimensions (0 & 1) so increasing $cf to more than 1 is what is causing the error.

However, a closer look at your code leaves me struggling to understand what you are trying to do by continually increasing $cf. Perhaps if you explained the purpose of the code we might be able to offer you some help - at present doing so is difficult.

M23

Edited by Melba23
Clarification (I hope)

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

Share this post


Link to post
Share on other sites

What is the 156 constant and why on Earth do you read the section names 156 times?

Then is it correct that you want to display the first key and the first value in the first section, then the second pair key/value in the second section, then the third pair in the third section, and so on?

(I guess no).


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
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
Sign in to follow this  
Followers 0