Jump to content

Problems With Array Scope ..


Recommended Posts

So I'm trying to use a Global $array inside of a function, but as soon as I enter the function, $array becomes non-array, and I'm absolutely lost as to why. Here's the pseudo:

Global $array[1]

MsgBox(0,"...",IsArray($array)); returns '1'
_myFunc


Func _myFunc()
MsgBox(0,"...",IsArray($array)); returns '0'
EndFunc

I tried adding a 'Global $array' inside of the function, didn't change anything. What am I doing wrong here?

tia,

] asbo

Edited by ·· ħþø ··
Link to comment
Share on other sites

  • Moderators

So I'm trying to use a Global $array inside of a function, but as soon as I enter the function, $array becomes non-array, and I'm absolutely lost as to why. Here's the pseudo:

Global $array[1]

_myFunc
Func _myFunc()That's what you call pseudo code?

Just post your issue, the way you have it, $array[0] is the only thing that could retain a value.


            
        

        

        
            

    
        

        
            
    Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

        
    

        
    

    

    




    Link to comment
    
        
    
    
    

    
    Share on other sites
    

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    


    
    More sharing options...

    


    

                    
                    
                    
                

                    

                    
                    





    

    

    
        
            
                


    
        
    

                
                
                    
                        

                    
                
            
        
        
            
                


·· ħþø ··
            
            
                Posted 
                
            
        
    
    
        


·· ħþø ··
            
        
        
            
                
                    


    
        
    

                    
                    
                        

                    
                
            
            
                Members
                
            
            
                
                    
                        
                            
                                
                            
                                 2
                            
                                
                            
                        
                        
                    
                
            
            
                

            
        
    
    
        



    
        
            
                
                    
                        Author
                    
                    
                    
                    
                    
                
            
            
                
                    
                    
                        
                        
                            Share
                        
                        
                        
                        
                        
                            
                                
                            
                            
                            
                            
                            
                            
                        
                    
                
                
            
        

        
            Posted 
            
            
                
                
            
        
    

    

    

    
        
        
            
That's what you call pseudo code?

Just post your issue, the way you have it, $array[0] is the only thing that could retain a value.Sorry, I was tabbing around and accidentally submitted it 


            
        

        

        
    

    

    




    Link to comment
    
        
    
    
    

    
    Share on other sites
    

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    


    
    More sharing options...

    


    

                    
                    
                    
                

                    

                    
                    





    

    
        
            
                
                    Moderators
                
                
                
                
            
        
    

    
        
            
                


    
        
    

                
                
                
                
                    
                        

                    
                
            
        
        
            
                


SmOke_N
            
            
                Posted 
                
            
        
    
    
        


SmOke_N
            
        
        
            
                
                    


    
        
    

                    
                        
                    
                    
                        

                    
                
            
            
                Moderators
                
                    
                
            
            
                
                    
                        
                            
                                
                            
                                 16.3k
                            
                                
                            
                        
                        
                            
                                
                                    
                                        
                                        49
                                
                                    
                                
                            
                        
                    
                
            
            
                

    
    
        
It's not what you know ... It's what you can prove!
    
    

            
        
    
    
        



    
        
            
                
                    
                    
                        Moderators
                    
                    
                    
                    
                
            
            
                
                    
                    
                        
                        
                            Share
                        
                        
                        
                        
                        
                            
                                
                            
                            
                            
                            
                            
                            
                        
                    
                
                
            
        

        
            Posted 
            
            
                
                
            
        
    

    

    

    
        
        
            Well this would be considered pseudo code IMHO:Global $array[1]
$array[0] = "Testing This Array"
MyFunc($array)

Func MyFunc(ByRef $aArray)
    If IsArray($aArray) Then
        For $iCount = 0 To UBound($aArray) - 1
            MsgBox(64, 'Info:', '$aArray[' & $iCount & '] = ' & $aArray[$iCount])
        Next
    EndIf
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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