Is this possible?

Scott Rossi scott at tactilemedia.com
Sun Jan 30 18:54:58 EST 2005


Recently, Jim Hurley wrote:

> Rather than have a handler poll the OS each time it is run, would it
> be possible to modify a handler just once in an openstack handler
> like the following:
> 
> on openstack
>  put the script of button 1 into tScript
>  if the platform is "macOS" then
>    replace "--unlock screen" with "unlock screen" in tScript
>  end if
>  set the script of button 1 to tScript
> end openstack
> 
> This works in the IDE environment, but will it work in a stand alone?
> 
> I know a script can't modify itself, and that a stack can't make
> permanent changes in a stand alone, but can a stand alone modify
> component scripts each time the stack is opened as indicated above?


Not if the script is more than 10 lines long.  Scripts run outside the IDE
cannot be edited if they're more than 10 lines.  What you're trying to do
above will need to be coded for within the script, which could be done with
a custom handler:

  on doMyRoutine
   lock screen
   doSomeStuff
   unLockTheScreen
   doSomeOtherStuff
  end doMyRoutine

  on unlockTheScreen
   if the platform = "macOS" then unlock screen
  end unlockTheScreen

FWIW, I don't believe "polling the OS" is a big deal.  But if you're really
concerned about it, you can store the platform info at startup in a global
or user property and reference this in your scripts.

Regards,

Scott Rossi
Creative Director
Tactile Media, Development & Design
-----
E: scott at tactilemedia.com
W: http://www.tactilemedia.com



More information about the use-livecode mailing list