Jump to content

ListView questions


JAFN
 Share

Recommended Posts

If you don't compile the script does it still give you the same error messages? If so, run it and find where the errors are in the uncompiled script before you even think of compiling it. You'll be chasing your tail for weeks otherwise.

The line number changes and the error message is gibberish, compared to the script version that is just irrelevant and damn hard to read.

[size="2"]The second mouse gets the cheese[/size]
Link to comment
Share on other sites

How is the error message from the script version irrelevant? Does it give you an error message in the console when you run it? If so, what is the error message?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

How is the error message from the script version irrelevant? Does it give you an error message in the console when you run it? If so, what is the error message?

Line 1173 (name of my file) Note: this program has less than 300 lines

Local $vTMP,$L=$iStart

four more lines of code that isn't in my script.

Error: Array variable subscript badly formatted.

[size="2"]The second mouse gets the cheese[/size]
Link to comment
Share on other sites

No such luck. It is AutoIt Error Box. Much like Windows Error messages, you can't even select the text.

Thanks though.

You are not supposed to select any text, ctrl+c copies everything.
Link to comment
Share on other sites

Line 1173 (name of my file) Note: this program has less than 300 lines

Local $vTMP,$L=$iStart

four more lines of code that isn't in my script.

Error: Array variable subscript badly formatted.

Is this when running the SCRIPT from SciTE, or when you're running it after it's been compiled? Because the only way you're going to see line numbers that are not in your script in an error MsgBox is when it has been compiled. Otherwise, it might be displaying a line number from one of your includes. When you're running the script from SciTe or when you run it manually with the Autoit3.exe program, you should only see the line numbers that are in your script.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

You are not supposed to select any text, ctrl+c copies everything.

Live and learn:

Script error

---------------------------

AutoIt Error

---------------------------

Line 1174 (File "C:\Users\Judith\AutoItFiles\AutoIt3\Include\Array.au3"):

Local $vTmp, $L = $iStart, $R = $iEnd, $vPivot = $avArray[int(($iStart + $iEnd) / 2)][$iSubItem], $fNum = IsNumber($vPivot)

Local $vTmp, $L = $iStart, $R = $iEnd, $vPivot = $avArray[int(($iStart + $iEnd) / 2)][^ ERROR

Error: Array variable subscript badly formatted.

---------------------------

OK

---------------------------

Compiled error:

This included some changes to any unrelated section changing to error to:

---------------------------

AutoIt Error

---------------------------

Line 552 (File "C:\Users\Judith\AutoItFiles\DVDLister\DvdLister.exe"):

Error: Array variable subscript badly formatted.

---------------------------

OK

---------------------------

[size="2"]The second mouse gets the cheese[/size]
Link to comment
Share on other sites

The problem you're having is caused by an _ArraySort in your script. It could be that you're formatting the function call incorrectly, or you're sending it a negative value as the sub item.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

The problem you're having is caused by an _ArraySort in your script. It could be that you're formatting the function call incorrectly, or you're sending it a negative value as the sub item.

I put in code to avoid the -1

Func RefreshListView()
    MsgBox(0,$ListViewHandle, GUICtrlGetState($ListViewHandle))
    if GUICtrlGetState($ListViewHandle) < 0 then _ArraySort($Data, 0, 0, 0, GUICtrlGetState($ListViewHandle)) ; Sort the array

    _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListViewHandle)) ; Delete the current content
    _GUICtrlListView_AddArray($ListViewHandle, $Data) ; Add the sorted content

EndFunc   ;==>RefreshListView

[\code]

Same error message.
Thinking about simply disabling the button until a sort has been made.


            
        

        

        
            

    
        

        
            [size="2"]The second mouse gets the cheese[/size]
        
    

        
    

    

    




    Link to comment
    
        
    
    
    

    
    Share on other sites
    

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    


    
    More sharing options...

    


    

                    
                    
                    
                

                    

                    
                    





    

    

    
        
            
                


    
        
    

                
                
                    
                        

                    
                
            
        
        
            
                


JAFN
            
            
                Posted 
                
            
        
    
    
        


