No.  What tripped me up was

<?livecode
put "lc version is" && the version & "<br>"
constant x = 4
put "this web page shows the problem" & "<br>"
put "here x = " && x & "<br>"

on somehandler
  put "within a handler, x =" && x & "<br>"
end somehandler

somehandler
put "and finally x still =" && x & "<br>"
?>
Constants do not take effect *outside* handlers. You rarely, if ever, have code outside a handler in "traditional" livecode - but revserver has changed that, so I think it's a reasonable request to enhance it to work for non-handle code.

But I am worried there's some obvious case that I haven't thought of that would prevent that being a good idea. If no-one comes up with a reason to keep this constraint, I'll submit an enhancement request.

-- Alex.

On 29/05/2012 04:57, dunb...@aol.com wrote:
Alex.


I have found that if you say this:


contant x = 4


on mouseup
   answer x
end mouseup


You get a "4"


But, if you place the contstant statement below the handler, you geet "x".


Is this what tripped you up?


Craig Newman



-----Original Message-----
From: Alex Tweedly<a...@tweedly.net>
To: How to use LiveCode<use-livecode@lists.runrev.com>
Sent: Mon, May 28, 2012 7:02 pm
Subject: Constant statement limitations.


The dictionary entry for constant says:
If you place the constant statement in a handler, you can use the
constant anywhere in the handler. If you place the constant statement
in a script outside any handler, you can use the constant anywhere in
the handlers of that script.
NB - "can use the constant anywhere *in the handlers* of that script".

That was a reasonable limitation in traditional Livecode - but seems
less reasonable in the context of revserver. It is (I think) common
practice, and it's certainly possible, to have quite a lot of the
"top-level" code be in the script itself, perhaps with html intermingled
with it, i.e. not be in a handler.

So the obvious, simple code fragment

constant K = 3.14159
put $_POST["diameter"] * K

doesn't give the expected result :-)

Anyone see any reason why constants *shouldn't* be usable outside handlers ?

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


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



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

Reply via email to