I'm in the early stages of using more external libs/behaviors for things I used 
to always pile up in stack/card/object scripts and custom properties.  My  old 
practice was less than stellar in terms of re-usability, fixing the same thing 
in multiple places etc.. So I'm looking to make more libs that can be re-used 
as behaviors.  But now I face message path mysteries I'm sure all of you have 
understood for decades. In particular:

passing values, via constants or local vars, as params.

I'm working on a gradient library to use as a behavior with graphics objects, 
the idea is to be able to pass a one or more curated color values to a gradient 
ramp where the gradient type, location, span etc are already set. 

If nothing is passed the function set defaults and returns a black and white 
radial gradient. or you can just pass a single RGB value to the end stop…  I 
have not included that function here, because it works if I pass an explicit 
three integer RGB value… 

But I am unable to pass either a constant or a local variable as a parameter

What am I doing wrong here:

on mouseUp
    setRamp "","","",sSoftRed,"",""  
    # function generates a fillGradient["ramp']  using defaults 
    # for the empty params, with a single color applied to the end stop.
    # I can't get the value of sSoftRed to go thru….
    # it works if I pass and explicit RGB string: "255,20,20" 
end mouseup

# We want to set up some curated colors in advance:

# Defaults:
constant kPureWhite= "255,255,255"
constant kPureBlack= "0,0,0"
constant kDefaultStart= "0.00000"               # left stop
constant kDefaultEnd= "1.00000"                 # right stop
constant kDefaultOpacity= "255"                         # 100% opaque

# Curated Colors
constant kSoftGreen = "88,246,27"
constant kSoftRed = "255,6,23"
# more to come later…

setRamp "","","","255,6,23","","" # this works

setRamp "","","",kSoftRed,"","" # this fails

# since a constant did not work, I tried locals:

command assignColors # trying locals here…
    local sSoftGreen, sSoftRed
    put "88,246,27" into sSoftGreen
    put "255,6,23" into sSoftRed
end assignColors

if I set the break point on the mouseup  I can see in the variable watcher that 
the values we expect are there:

kSoftRed  255,6,23
sSoftRed 255,6,23

But when passed as a param the gradient ramp gets (where start defaults to 

setRamp "","","",sSoftRed,"","" # this also fails

# we see this:

# or 


# if I try to pass the param as a constant

and errors out with "bad gradient ramp" because the literal string value of the 
name of the variable or constant is passed and not the value it contains.

I would rather avoid "do" if at all possible. 


Missing something really simple here.


use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your subscription 

Reply via email to