JAFN
            
        
        
            
                
                    


    
        
    

                    
                    
                        

                    
                
            
            
                Active Members
                
            
            
                
                    
                        
                            
                                
                            
                                 135
                            
                                
                            
                        
                        
                    
                
            
            
                

            
        
    
    
        



    
        
            
                
                    
                        Author
                    
                    
                    
                    
                    
                
            
            
                
                    
                    
                        
                        
                            Share
                        
                        
                        
                        
                        
                            
                                
                            
                            
                            
                            
                            
                            
                        
                    
                
                
            
        

        
            Posted 
            
            
                
                
            
        
    

    

    

    
        
        
            I put in code to avoid the -1

Func RefreshListView()
MsgBox(0,$ListViewHandle, GUICtrlGetState($ListViewHandle))
if GUICtrlGetState($ListViewHandle) < 0 then _ArraySort($Data, 0, 0, 0, GUICtrlGetState($ListViewHandle)) ; Sort the array

_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListViewHandle)) ; Delete the current content
_GUICtrlListView_AddArray($ListViewHandle, $Data) ; Add the sorted content

EndFunc ;==>RefreshListView

Same error message.

Thinking about simply disabling the button until a sort has been made

[size="2"]The second mouse gets the cheese[/size]
Link to comment
Share on other sites

Actually, your code will only sort the array when it's LESS than 0, you need to use if GUICtrlGetState($ListViewHandle) >= 0 then

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I went with disabling the refresh command when no data had been changed. A logical feature and seems to be working.

Any ideas on why:

If $DVDid <> "" Then
        $WPos = WinGetPos($DVDid)
        $x = $WPos[0]
        $y = $WPos[1]
        If $x <> -32000 Then IniWrite($Name & ".ini", "Starting Value", "Window Left", $x) ; save the x,y locations of the window
        If $y <> -32000 Then IniWrite($Name & ".ini", "Starting Value", "Window Top", $y) ; so next time it will be in the same place

        GUIDelete($DVDid)
        $DVDid = ""
    EndIf

Sometimes works and sometimes says 'non-array variable use with array'?

[size="2"]The second mouse gets the cheese[/size]
Link to comment
Share on other sites

I'm guessing that $DVDid is the title of the window you're trying to get the position of? It's possible that the WinGetPos is failing to get the position of the window so it is returning 0 which isn't an array. Try adding an error check before trying to get the position of the window in the array. For example:

$WPos = WinGetPos($DVDid)
If Not IsArray($WPos)Then
    ;Do something 
Else
    $x = $WPos[0]
    $y = $WPos[1]
    If $x <> -32000 Then IniWrite($Name & ".ini", "Starting Value", "Window Left", $x) ; save the x,y locations of the window
    If $y <> -32000 Then IniWrite($Name & ".ini", "Starting Value", "Window Top", $y) ; so next time it will be in the same place
    GUIDelete($DVDid)
    $DVDid = ""
EndIf

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I'm guessing that $DVDid is the title of the window you're trying to get the position of? It's possible that the WinGetPos is failing to get the position of the window so it is returning 0 which isn't an array. Try adding an error check before trying to get the position of the window in the array. For example:

$WPos = WinGetPos($DVDid)
If Not IsArray($WPos)Then
    ;Do something 
Else
    $x = $WPos[0]
    $y = $WPos[1]
    If $x <> -32000 Then IniWrite($Name & ".ini", "Starting Value", "Window Left", $x) ; save the x,y locations of the window
    If $y <> -32000 Then IniWrite($Name & ".ini", "Starting Value", "Window Top", $y) ; so next time it will be in the same place
    GUIDelete($DVDid)
    $DVDid = ""
EndIf

I was just coming to say I had had my 'aha' moment. The one you listed above. Thanks. I took the opportunity to tighten up the script and add a lot of error checking.

Thank you all, I learned a lot today.

[size="2"]The second mouse gets the cheese[/size]
Link to comment
Share on other sites

It's always a good thing to see that what I am posting is helping others, as other's have helped me with problems I've run into.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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