Strange local behavior (plus a cool tip!)

revolution at knowledgeworks.plus.com revolution at knowledgeworks.plus.com
Thu Jun 24 08:58:04 EDT 2004


Hi Xavier,

I found this in the docs:
>>
To create a script local variable, you use the local command in the script, but outside any handler:

  local mySharedVariable

  on mouseDown
    put 2 into mySharedVariable
  end mouseDown

  on mouseUp
    answer mySharedVariable -- displays "2"
  end mouseUp

Any handler that comes after the local declaration can use the script local variable. 
<<

I noticed that in the TD entry for "local" does not really make it clear 
that it is only handlers after the declaration of a script local variable 
that can use that variable.  It looks to me that in your mouseUp handler 
it will be creating a 'handler local' variable.

Regards,
Bernard




"MisterX" <b.xavier at internet.lu>
Sent by: use-revolution-bounces at lists.runrev.com
24/06/2004 09:18
Please respond to x; Please respond to How to use Revolution

 
        To:     "How to use Revolution" <use-revolution at lists.runrev.com>
        cc: 
        Subject:        Strange local behavior (plus a cool tip!)


Maybe this is my pandimensional processor acting up but I wanted to know 
if
the following is localized to this computer or you have had the same
experience.

I entered a bug regarding the loss of hilitedlines in a list field after
resizing a stack.

so I wrote this nice little handler to save the face of my applications
<script 1>
on mouseUp
  put the hilitedtext of me into x
  put the hilitedline of me into ilastselection -- for reselect handler

  bla bla bla
end mouseUp

local ilastselection

on reselect
  -- in case selection is lost
  set the hilitedline of me to ilastselection
end reselect

When I needed to use the hilitedline of this field, I would just send
"Reselect" to the field and the hilitedline would come back if it was 
lost.
Well, funny behavior is that it never worked!

So I put the "local" statement before the mouseup and now it works.

I checked the documentation to see if there was a mention of precedence 
but
there isn't any.

So is it normal? Should I write a bugzilla to suggest documentation change
or a script precendence bug?

cheerios
Xavier


_______________________________________________
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