Local variables perhaps not being recognised


#1

In a form, I wish to give the user the options of displaying and removing a second form containing a Text List Object. I have buttons, “Display a listing” and “Remove the listing”. This is the code that results from clicking either of them:

local a,b,c,d
getwindow a,b,c,d
if Button contains "display"
    zoomwindow 23,b-500,c,d,"nopalette,noscroll"
    openform "DataListing"
    zoomwindow 23,b-500+d,c,1010,"nopalette,noscroll"
else
    openform "DataListing"
    closewindow
    zoomwindow a,b,c,d,"nopalette,noscroll"
endif    

The first zoomwindow command shifts the current form left by 500 points to make room for the listing.

When I click on “Remove the listing”, the second block of code executes but the zoomwindow statement in that block, designed to return the first form to its original location, is not effected. A message after the zoom displays, so the procedure’s not stopping.

If I use numeric values instead of a,b,c,d, it works, so it appears that the local variables are not being recognised, even though they were in the two previous zoomwindow statements.


#2

I suppose the second button is on the form “Datalisting”. So there would be no need for opening that form again.

I think you had defined a variable named “Button” somewhere else. In my test I replaced it with the function delivering the title of the clicked object.

Since the variables a, b, c, d are recalculated with each click in either form, you simply have to revert your movement to the right. (In my test database I left those forms named “Form_A” and “Form_B”.)

local a,b,c,d
getwindow a,b,c,d
if objectinfo("title",info("clickedobjectid")) contains "Display"
    zoomwindow 23,b-500,c,d,"nopalette,noscroll"
    openform "Form_B"
    zoomwindow 23,b-500+d,c,1010,"nopalette,noscroll"
else
    closewindow
    openform "Form_A"
    zoomwindow a,b+500-d,c,d,"nopalette,noscroll"
endif

#3

Of course - I missed that and your solution works if I change

zoomwindow a,b+500-d,c,d,"nopalette,noscroll"  

to

zoomwindow a,b+500,c,d,"nopalette,noscroll"

It’s really good having you in a time zone about eight hours behind - you are always there when I have problems late at night. Thank you for yet another rescue.