Jump to content

Need help with some sort of diary script


Recommended Posts

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!

Link to comment
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.
Link to comment
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
Link to comment
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
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...