Oh I see how that works. That makes sense for distributed developer tools. You are preventing unintended changes to your internal variables from the the "outside world" while providing a mechanism for accessing them if needed. I never understood Script Local variables until now.

Bob Sneidar
IT Manager
Logos Management
Calvary Chapel CM

On Dec 12, 2008, at 9:02 AM, Rob Cozens wrote:

Bob, et al:

A couple of follow up thoughts:

And script local variables cannot be accidentally or purposely read
or changed by scripts in other stacks or other objects.

This may not mean much if you are developing end user applications;
however if you are building libraries that may be used by other Rev
developers, it is a significant plus.

any script local variable can be accessed by handlers in other
scripts or stacks, if the script declaring the local variable
includes a getValue function and a setValue command for that variable. Eg:

local mySharedVariable

function getValue
  return mySharedVariable
end getValue

on setValue newValue
  put newValue into mySharedVariable
end setValue

The examples I gave are very generic.  In the real world one might
script specific get and set handlers:

local mySharedVariable
local anotherSharedValue

function getMySharedVariable
   return mySharedVariable
end  getMySharedVariable

on setAnotherSharedValue newValue
   put newValue into anotherSharedValue
end

or something a little more generic like:

function getValue variableName
   switch variableName
      case "mySharedVariable"
         return mySharedVariable
      case "anotherSharedValue"
         return anotherSharedValue
   end switch
   return empty --or an error
end getVal;ue

on setValue variableName, newValue
   switch variableName
      case "mySharedVariable"
         put newValue into mySharedVariable
         break
      case "anotherSharedValue"
         put newValue into anotherSharedValue
         break
   end switch
end getVal;ue

I don't know if "do" will do the job:

function getValue variableName
   do "put"&&variableName&&"into theValue"
  return theValue
end getValue

because I don't do "do"s and wonder if code compiled a runtime can
access script local variables.

If shared script local variables reside in the stack script, then
handlers such as those above allow access to the variables from every
other handler in the stack.  If the script locals reside on an
interior control, one might want to script getValue as a command
which can be sent by other handlers elsewhere in the stack:

on getMySharedVariable
   return mySharedVariable
end getMySharedVariable

Where the calling handler could...

   send "getMySharedVariable" to <reference to control whose script
contains\ the variable>
   put the result into mySharedVariableCopy



Rob Cozens CCW
Serendipity Software Company

"And I, which was two fooles, do so grow three;
 Who are a little wise, the best fooles bee."

 from "The Triple Foole" by John Donne (1572-1631)
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to