Sign in to follow this  
Followers 0
OiMunk

Newb Question: non-array variable?

5 posts in this topic

#1 ·  Posted (edited)

I'm getting an "Error: Subscript used with non-Array variable", but only 10% of the time. Does anyone know how to make this work?

This script is designed to resize two windows in relation to each other. The 3rd line has the error.Thanks,

$size = WinGetPos("FX chain","")

$sizeB = WinGetPos("Add FX","")

If $size[2] > 1000 Then ;Check if Window is too Wide ERROR LINE

WinMove("FX chain","",0,111, 999,666) ;make smaller

Else

WinMove("FX chain","",0,111,$size[2],$size[3]) ;leave size

EndIf

$FXWidth=999

If $size[2] < 888 Then

$FXWidth=888

EndIf

$sizeB[3]=600 ;unsure about this line, but seems to stop an array error next line

WinMove("Add FX","",$FXWidth,111,$sizeB[2],$sizeB[3]) ; RESIZE ADD FX WINDOW

Edited by OiMunk

Share this post


Link to post
Share on other sites



$size = WinGetPos("FX chain","")
$sizeB = WinGetPos("Add FX","")

if Not @error then
  If $size[2] > 1000 Then ;Check if Window is too Wide ERROR LINE
    WinMove("FX chain","",0,111, 999,666) ;make smaller
  Else
    WinMove("FX chain","",0,111,$size[2],$size[3]) ;leave size
  EndIf

  $FXWidth=999

  If $size[2] < 888 Then
    $FXWidth=888
  EndIf

  $sizeB[3]=600 ;unsure about this line, but seems to stop an array error next line
 
  WinMove("Add FX","",$FXWidth,111,$sizeB[2],$sizeB[3]) ; RESIZE ADD FX WINDOW
endif


[font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font]

Share this post


Link to post
Share on other sites

Well, I don't know if that will work. I am by no means an expert, so don't take offense ame1011 if I'm wrong. I think @error is reset after every built-in function call. So, you would need to check @error after the first and second call of WinGetPos()

Share this post


Link to post
Share on other sites

Thanks, that was an important lesson. I was trying to make a call to a Window that didn't quite exist yet

Share this post


Link to post
Share on other sites

That's correct crzftx. I was lucky and it turned out the error was in the 2nd WinGetPos call, but I managed to get the same error when the 1st Window didn't exist, despite the @error.

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