Sign in to follow this  
Followers 0
PcExpert

Need help with some sort of diary script

6 posts in this topic

Hi all,

I'm making a diary script. But when I try to add all the sections found in the specified ini to the listview i'm getting errors like

Digital Diary.au3 (28) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

For $r = 1 To $readdates[0][0]

For $r = 1 To ^ ERROR

This is my current code:

#include <GUIConstants.au3>
#Include <GuiListView.au3>

GUICreate("Digital Diary", 500, 400) ; will create a dialog box that when displayed is centered
$List = GUICtrlCreateList("", 5, 5, 150, 375)
$Edit = GUICtrlCreateEdit("", 170, 5, 325, 375)
GUISetState ()      ; will display an  dialog box with 2 button
; Run the GUI until the dialog is closed

$readdates = IniReadSectionNames("diary.ini")
If $readdates = @error Then
MsgBox(16, "Digital Diary", "Geen data gevonden.") 
Else
If IsArray($readdates) Then
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($List)) 
    For $r = 1 To $readdates[0][0]
        GUICtrlCreateListViewItem($readdates[$r][1], $List)
    Next
EndIf
EndIf


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
 EndSelect
Wend

Could somebody please help me out, I tried different things, like removing a '[0]' and such things, but no luck :). Thanks!

Share this post


Link to post
Share on other sites



Digital Diary.au3 (28) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

For $r = 1 To $readdates[0][0]

For $r = 1 To ^ ERROR

That error usually appears when the second value is less than the first. This means your "IniReadSectionNames" don't get any result. Try a msgbox with $readdates to make sure this is the problem.

Share this post


Link to post
Share on other sites

By editing the for loop to this:

For $r = 1 To $readdates[0]
        MsgBox(0, "", $readdates[$r])
  ;GUICtrlCreateListViewItem($readdates[$r], $List)
    Next

the MSGbox shows the right dates, but I cant manage to add them to the listview.

Share this post


Link to post
Share on other sites

Since my last post i've been trying to see if it helped to change values, but it didnt. I also tried to have a single '[0]' instead of a double. But still no luck.

Share this post


Link to post
Share on other sites

Hi all,

I'm making a diary script. But when I try to add all the sections found in the specified ini to the listview i'm getting errors like

This is my current code:

#include <GUIConstants.au3>
#Include <GuiListView.au3>

GUICreate("Digital Diary", 500, 400); will create a dialog box that when displayed is centered
$List = GUICtrlCreateList("", 5, 5, 150, 375)
$Edit = GUICtrlCreateEdit("", 170, 5, 325, 375)
GUISetState ()   ; will display an  dialog box with 2 button
; Run the GUI until the dialog is closed

$readdates = IniReadSectionNames("diary.ini")
If $readdates = @error Then
MsgBox(16, "Digital Diary", "Geen data gevonden.") 
Else
If IsArray($readdates) Then
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($List)) 
    For $r = 1 To $readdates[0][0]
        GUICtrlCreateListViewItem($readdates[$r][1], $List)
    Next
EndIf
EndIf

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
 EndSelect
Wend

Could somebody please help me out, I tried different things, like removing a '[0]' and such things, but no luck :P. Thanks!

Just fix your error handling and use the right array type:
$readdates = IniReadSectionNames("diary.ini"); returns section names in a 1D array
If @error Then
    MsgBox(16, "Digital Diary", "Geen data gevonden.")
Else
    If IsArray($readdates) Then
        _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($List))
        For $r = 1 To $readdates[0]
            GUICtrlCreateListViewItem($readdates[$r], $List)
        Next
    EndIf
EndIf

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

That error usually appears when the second value is less than the first. This means your "IniReadSectionNames" don't get any result. Try a msgbox with $readdates to make sure this is the problem.

That condition does not produce an error, it only stops any execution of the loop:
$x = 3
For $n = $x To 2
    MsgBox(16, "Failure", "This message never seen.")
Next
MsgBox(64, "Done", "Done")

Where you have arrays with the count in [0] (or [0][0] also), it is OK to use this:

For $n = 1 To $avArray[0]
    ; ...
Next

This will not give an error if $avArray[0] = 0, it will just not execute the loop.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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