Parameterising an application

Ken Ray kray at sonsothunder.com
Mon Jul 4 12:25:42 EDT 2005


On 7/2/05 4:16 AM, "Robert Cailliau" <robert.cailliau at free.fr> wrote:


> Methods (1) and (2) have the disadvantage that I need to separate the
> declaration from the value assignment and/or need to write code in an
> initialisation routine.  Method (3) is in some sense worse because
> when I change my mind as to the value, I have to change it in all
> stacks that use it.

Yup.

> It seems I cannot do it by some statement like:
> 
>     global constant cRed = "255,0,0"
> 
> However, this restriction does not apply to handlers:  If I write a
> handler in the main stack's script and then call it from a substack,
> I do not have to make any declaration in the substack.  Similarly, it
> is sufficient to write
> 
>     start using stack <stackname>
> 
> to get access to all its handlers.
> 
> Maybe (suggestion) there should be a "global constant" statement,
> such that any global constants are application-wide and this would
> also apply to global constants declared in stacks used as libraries.

(Here we go again...)  ;-)

Sorry, Robert, but there were two VERY LONG threads on the Improve Rev list
recently about this, and the bottom line result was that if it is important
to you then vote for it in BugZilla (Bug #2401) and we'll see if RunRev puts
it in.

For right now, it seems that the simplest way to simulate global constants
is to create a function handler in a stack that you can get to (like a
library stack) that returns the static value and then use that in your code.

Ex.  libStuff

function cRed
  return "255,0,0"
end cRed

Elsewhere:

  set the backgroundColor of field 1 to cRed()

HTH,

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




More information about the use-livecode mailing list