usage of "this"

Ken Ray kray at sonsothunder.com
Thu Oct 31 15:31:01 CST 2002


Alex,

Actually this is consistent behavior because your context is switching.
"This" always refers to the object that has the focus. If you have a stack
named "stack one" and another named "stack two", and you have a button on
"stack one" that says:

on mouseUp
  go to first card of stack "stack two" as toplevel
end mouseUp

the current stack with the stack with the focus ("this stack") *before* the
"go to" command is "stack one", but once you opened another stack, it now
has the focus, and so "this stack" is looking at "stack two". If you want to
change the focus, you can use "set the defaultStack to <stackDescriptor>" or
do what you did, which is specifically address a stack by name when you
close it.

BTW: stacks open as topLevel automatically (unless you specify otherwise),
and will open to the first card as well, so you only need: go to stack
"stack two".

So if you want to close one stack and open another, you can do any of the
following:

on mouseUp
  go to stack "stack two"
  set the defaultStack to "stack one"
  close this stack
end mouseUp

on mouseUp
  go to stack "stack two"
  close stack "stack one"
end mouseUp

on mouseUp
  put the short name of this stack into tStack
  go to stack "stack two"
  close stack tStack
end mouseUp

And I'm sure there are a bunch more ways to do this. But you get the idea.

Hope "this" helps,

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/


----- Original Message -----
From: "Alex Rice" <alex at mindlube.com>
To: <use-revolution at lists.runrev.com>
Sent: Wednesday, October 30, 2002 2:11 PM
Subject: usage of "this"


> I was just hunting down this bug in my program, and it seems
> counterintuitive what I discovered. In this code, the value of "this
> stack" changes even before the handler finishes! That's surprising for
> some reason. I don't know why I though "this" was consistend through a
> handler. What other handlers or functions in rev can cause "this" to
> change like this?
>
> if tCalcType is not empty then
>      go to first card of stack tCalcType as toplevel
>      -- close the the current... the stack we were just in.
>      -- close this stack -- nope; "this stack" has now changed!
>      close stack "FacilityCalculator"
> end if
>
> Alex Rice, Software Developer
> Architectural Research Consultants, Inc.
> alrice at swcp.com
> alex_rice at arc.to
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list