Jump to content

ConsoleWrite and Non-Accessible Variables


Recommended Posts

Hello!

So I have a little script here 

Func getThe ()
      Local $nearPix = 0123
      Local $winPos = WinGetPos ($workWin)
      FFSaveBMP ("yBarPosArea", "True" , 600, 239, 600, 555, 30, $workWin)
      $nearPix = FFNearestPixel (600, 220, "0xC1C1C1" , False, $workWin)
      If $nearPix == 0123 Then
         ConsoleWrite ("No val for NearPix")
      ElseIf $nearPix <> 0123 Then
         ConsoleWrite ("Val is there")
      
      ConsoleWrite ($nearPix[0]&","&$nearPix[1]&@CR)
EndIf
EndFunc

And when it comes time to run it I get a return of 

Quote

(11) : ==> Subscript used on non-accessible variable.:

ConsoleWrite ($nearPix[0]&","&$nearPix[1]&@CR)
ConsoleWrite ($nearPix^ ERROR

When it says "non-accessible variable" , what is it meaning by that? The scope is "Local" and it is within the same function. The variable was even referenced in the step right before the one throwing the error. Any insight would be thoroughly appreciated. Thank you!

Link to comment
Share on other sites

  • Moderators

@Reizvoller it is telling you that $nearPix[0] does not exist. It appears you are expecting $nearPix to be an array of values; have you tried inserting an _Arraydisplay, or IsArray for debugging purposes?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Greetings JLogan, 

IsArray escaped my memory and it has returned with "Not an array" in my little script

Func getThe ()
      Local $nearPix = 0123
      Local $winPos = WinGetPos ($workWin)
      FFSaveBMP ("yBarPosArea", "True" , 600, 239, 600, 555, 30, $workWin)
      $nearPix = FFNearestPixel (600, 220, "0xC1C1C1" , False, $workWin)
      If $nearPix == 0123 Then
         ConsoleWrite ("No val for NearPix")
      ElseIf $nearPix <> 0123 Then
         ConsoleWrite ("Val is there")
      Local $arrayCheck = IsArray ($nearPix)
      If $arrayCheck = 0 Then
         ConsoleWrite ("Not an array")
      ElseIf $arrayCheck = 1 Then
         ConsoleWrite ($nearPix[0]&","&$nearPix[1]&@CR)
      EndIf

EndIf
EndFunc

That's the script as it stands now, did I employ the "IsArray" appropriately in your opinion?

I am going to dig around at my FFNearestPixel function as it isn't giving me the array return I am hoping for... 

Your debugging reminder was very valuable at the very least. Thank you again. :)

Edited by Reizvoller
Error in my script
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

×
×
  • Create New...