Discussion:
Explicit Variables again
(too old to reply)
Peter Haworth
2012-10-18 17:20:19 UTC
Permalink
Still working on converting my stacks to use explicit variables and am
realising the significance of the fact that the explicit variables setting
is global to the ID not local to a stack. Until I get all my stacks
converted, I'd like to pick and choose which ones use explicit variables
and which don't, and remembering to switch that option on and off via the
Preferences dialog is a pain.

I'm wondering if anyone knows where the LC Preference settings are stored?
What I have in mind is to have a custom property of each of my stacks that
defines whether explicit variables should be on or off and in preOpenCard
or similar, I'll set the Livecode Preference accordingly, then set it back
to it's initial value on closeStack.

Pete
lcSQL Software <http://www.lcsql.com>
Chris Sheffield
2012-10-18 17:28:57 UTC
Permalink
Pete,

It is possible to toggle it via the Edit menu when you have a script window open. Still a hassle, but doesn't take nearly as long as opening the prefs and doing it that way.

Chris


--
Chris Sheffield
Read Naturally, Inc.
www.readnaturally.com
Post by Peter Haworth
Still working on converting my stacks to use explicit variables and am
realising the significance of the fact that the explicit variables setting
is global to the ID not local to a stack. Until I get all my stacks
converted, I'd like to pick and choose which ones use explicit variables
and which don't, and remembering to switch that option on and off via the
Preferences dialog is a pain.
I'm wondering if anyone knows where the LC Preference settings are stored?
What I have in mind is to have a custom property of each of my stacks that
defines whether explicit variables should be on or off and in preOpenCard
or similar, I'll set the Livecode Preference accordingly, then set it back
to it's initial value on closeStack.
Pete
lcSQL Software <http://www.lcsql.com>
_______________________________________________
use-livecode mailing list
http://lists.runrev.com/mailman/listinfo/use-livecode
Chris Sheffield
2012-10-18 17:31:35 UTC
Permalink
Or there's this property that can be set:

explicitVariables = true or false

:-)
Post by Chris Sheffield
Pete,
It is possible to toggle it via the Edit menu when you have a script window open. Still a hassle, but doesn't take nearly as long as opening the prefs and doing it that way.
Chris
--
Chris Sheffield
Read Naturally, Inc.
www.readnaturally.com
Post by Peter Haworth
Still working on converting my stacks to use explicit variables and am
realising the significance of the fact that the explicit variables setting
is global to the ID not local to a stack. Until I get all my stacks
converted, I'd like to pick and choose which ones use explicit variables
and which don't, and remembering to switch that option on and off via the
Preferences dialog is a pain.
I'm wondering if anyone knows where the LC Preference settings are stored?
What I have in mind is to have a custom property of each of my stacks that
defines whether explicit variables should be on or off and in preOpenCard
or similar, I'll set the Livecode Preference accordingly, then set it back
to it's initial value on closeStack.
Pete
lcSQL Software <http://www.lcsql.com>
_______________________________________________
use-livecode mailing list
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
http://lists.runrev.com/mailman/listinfo/use-livecode
Richard Gaskin
2012-10-18 18:45:18 UTC
Permalink
I wouldn't worry too much about making your scripts "compliant" with
explicitvars.

There are probably some users who run with it on, but not many.

The IDE itself doesn't really use it except during compilation only, it
seems - here's where the dizzyingly long chain of commands that gets
invoked when you click "Apply" finally sets the script, handled here in
button "Template Editor" of stack "revscripteditor.rev":


command scriptCompile pObject
lock screen
lock messages

local tOldPreserveVariables, tOldExplicitVariables
put the preserveVariables into tOldPreserveVariables
put the explicitVariables into tOldExplicitVariables
set the preserveVariables to sePrefGet("preserveVariables")
set the explicitVariables to sePrefGet("explicitVariables")

local tScript
scriptGet pObject
put the result into tScript

local tResult
set the script of button "revCompileObject" of me to tScript
put the result into tResult

if tResult is empty then
put the revAvailableHandlers of button "revCompileObject" of me
into sHandlerList
end if

set the preserveVariables to tOldPreserveVariables
set the explicitVariables to tOldExplicitVariables

# The script should be unset because it could cause issues with idle
handlers
set the script of button "revCompileObject" of me to empty

unlock messages
unlock screen

return tResult
end scriptCompile


IIRC, explicitvars were seen as too cumbersome to work with, since as a
truly global property the required that EVERYTHING you're using comply
with it, and too many plugins didn't.

So rather than require every developer to comply with the requirements
of explicitvars just in case, they came up with that clever trick of
turning it on only during compilation, and immediately turning it back
off again (or to whatever its value was, which is usually off since most
folks who turn it "on" do so from Prefs, where it's not really "on"
until that moment of compilation.

In brief, I'd just blow it off and move on to other tasks....
--
Richard Gaskin
Fourth World Systems
Software Design and Development for the Desktop, Mobile, and the Web
____________________________________________________________________
***@FourthWorld.com http://www.FourthWorld.com
Joe Lewis Wilkins
2012-10-18 19:34:16 UTC
Permalink
Richard,

When this recently occurred when I started reworking one of my old projects, I was non-plussed, having actually forgotten how to declare vars explicitly. (smile) With my very poor vision I started looking for instances in which I had done so in the past and could not find any. So I am very pleased that this topic has surfaced on the list. I could not find any explanation that I could read in the Dictionary or the User's Guide. I've been avoiding using VARs so far by referencing containers. Not always very easy and, obviously, much slower. Guidance please?

Joe Wilkins
I wouldn't worry too much about making your scripts "compliant" with explicitvars.
There are probably some users who run with it on, but not many.
command scriptCompile pObject
lock screen
lock messages
local tOldPreserveVariables, tOldExplicitVariables
put the preserveVariables into tOldPreserveVariables
put the explicitVariables into tOldExplicitVariables
set the preserveVariables to sePrefGet("preserveVariables")
set the explicitVariables to sePrefGet("explicitVariables")
local tScript
scriptGet pObject
put the result into tScript
local tResult
set the script of button "revCompileObject" of me to tScript
put the result into tResult
if tResult is empty then
put the revAvailableHandlers of button "revCompileObject" of me into sHandlerList
end if
set the preserveVariables to tOldPreserveVariables
set the explicitVariables to tOldExplicitVariables
# The script should be unset because it could cause issues with idle handlers
set the script of button "revCompileObject" of me to empty
unlock messages
unlock screen
return tResult
end scriptCompile
IIRC, explicitvars were seen as too cumbersome to work with, since as a truly global property the required that EVERYTHING you're using comply with it, and too many plugins didn't.
So rather than require every developer to comply with the requirements of explicitvars just in case, they came up with that clever trick of turning it on only during compilation, and immediately turning it back off again (or to whatever its value was, which is usually off since most folks who turn it "on" do so from Prefs, where it's not really "on" until that moment of compilation.
In brief, I'd just blow it off and move on to other tasks....
--
Richard Gaskin
Fourth World Systems
Software Design and Development for the Desktop, Mobile, and the Web
____________________________________________________________________
_______________________________________________
use-livecode mailing list
http://lists.runrev.com/mailman/listinfo/use-livecode
Mark Wieder
2012-10-18 19:40:24 UTC
Permalink
Richard-
Post by Richard Gaskin
There are probably some users who run with it on, but not many.
...sad, but possibly true.
Post by Richard Gaskin
IIRC, explicitvars were seen as too cumbersome to work with, since as a
truly global property the required that EVERYTHING you're using comply
with it, and too many plugins didn't.
Not at all true.
Oh, wait... you're trolling again, right?
You're correct in that explicitVars only comes into play when you're
compiling a script, but I've always worked with explicitVars enabled.
If it caused problems in a generic sense I'd never be able to run the
IDE.
--
-Mark Wieder
***@ahsoftware.net
Richard Gaskin
2012-10-18 19:54:22 UTC
Permalink
Post by Mark Wieder
Richard-
Post by Richard Gaskin
There are probably some users who run with it on, but not many.
...sad, but possibly true.
Post by Richard Gaskin
IIRC, explicitvars were seen as too cumbersome to work with, since as a
truly global property the required that EVERYTHING you're using comply
with it, and too many plugins didn't.
Not at all true.
Oh, wait... you're trolling again, right?
I don't understand your frequent use of "trolling". I wasn't "trolling"
last time you suggested I was, and I'm not "trolling" now. And as far
as I know, Jacque wasn't "trolling" each of the times you suggested she
was either. Can we please move past that?

I'm frequently incorrect, but when I am it isn't intentional.

If you need to toss a word around try "mistaken", or even "buffoon", but
I'm not "trolling".
Post by Mark Wieder
You're correct in that explicitVars only comes into play when you're
compiling a script, but I've always worked with explicitVars enabled.
If it caused problems in a generic sense I'd never be able to run the
IDE.
If you choose to use explicitVars that's your own choice. But with all
due respect, you're not the only one making plugins.

Many simply don't use it; I haven't even thought about them in years
since RunRev made their implementation in the IDE compile-moment-specific.

--
Richard Gaskin
Fourth World
LiveCode training and consulting: http://www.fourthworld.com
Webzine for LiveCode developers: http://www.LiveCodeJournal.com
Follow me on Twitter: http://twitter.com/FourthWorldSys
J. Landman Gay
2012-10-18 20:27:57 UTC
Permalink
Post by Richard Gaskin
And as far
as I know, Jacque wasn't "trolling" each of the times you suggested she
was either.
Actually he said I indulged in hyperbole. But I've said a million times
I don't do that. :)
--
Jacqueline Landman Gay | ***@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Mark Wieder
2012-10-19 00:52:05 UTC
Permalink
Richard-
Post by Richard Gaskin
Post by Mark Wieder
Oh, wait... you're trolling again, right?
I don't understand your frequent use of "trolling". I wasn't "trolling"
My apologies. I assumed a <g> after that statement, but I guess it
didn't come across without my making it explicit.
--
-Mark Wieder
***@ahsoftware.net
Mark Wieder
2012-10-19 00:56:43 UTC
Permalink
Richard-
Post by Richard Gaskin
If you choose to use explicitVars that's your own choice. But with all
due respect, you're not the only one making plugins.
Sure, but as I pointed out, it doesn't affect other plugins. As long
as you don't need to compile plugins before using them it doesn't
matter whether explicitVars is on or off.
--
-Mark Wieder
***@ahsoftware.net
Richard Gaskin
2012-10-19 03:51:46 UTC
Permalink
Post by Mark Wieder
Post by Richard Gaskin
If you choose to use explicitVars that's your own choice. But with all
due respect, you're not the only one making plugins.
Sure, but as I pointed out, it doesn't affect other plugins. As long
as you don't need to compile plugins before using them it doesn't
matter whether explicitVars is on or off.
Depends what "on" means. :)

Remember that LiveCode is dynamically compiled - the only copy of a
script stored with a stack is the source copy, not any tokenized
version. So whenever you open a stack, as part of the unpacking its
scripts are dynamically compiled - and that's when the compilation error
will occur.

That is, if explicitVars is truly on.

If you're just turning it on via Prefs, in recent versions of LC that
merely sets a prefs value that causes explicitVars to be turned on only
for the moment a script is set; at all other times explicitVars isn't
really on at all (see the previous snippet from their IDE I posted that
illustrates that man behind the curtain).

But if you turn it on manually via the Message Box ("set the
explicitVars to true"), then you can see the behavior that happens when
you try to open a stack that has undeclared vars in its scripts - here I
get "can't create a variable with that name (explicitVars)".

So the good news is that RunRev's clever revamp of the IDE means we
never need to think about explicit vars for most projects, so those
turning it "on" via Prefs will never actually have it on unless they
open your script and try to save changes.

But the bad news is that it's just one more difference between how the
IDE works and how the engine works.

So when I wear my T-shirt which reads:

"Know the engine.
Trust the engine.
Use the engine."

...I need to add for the good folks at RunRev:

"If you own the engine
and don't like something in the engine,
change the engine."

:)



PS: Sorry about being over-sensitive about the "trolling" thing. I've
known you for enough years that I should have been able to expect
nothing more than good humor from you. I'd just had a complicated
morning; thank you for replying so gracefully.
--
Richard Gaskin
Fourth World Systems
Software Design and Development for Desktop, Mobile, and Web
____________________________________________________________
***@FourthWorld.com http://www.FourthWorld.com
Mark Wieder
2012-10-19 04:32:56 UTC
Permalink
Richard-
Post by Richard Gaskin
Remember that LiveCode is dynamically compiled - the only copy of a
script stored with a stack is the source copy, not any tokenized
version. So whenever you open a stack, as part of the unpacking its
scripts are dynamically compiled - and that's when the compilation error
will occur.
OK - I see the difference. I've never considered turning explicitVars
on from the message box. The message box is a weird enough critter
that I wouldn't be surprised by unexpected consequences (OK - I
realize that's an oxymoron, but I can live with that). But I've had
explicitVars enabled from the preferences menu for years and never had
a problem. The IDE stacks are notoriously not explicitVars-safe, so
you'd expect there to be issues with them if there were any problems
with running in mixed mode.

The only "issues" I've had are when trying to compile someone else's
stack, plugin or no, that doesn't have declared variables.
Post by Richard Gaskin
PS: Sorry about being over-sensitive about the "trolling" thing. I've
known you for enough years that I should have been able to expect
nothing more than good humor from you. I'd just had a complicated
morning; thank you for replying so gracefully.
Not a problem on my end. Sorry about the unintentional slight. And
sorry about your morning - mine was weird as well. Sunspots? UFOs?
--
-Mark Wieder
***@ahsoftware.net
Jerry Jensen
2012-10-19 05:00:06 UTC
Permalink
Post by Mark Wieder
But I've had
explicitVars enabled from the preferences menu for years and never had
a problem.
I'm writing as a far more pedestrian user of LC than either Mark or Richard. I've had explicit variables enabled from the prefs for a long time as well. I actually find it comforting. It helps me catch typos all the time. My eyesight is not great, and I often miss an m instead of an n, or a ; instead of a :, or the like. Usually when dealing with code I didn't write, its because I'm trying to fix code that doesn't work properly. Often, the original coder would have been helped by explicit vars.

One guy's opinion.
.Jerry
Thierry Douez
2012-10-19 05:45:17 UTC
Permalink
Post by Jerry Jensen
Post by Mark Wieder
But I've had
explicitVars enabled from the preferences menu for years and never had
a problem.
I'm writing as a far more pedestrian user of LC than either Mark or Richard. I've had explicit variables enabled from the prefs for a long time as well. I actually find it comforting. It helps me catch typos all the time. My eyesight is not great, and I often miss an m instead of an n, or a ; instead of a :, or the like. Usually when dealing with code I didn't write, its because I'm trying to fix code that doesn't work properly. Often, the original coder would have been helped by explicit vars.
One guy's opinion.
.Jerry
+1

another guy's opinion.

Thierry
Richard Gaskin
2012-10-19 14:47:22 UTC
Permalink
Post by Mark Wieder
Richard-
Post by Richard Gaskin
Remember that LiveCode is dynamically compiled - the only copy of a
script stored with a stack is the source copy, not any tokenized
version. So whenever you open a stack, as part of the unpacking its
scripts are dynamically compiled - and that's when the compilation error
will occur.
OK - I see the difference. I've never considered turning explicitVars
on from the message box. The message box is a weird enough critter
that I wouldn't be surprised by unexpected consequences (OK - I
realize that's an oxymoron, but I can live with that).
My issue with LC's Message Box is that it's always in palette mode.
MC's is modeless, and the more I use Terminal the more I've come to
enjoy having the MB occasionally sized larger and always layerable with
my other windows.

So a while back when I had a free Saturday I started work on my own MB
replacement, and these days it's much easier to do a graceful
implementation because we now have the messageBoxRedirect global
property (thanks for that one, Kevin - I'm making good use of it).

At the time my main motivation was just to have an MB I could use as an
optional plugin in standalones but limited to specific commands in case
I chose to make it available for customers, but the more I got to using
it the more I found it simpler for day-to-day work in the IDE than LC's
mouse-driven MB UI (when you're typing, you're typing).

I've since added a bunch of shortcuts I use all the time, like listing
globals vars and props, and stack lists, and the message path, and other
stuff, and then I started down the road of implementing a few shell
calls like "ls" and "cd" - and of course now the challenge is to stop
doing that so I can just post it for others to use. I have an update
for devolution in the works that'll include it once I get a few client
things out of the way. It'll be MIT licensed so folks can tear it apart
and make their own if they want.
Post by Mark Wieder
But I've had explicitVars enabled from the preferences menu for years
and never had a problem. The IDE stacks are notoriously not
explicitVars-safe, so you'd expect there to be issues with them if
there were any problems with running in mixed mode.
The only "issues" I've had are when trying to compile someone else's
stack, plugin or no, that doesn't have declared variables.
That's the great thing about LC's current implementation in their IDE,
one of the areas in which I'd say it's a cut above MetaCard:

In MC, being close to the engine as it is, explicitVars is truly a
global property, and will require that everything you run has been
written to accommodate it.

In LC we have greater freedom in the sense that we can turn it on for
our own scripts while still using stuff from other people that doesn't
account for it.


Some history trivia for those who might care:

The explicitVars global property was added for SuperCard compatibility
back in the late '90s. SC was the first xTalk to have implemented
this, and I suppose that Raney, with his degree in CS focused on
compiler design, found it appealing, so unlike so many other SC- and
HC-specific compatibility tokens added as mere non-working stubs, this
one was added with full functionality.

But how did SC come to have explicitVars?

Back in those days the lead engineer for SuperCard was Gary Poppitz, a
man well versed in C and 68k Assembler. As far as I know no user had
ever requested it, he just felt it would be useful and put it in.

After he added that to SC I wondered if perhaps the benefit might be
compiler optimization, so I did some benchmarking. But on the
contrary, I found that running with it turned on actually made script
execution measurably slower than without (not by much though, maybe <5%,
and I've seen no difference in speed with LC's implementation, though
it's been years since I've benchmarked it).

So I asked Gary, "Why was explicitVars added?", and he said, "Because it
enforces discipline."

I write tons of code, and then I have to also write unit tests and
harnesses for it - and I need a new feature that requires even more
discipline? :)

SC's implementation was like MC's (and ultimately LC's since of course
MC and LC are the same engine), in which it's truly global and requires
everything in the environment be compliant with it if it's to be used at
all.

So while I had no personal interest in explicitVars myself, I used to
adhere to its requirements because I had no choice if I wanted to share
code with others who might have it turned on.

Now that RunRev has made this a more optional thing I'll admit I never
bother with it at all. I can understand why some do, but I really love
the freedom of being able to choose for myself whether I use it or not
for a given script.
Post by Mark Wieder
Post by Richard Gaskin
PS: Sorry about being over-sensitive about the "trolling" thing. I've
known you for enough years that I should have been able to expect
nothing more than good humor from you. I'd just had a complicated
morning; thank you for replying so gracefully.
Not a problem on my end. Sorry about the unintentional slight. And
sorry about your morning - mine was weird as well. Sunspots? UFOs?
In my case it was UFOs: Uninteresting FUBAR Obstacles. :)

My mood has since elevated with news of some nice fixes in the LC engine
for Linux (including a particularly difficult one in which Mark
Waddingham worked around a GTK limitation to provide a workable
windowBoundingRect, at least for single-monitor setups - thanks Mark!),
and I very much enjoyed the notice on the Ubuntu.com home page
announcing their new 12.10 release with the tag line, "Avoid the pain of
Windows 8" (which they've since replaced with a much less interesting
tag line, but it made me chuckle while it was up <g>).

Like the Apple "1984", "Lemmings", and "I'm a Mac" ads, and the recent
ones from Samsung that turn the tables, sometimes a little controversy
isn't a bad thing; when done well it can even be fun (though I suppose
Win8 is an easy target given the press it's been getting, not to mention
Otellini's leaked memo).

--
Richard Gaskin
Fourth World
LiveCode training and consulting: http://www.fourthworld.com
Webzine for LiveCode developers: http://www.LiveCodeJournal.com
Follow me on Twitter: http://twitter.com/FourthWorldSys
Mark Wieder
2012-10-19 15:27:35 UTC
Permalink
Richard-
"Avoid the pain of Windows 8"
I run the Win8 Customer Preview in a VM at work, and while LC mostly
works as a desktop app, I reported a couple of bugs that the rev team
hasn't been able to reproduce. There's also one *really* annoying one
having to do (I think) with templates that I haven't been able to
narrow down enough to write a bug report yet. Luckily I don't need
Win8 for anything and I look forward to avoiding the pain.
--
-Mark Wieder
***@ahsoftware.net
Mark Wieder
2012-10-19 15:48:29 UTC
Permalink
Richard-
Post by Richard Gaskin
I've since added a bunch of shortcuts I use all the time, like listing
globals vars and props, and stack lists, and the message path, and other
stuff, and then I started down the road of implementing a few shell
calls like "ls" and "cd" - and of course now the challenge is to stop
doing that so I can just post it for others to use. I have an update
for devolution in the works that'll include it once I get a few client
things out of the way. It'll be MIT licensed so folks can tear it apart
and make their own if they want.
! Looking forward to that.
Thanks. I do care.
Post by Richard Gaskin
I write tons of code, and then I have to also write unit tests and
harnesses for it - and I need a new feature that requires even more
discipline? :)
<sigh> Look, as a qa engineer let me state the truism that the earlier
in the development process you can find bugs, the cheaper it is to fix
them. The idea of enforcing explicit variable declarations is to catch
some bugs at compile time rather then waiting for them to appear at
runtime and force you to debug what happened.

Have you ever typed something like

"if theversion > 4.5 then"
instead of
"if the version > 4.5 then"

Easy enough to find if it's in front of you like that, but what if
it's buried in several hundred lines of code? With explicitVars
enabled the compiler will tell you what line of code failed when you
press the Apply button.

I believe in letting the compiler help me rather than fighting against
it. That's the whole reason I enable explicitVars. I can't count the
number of stupid typos I've caught this way in my code, in other
people's code, and in the IDE. Stuff that should never have gotten out
the door in the first place, and wouldn't if people just let the
compiler exercise some "discipline".
--
-Mark Wieder
***@ahsoftware.net
Richard Gaskin
2012-10-19 16:41:51 UTC
Permalink
Post by Mark Wieder
<sigh> Look, as a qa engineer let me state the truism that the earlier
in the development process you can find bugs, the cheaper it is to fix
them. The idea of enforcing explicit variable declarations is to catch
some bugs at compile time rather then waiting for them to appear at
runtime and force you to debug what happened.
Have you ever typed something like
"if theversion > 4.5 then"
instead of
"if the version > 4.5 then"
Easy enough to find if it's in front of you like that, but what if
it's buried in several hundred lines of code? With explicitVars
enabled the compiler will tell you what line of code failed when you
press the Apply button.
I believe in letting the compiler help me rather than fighting against
it. That's the whole reason I enable explicitVars. I can't count the
number of stupid typos I've caught this way in my code, in other
people's code, and in the IDE. Stuff that should never have gotten out
the door in the first place, and wouldn't if people just let the
compiler exercise some "discipline".
I agree with everything you wrote, but I still don't do it. :)

I think it's just a question of work style.

While everyone has typos in their code (though here I don't do
"theversion" as much as "teh version" <g>), in practice I find those are
a very slender minority of issues I encounter.

Far more frequent are logic errors, mismatched states, or other things
far beyond the scope of what explicitVars can help with.

One could argue that even if explicitVars helps with only a very slender
subset of my issues, it's still better than not using it at all, and I
would agree if it were not for this aspect of my workflow:

LiveCode is great for both prototyping and final deployment, so in the
early stages I often don't know exactly what my code will look like in
its final state; I try a few things, flesh them out, revise them, and
over time it becomes a finalized handler I can use as an internal API.

But that process often involves a lot of iteration, and along the way
things that began as params may become local vars, or even script-local
vars as I identify ways to leverage other handlers, or even custom props.

Taking full advantage of xTalk's inherent looseness, I can let this
process flow easily, adjusting things as I go freely with minimal
effort. This helps me keep my focus on the logic side of things, which
is for myself the greater weakness.

Typos are often found in unit testing right away, but logic errors due
to state assumptions can be far more difficult to pin down in the early
stages, so while it may be a cognitive weakness of mine I need to
reserve every brain cell I can for those.

If I also take the time to declare every variable (or, as we've seen,
most variables, since apparently not all require declaration under
explicitVars), that's just extra stuff to revise while I'm also revising
code. So I can see how it would be a benefit to some, but for me it just
slows me down.

I've been tempted after I finalize an API to go back and make it all
explicitVars-compliant, but inevitably there are other things on my
to-do list that take priority.

The cool thing about the way RunRev has revamped its use of explicitVars
in the IDE is that it lets both of us use whichever mode we find most
productive for our work style.

--
Richard Gaskin
Fourth World
LiveCode training and consulting: http://www.fourthworld.com
Webzine for LiveCode developers: http://www.LiveCodeJournal.com
Follow me on Twitter: http://twitter.com/FourthWorldSys
Mark Wieder
2012-10-19 17:39:46 UTC
Permalink
Post by Richard Gaskin
I agree with everything you wrote, but I still don't do it. :)
LOL.
Post by Richard Gaskin
I think it's just a question of work style.
Yep. And far be it from me to get in the way of what makes you productive. For
my part, forcing explicitVars true makes me more productive down the road at the
small expense of a little extra work at the front end. YMM(and obviously does)V.
Post by Richard Gaskin
But that process often involves a lot of iteration, and along the way
things that began as params may become local vars, or even script-local
vars as I identify ways to leverage other handlers, or even custom props.
<g>
If you used glx2, you could refactor those from the menu.
</g>
--
Mark Wieder
***@ahsoftware.net
J. Landman Gay
2012-10-19 18:00:56 UTC
Permalink
Post by Richard Gaskin
If I also take the time to declare every variable (or, as we've seen,
most variables, since apparently not all require declaration under
explicitVars), that's just extra stuff to revise while I'm also revising
code. So I can see how it would be a benefit to some, but for me it just
slows me down.
That's my style too. And I like short, concise code, and having all that
extra stuff at the top of each handler just visually annoys me.

Typos are almost never a problem for me. I only type variable names once
when I first write them. I have a custom frontscript that includes a
whole lot of handy things, one of which is the ability to insert or
replace the selection with whatever word I point at. When I need to use
an existing variable, I just point at the original and hit a keyboard
shortcut and the variable name goes into the script with no typing. If
the handler is longer than the script window (very rare for me) then I
use copy/paste or the replace dialog.

I've been doing this for years and I virtually never have a misspelled
variable name. I do misspell other things, but the compiler tells me it
can't find the handler, or that the line as written doesn't make sense.

The result is tight code that reads like a story without any
interruptions in conceptualization. It seems to me that's the whole
point of the language -- it eliminates all the extra cruft that other
languages require. I suppose that's my HyperCard background coming
through, but then again, HC set the bar.

I'd be interested in the results if someone sets up a poll to see how
many people use explicit variables. I've always thought it was a
minority but maybe that's not so.
--
Jacqueline Landman Gay | ***@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Ralph DiMola
2012-10-19 18:26:23 UTC
Permalink
I have always used explicit variable checking since the first language that
had the option. I make spelling errors now and again this has saved me more
than a few times. I like that repeat loops vars do not have be declared.
This make the top of the code cleaner. I agree that cleaner and leaner the
better but I live with the local statements at the top. By the way, Putting
local statements anywhere but at the top is crazy. VB6 allows this as well
as LC but I never do it.

In short I have used strict compile mode since the first time I fired up LC.
It was one of the first things I looked for when perusing the pref screens
and turned it on.

Ralph DiMola
IT Director
Evergreen Information Services
***@evergreeninfo.net


-----Original Message-----
From: use-livecode [mailto:use-livecode-***@lists.runrev.com] On Behalf
Of J. Landman Gay
Sent: Friday, October 19, 2012 2:01 PM
To: How to use LiveCode
Subject: Re: Explicit Variables again
Post by Richard Gaskin
If I also take the time to declare every variable (or, as we've seen,
most variables, since apparently not all require declaration under
explicitVars), that's just extra stuff to revise while I'm also
revising code. So I can see how it would be a benefit to some, but for
me it just slows me down.
That's my style too. And I like short, concise code, and having all that
extra stuff at the top of each handler just visually annoys me.

Typos are almost never a problem for me. I only type variable names once
when I first write them. I have a custom frontscript that includes a whole
lot of handy things, one of which is the ability to insert or replace the
selection with whatever word I point at. When I need to use an existing
variable, I just point at the original and hit a keyboard shortcut and the
variable name goes into the script with no typing. If the handler is longer
than the script window (very rare for me) then I use copy/paste or the
replace dialog.

I've been doing this for years and I virtually never have a misspelled
variable name. I do misspell other things, but the compiler tells me it
can't find the handler, or that the line as written doesn't make sense.

The result is tight code that reads like a story without any interruptions
in conceptualization. It seems to me that's the whole point of the language
-- it eliminates all the extra cruft that other languages require. I suppose
that's my HyperCard background coming through, but then again, HC set the
bar.

I'd be interested in the results if someone sets up a poll to see how many
people use explicit variables. I've always thought it was a minority but
maybe that's not so.
--
Jacqueline Landman Gay | ***@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com

_______________________________________________
use-livecode mailing list
use-***@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Peter M. Brigham
2012-10-19 22:41:57 UTC
Permalink
Typos are almost never a problem for me. I only type variable names once when I first write them. I have a custom frontscript that includes a whole lot of handy things, one of which is the ability to insert or replace the selection with whatever word I point at. When I need to use an existing variable, I just point at the original and hit a keyboard shortcut and the variable name goes into the script with no typing. If the handler is longer than the script window (very rare for me) then I use copy/paste or the replace dialog.
I've been using your frontscript handler for several years now and I love it -- it saves me so much time and prevents typos. For those who are interested here is my version (slightly altered from yours, Jacque). They are all control-shift keypresses that work only in the IDE script editor. The one Jacque referred to is the "scriptPaint" handler: control-shift-space inserts the mousetext into the selection.

Put this into a frontScript:

on controlkeydown whichKey
put the long name of the target into tarName
put the shiftkey is down into shK
switch whichKey
case "'" -- ctrl-sh-quote puts quotes around the selection
if not shK then pass controlkeydown
if "field" is not in tarName then pass controlkeydown
if "revNewScriptEditor" is not in tarName then pass controlkeydown
get the selection
put q(it) into the selection
if it = "" then
put the selectedChunk into tSel
put word 4 of tSel into word 2 of tSel
put (word 4 of tSel) - 1 into word 4 of tSel
select tSel
end if
doUndoSpace
break
case "9"
case "0" -- ctrl(-sh)-paren puts parens around the selection
if "field" is not in tarName then pass controlkeydown
if not shK then pass controlkeydown
if "revNewScriptEditor" is not in tarName then pass controlkeydown
get the selection
put "(" & it & ")" into the selection
if it = "" then
put the selectedChunk into tSel
put word 4 of tSel into word 2 of tSel
put (word 4 of tSel) - 1 into word 4 of tSel
select tSel
end if
doUndoSpace
break
case "["
case "]" -- ctrl-bracket puts brackets around the selection
if not shK then pass controlkeydown
if "field" is not in tarName then pass controlkeydown
if "revNewScriptEditor" is not in tarName then pass controlkeydown
get the selection
put "[" & it & "]" into the selection
if it = "" then
put the selectedChunk into tSel
put word 4 of tSel into word 2 of tSel
put (word 4 of tSel) - 1 into word 4 of tSel
select tSel
end if
doUndoSpace
break
case "-"
case "_" -- ctrl-sh-dash comments out the line(s)
if not shK then pass controlkeydown
if "field" is not in tarName then pass controlkeydown
if "revNewScriptEditor" is not in tarName then pass controlkeydown
put the selectedLine into tLineCh
put "-" & "-" into cmntChars
if " to " is in tLineCh then
put word 2 of tLineCh into stLineNbr
put word 4 of tLineCh into endLineNbr
repeat with n = stLineNbr to endLineNbr
put "put cmntChars & space before word 1 of line" && n && "of" && tarName \
into theDo
do theDo
end repeat
-- put scriptLinesText into line stLineNbr to endLineNbr of the target
put endLineNbr into selectHere
else
put word 2 of tLineCh into lineNbr
put the long name of the target into tLongName
put sr(line lineNbr of the target) into tLineText
do "put cmntChars & space before word 1 of" && tLineCh
put lineNbr into selectHere
end if
doUndoSpace
send "tabkey" to tarname -- to fix indenting
select after line selectHere of the target
break
case "="
case "+" -- ctr(-sh)-plus uncomments the line -- until Rev fixes the commandkey shortcut
if not shK then pass controlkeydown
if "field" is not in tarName then pass controlkeydown
if "revNewScriptEditor" is not in tarName then pass controlkeydown
put the selectedLine into tLineCh
if " to " is in tLineCh then
put word 2 of tLineCh into stLineNbr
put word 4 of tLineCh into endLineNbr
put line stLineNbr to endLineNbr of target into scriptLinesText
repeat with n = 1 to the number of lines of scriptLinesText
put sr(line n of scriptLinesText) into tLineText
if char 1 to 2 of tLineText = "-" & "-"
then delete char 1 to 2 of tLineText
put tLineText into line n of scriptLinesText
end repeat
put scriptLinesText into line stLineNbr to endLineNbr of the target
else
put sr(value(tLineCh)) into tLineText
if char 1 to 2 of tLineText = "-"&"-" then
delete char 1 to 2 of tLineText
do "put tLineText into" && tLineCh
end if
end if
doUndoSpace
send "tabkey" to tarname
break
case " " -- scriptPaint: crl-sh-space inserts the mousetext into the selection
if not shK then pass controlkeydown
if "field" is not in tarName then pass controlkeydown
if "revNewScriptEditor" is not in tarName then pass controlkeydown
put the mouseText into the selection
doUndoSpace
break
default
pass controlkeydown
end switch
end controlkeydown

private command doUndoSpace
-- this solves the problem that after the above scripted operations
-- the script editor remains unaware that the script has changed,
-- so an <enterkey> will close but not save the changed script
-- thus we have to *type* at least one character
lock screen
put the selectedText into selTxt
type numToChar(32) -- the important step
put word 4 of the selectedChunk into charNbr
put selTxt into char charNbr of the target
unlock screen
end doUndoSpace

function q str
return quote & str & quote
end q
J. Landman Gay
2012-10-20 00:26:22 UTC
Permalink
Post by Peter M. Brigham
For those who
are interested here is my version (slightly altered from yours,
Jacque). They are all control-shift keypresses that work only in the
IDE script editor.
Actually, heavily modified. :) Here's mine for comparison. It uses the
command key instead of control key, doesn't include any commenting
functions, and still doesn't have your (useful) "type space" addition
which I've been meaning to add now for a few years.

on commandKeyDown whichKey
if ("editor field" is not in the name of the target and "script" is
not in the name of the target) \
or the shiftkey is not down
then pass commandKeyDown
switch whichKey
case quote
case "'"
put quote & the selection & quote into the selection
break
case "v" -- paste only plain text
put the clipboardData["text"] into the selection
break
case "="
case "+"
put " -" & "-" & "#"&"#"&"#" into the selection
break
case "9"
case "0"
case "("
case ")"
put "(" & the selection & ")" into the selection
break
case "["
case "]"
case "{"
case "}"
get the selection
put "[" & it & "]" into the selection
if it = "" then
put the selectedchunk into tSel
put word 4 of tSel into word 2 of tSel
put (word 4 of tSel) - 1 into word 4 of tSel
select tSel
end if
break
case " " -- scriptPaint
put the mousetext into the selection
break
default
pass commandKeyDown
end switch
end commandKeyDown
--
Jacqueline Landman Gay | ***@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Peter Haworth
2012-10-26 00:04:46 UTC
Permalink
Ho Jacque,
Just been playing around with this and there seems to be a problem using
command-z to undo - leaves garbage in the script field?
Pete
lcSQL Software <http://www.lcsql.com>
Post by J. Landman Gay
Post by Peter M. Brigham
For those who
are interested here is my version (slightly altered from yours,
Jacque). They are all control-shift keypresses that work only in the
IDE script editor.
Actually, heavily modified. :) Here's mine for comparison. It uses the
command key instead of control key, doesn't include any commenting
functions, and still doesn't have your (useful) "type space" addition which
I've been meaning to add now for a few years.
on commandKeyDown whichKey
if ("editor field" is not in the name of the target and "script" is not
in the name of the target) \
or the shiftkey is not down
then pass commandKeyDown
switch whichKey
case quote
case "'"
put quote & the selection & quote into the selection
break
case "v" -- paste only plain text
put the clipboardData["text"] into the selection
break
case "="
case "+"
put " -" & "-" & "#"&"#"&"#" into the selection
break
case "9"
case "0"
case "("
case ")"
put "(" & the selection & ")" into the selection
break
case "["
case "]"
case "{"
case "}"
get the selection
put "[" & it & "]" into the selection
if it = "" then
put the selectedchunk into tSel
put word 4 of tSel into word 2 of tSel
put (word 4 of tSel) - 1 into word 4 of tSel
select tSel
end if
break
case " " -- scriptPaint
put the mousetext into the selection
break
default
pass commandKeyDown
end switch
end commandKeyDown
--
HyperActive Software | http://www.hyperactivesw.com
______________________________**_________________
use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your
http://lists.runrev.com/**mailman/listinfo/use-livecode<http://lists.runrev.com/mailman/listinfo/use-livecode>
J. Landman Gay
2012-10-26 04:01:25 UTC
Permalink
Post by Peter Haworth
Ho Jacque,
Just been playing around with this and there seems to be a problem using
command-z to undo - leaves garbage in the script field?
Yes, it can do that. The insertions the script makes aren't known to the
editor. Undo is tracked by character position and those have changed
behind its back. I've become so used to it that I automatically save the
script after I use any of the frontscript features. Since the script was
always just for my personal use, I never bothered to harden it.

Last week I added a variation on Peter Brigham's "type space" fix, which
I've been meaning to do for ages. I haven't tested it much but so far
it's working. Forcing the editor to recognize the script changes may
also fix the undo problem (but I haven't really paid attention to that
yet.) Anyway, here's what I'm using now:

on commandKeyDown whichKey
if ("editor field" is not in the name of the target and "script" is
not in the name of the target) \
or the shiftkey is not down
then pass commandKeyDown
switch whichKey
case quote
case "'"
put quote & the selection & quote into the selection
break
case "v" -- paste only plain text
put the clipboardData["text"] into the selection
break
case "9"
case "0"
case "("
case ")"
put "(" & the selection & ")" into the selection
break
case "["
case "]"
case "{"
case "}"
get the selection
put "[" & it & "]" into the selection
if it = "" then
put the selectedchunk into tSel
put word 4 of tSel into word 2 of tSel
put (word 4 of tSel) - 1 into word 4 of tSel
select tSel
end if
break
case " " -- scriptPaint
put the mousetext into the selection
break
default
pass commandKeyDown
end switch
setEditorDirty
end commandKeyDown

private command setEditorDirty
type space
delete char (word 4 of the selectedchunk) of the target
end setEditorDirty
--
Jacqueline Landman Gay | ***@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Peter Haworth
2012-10-19 16:59:33 UTC
Permalink
Sounds like this is turning into a "There are 2 types of Livecode coders,
those who..." situation!

Marks' comment below hit the nail on the head for me. All I can say is
that when I converted my first stack to use explicit variables, it turned
up a couple of nasty bugs lurking in seldom used parts of the code that
would have surfaced to surprise me at some point in the future. I can also
recall more than one occasion where I spent a not insignificant amount of
time debugging a problem cause by a misspelled variable. So, for me, I am
more than happy to take the few extra seconds to type a local command,
knowing that it will almost certainly save me from myself.

But others may, and do, think differently. It's a personal opinion. Maybe
those of us who do use explicit variables should have our plugins display a
message at startup, something like:

WARNING!! THIS CODE CONTAINS VARIABLES OF AN EXPLICIT NATURE.

Pete
lcSQL Software <http://www.lcsql.com>
Post by Mark Wieder
<sigh> Look, as a qa engineer let me state the truism that the earlier
in the development process you can find bugs, the cheaper it is to fix
them. The idea of enforcing explicit variable declarations is to catch
some bugs at compile time rather then waiting for them to appear at
runtime and force you to debug what happened.
Mark Wieder
2012-10-19 17:46:00 UTC
Permalink
Post by Peter Haworth
Sounds like this is turning into a "There are 2 types of Livecode coders,
those who..." situation!
It was ever thus. Nothing wrong with that. I understand the arguments about it
being too much typing, especially if you never make mistakes. But given half a
chance I'll always advocate for a way to help keep coders out of trouble.
--
Mark Wieder
***@ahsoftware.net
Peter M. Brigham
2012-10-19 22:44:26 UTC
Permalink
Post by Peter Haworth
Sounds like this is turning into a "There are 2 types of Livecode coders,
those who..." situation!
as in "there are 10 kinds of people, those who understand binary, and those who don't."

or how about "there are 3 kinds of people, those who can count and those who can't."

-- Peter

Peter M. Brigham
***@gmail.com
http://home.comcast.net/~pmbrig
Peter Haworth
2012-10-19 23:11:16 UTC
Permalink
Peter,
You got it! Thanks for the script also (and Jacque). I have to admit I'm
not entirely sure of all the benefits of it but I'm sure they'll come
though when I give it a try.

Pete
lcSQL Software <http://www.lcsql.com>
Post by Peter M. Brigham
Post by Peter Haworth
Sounds like this is turning into a "There are 2 types of Livecode coders,
those who..." situation!
as in "there are 10 kinds of people, those who understand binary, and those who don't."
or how about "there are 3 kinds of people, those who can count and those who can't."
-- Peter
Peter M. Brigham
http://home.comcast.net/~pmbrig
_______________________________________________
use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your
http://lists.runrev.com/mailman/listinfo/use-livecode
J. Landman Gay
2012-10-20 00:15:44 UTC
Permalink
Post by Peter Haworth
Peter,
You got it! Thanks for the script also (and Jacque). I have to admit I'm
not entirely sure of all the benefits of it but I'm sure they'll come
though when I give it a try.
Mine is much simpler than the one Peter posted, he's added some stuff.
I've never had any trouble with commenting using the IDE shortcuts, for
example, so I don't have that in there.

But I use the quotes and parentheses and scriptpaint parts all the time.
For example, you type this and find out it doesn't parse right:

put the short name of cd i and cr after tList

and realize you need to force evaulation by putting parentheses around
"the short name of cd i" -- so you hilite it and type Cmd-Shift-9 (or 0,
either one) and it's done. Same for quotes.

More than anything I use the scriptpaint feature, which I admit wasn't
my own idea but I can't remember now where I got it. Instead of typing a
variable name, just point at it in some other part of the script and
type Cmd-Shift-space. In it goes. Works for a selection too; it will
replace your selection with the word you're pointing to. I have managed
to teach my left hand to hit all three keys at once without tearing any
tendons.
--
Jacqueline Landman Gay | ***@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Peter Haworth
2012-10-20 00:41:29 UTC
Permalink
Thanks Jacque, I plan to give this a whirl. This seems to
have usefulness whether explicit vars are in force or not.

By the way, what are the shortcuts for commenting? I haven't come across
them.


Having stirred up a hornet's nest with this issue, I think I will refrain
form starting another storm regarding code commenting :-)

Pete
lcSQL Software <http://www.lcsql.com>
Post by J. Landman Gay
Post by Peter Haworth
Peter,
You got it! Thanks for the script also (and Jacque). I have to admit I'm
not entirely sure of all the benefits of it but I'm sure they'll come
though when I give it a try.
Mine is much simpler than the one Peter posted, he's added some stuff.
I've never had any trouble with commenting using the IDE shortcuts, for
example, so I don't have that in there.
But I use the quotes and parentheses and scriptpaint parts all the time.
put the short name of cd i and cr after tList
and realize you need to force evaulation by putting parentheses around
"the short name of cd i" -- so you hilite it and type Cmd-Shift-9 (or 0,
either one) and it's done. Same for quotes.
More than anything I use the scriptpaint feature, which I admit wasn't my
own idea but I can't remember now where I got it. Instead of typing a
variable name, just point at it in some other part of the script and type
Cmd-Shift-space. In it goes. Works for a selection too; it will replace
your selection with the word you're pointing to. I have managed to teach my
left hand to hit all three keys at once without tearing any tendons.
--
HyperActive Software | http://www.hyperactivesw.com
______________________________**_________________
use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your
http://lists.runrev.com/**mailman/listinfo/use-livecode<http://lists.runrev.com/mailman/listinfo/use-livecode>
J. Landman Gay
2012-10-20 00:53:36 UTC
Permalink
Post by Peter Haworth
By the way, what are the shortcuts for commenting? I haven't come across
them.
Cmd-hyphen to comment, Cmd-Shift-hyphen to uncomment. It affects
whatever line the cursor is in; if you select multiple lines they are
all affected.

It's in the Edit menu when a script is open, but I notice the Shift
designator symbol has gone wonky, at least in rc-3.
Post by Peter Haworth
Having stirred up a hornet's nest with this issue, I think I will refrain
form starting another storm regarding code commenting :-)
The rule is: always do it or yoooou'llll beeee sowwwwwyyyy.
--
Jacqueline Landman Gay | ***@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Peter Haworth
2012-10-19 17:03:33 UTC
Permalink
messageBoxRedirect? I can find no mention of that in the dictionary. What
does it do?

I look forward to seeing your message box replacement Richard. I have that
as a future enhancement to my lcStackBrowser plugin but sounds like you may
have saved me the trouble!

Pete
lcSQL Software <http://www.lcsql.com>



On Fri, Oct 19, 2012 at 7:47 AM, Richard Gaskin
Post by Richard Gaskin
So a while back when I had a free Saturday I started work on my own MB
replacement, and these days it's much easier to do a graceful
implementation because we now have the messageBoxRedirect global property
(thanks for that one, Kevin - I'm making good use of it).
Richard Gaskin
2012-10-19 17:25:30 UTC
Permalink
Post by Peter Haworth
messageBoxRedirect? I can find no mention of that in the dictionary. What
does it do?
I look forward to seeing your message box replacement Richard. I have that
as a future enhancement to my lcStackBrowser plugin but sounds like you may
have saved me the trouble!
My bad: it's actually called "revMessageBoxRedirect".

And you're right: oddly, it isn't documented, but can potentially be
useful for other things than what it was originally implemented for, so
I just logged a request for its documentation:
<http://quality.runrev.com/show_bug.cgi?id=10481>

The revMessageBoxRedirect global property was originally added at my
request to overcome a limitation formerly in the engine which prevented
us from replacing the Message Box stack without crashing. I was
pursuing a path for migrating portions of the MetaCard IDE for use
within the LiveCode IDE, and this was preventing that work from going
forward.

Their solution for this far exceeded my expectations, and can be useful
for all sorts of MB replacements and diagnostic tools.

The revMessageBoxRedirect global prop defaults to empty, and when empty
any "put" commands have their output sent to the main field in a stack
named "Message Box" (and you really should use only LC's provided
Message Box stack, because I've found that attempting to replace it with
another of the same name on the fly is problematic).

But you can set the value of the revMessageBoxRedirect to the long ID of
any object, and after having done so that object will then receive a new
message, msgChanged, whenever any script triggers an action that would
normally put output into the Message Box, e.g.:

on msgChanged pMsg
put pMsg into fld "Messages" of stack "My Cool Message Box"
end msgChanged


Certainly a specialized need, which may be why they've never bothered to
document it.

But serious toolmakers will find it interesting, and it can lend itself
to certain types of logging solutions which can be useful and fun to build.

--
Richard Gaskin
Fourth World
LiveCode training and consulting: http://www.fourthworld.com
Webzine for LiveCode developers: http://www.LiveCodeJournal.com
Follow me on Twitter: http://twitter.com/FourthWorldSys
Peter Haworth
2012-10-19 18:18:28 UTC
Permalink
Richard,
Thanks for the explanation and QCC request to document it. Hopefully they
documentation update will include the msgChanged message too.
Pete
lcSQL Software <http://www.lcsql.com>
Post by Peter Haworth
messageBoxRedirect? I can find no mention of that in the dictionary.
Post by Peter Haworth
What
does it do?
I look forward to seeing your message box replacement Richard. I have that
as a future enhancement to my lcStackBrowser plugin but sounds like you may
have saved me the trouble!
My bad: it's actually called "revMessageBoxRedirect".
And you're right: oddly, it isn't documented, but can potentially be
useful for other things than what it was originally implemented for, so I
<http://quality.runrev.com/**show_bug.cgi?id=10481<http://quality.runrev.com/show_bug.cgi?id=10481>
The revMessageBoxRedirect global property was originally added at my
request to overcome a limitation formerly in the engine which prevented us
from replacing the Message Box stack without crashing. I was pursuing a
path for migrating portions of the MetaCard IDE for use within the LiveCode
IDE, and this was preventing that work from going forward.
Their solution for this far exceeded my expectations, and can be useful
for all sorts of MB replacements and diagnostic tools.
The revMessageBoxRedirect global prop defaults to empty, and when empty
any "put" commands have their output sent to the main field in a stack
named "Message Box" (and you really should use only LC's provided Message
Box stack, because I've found that attempting to replace it with another of
the same name on the fly is problematic).
But you can set the value of the revMessageBoxRedirect to the long ID of
any object, and after having done so that object will then receive a new
message, msgChanged, whenever any script triggers an action that would
on msgChanged pMsg
put pMsg into fld "Messages" of stack "My Cool Message Box"
end msgChanged
Certainly a specialized need, which may be why they've never bothered to
document it.
But serious toolmakers will find it interesting, and it can lend itself to
certain types of logging solutions which can be useful and fun to build.
--
Richard Gaskin
Fourth World
LiveCode training and consulting: http://www.fourthworld.com
Webzine for LiveCode developers: http://www.LiveCodeJournal.com
Follow me on Twitter: http://twitter.com/**FourthWorldSys<http://twitter.com/FourthWorldSys>
______________________________**_________________
use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your
http://lists.runrev.com/**mailman/listinfo/use-livecode<http://lists.runrev.com/mailman/listinfo/use-livecode>
Peter Haworth
2012-10-19 17:06:06 UTC
Permalink
That explains a lot, thanks Richard. I admit I had not been understanding
your posts but I think this clarifies it. I assume this is what happened
when explicit variables were first implemented but that now the situatio is
as you described in your email with the script of the "Apply" process.
Pete
lcSQL Software <http://www.lcsql.com>



On Thu, Oct 18, 2012 at 8:51 PM, Richard Gaskin
Remember that LiveCode is dynamically compiled - the only copy of a script
stored with a stack is the source copy, not any tokenized version. So
whenever you open a stack, as part of the unpacking its scripts are
dynamically compiled - and that's when the compilation error will occur.
Peter Haworth
2012-10-18 20:20:55 UTC
Permalink
Hi Richard,
I think perhaps I didn't explain what I am trying to achieve very well.

I certainly don't want to force anyone except me into using explicit vars,
or strict compile mode, or whatever the correct term is, but I do want to
use them when developing on my computer. The scheme I had in mind would
only come into play if the stack was not running as a plugin and it
was running on my computer (although I haven't figured out the best way to
check the latter). I just want to find a controlled way of switching in
and out of strict compile mode, stack by stack and without having to
remember which stacks I want to be in that mode.

I think this is probably at the point where it would be faster to set the
Strict Compile mode preference to true and spend a few hours converting all
my stacks. The one thing that would really help in that regard is if there
was a way to have the compile/Apply function list all the errors it found
instead of stopping at the first one, but I'm sure that can't be done.


Pete
lcSQL Software <http://www.lcsql.com>
Post by Richard Gaskin
I wouldn't worry too much about making your scripts "compliant" with
explicitvars.
There are probably some users who run with it on, but not many.
J. Landman Gay
2012-10-18 20:46:58 UTC
Permalink
Post by Peter Haworth
I certainly don't want to force anyone except me into using explicit vars,
or strict compile mode, or whatever the correct term is, but I do want to
use them when developing on my computer.
I'm still trying to figure out why anyone would want to. Some people
insist it's a better way to work, but I've never seen any advantages,
only restrictions. The occasional typo isn't worth the trouble to me.
--
Jacqueline Landman Gay | ***@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Ben Rubinstein
2012-10-19 18:02:16 UTC
Permalink
Post by Peter Haworth
I certainly don't want to force anyone except me into using explicit vars,
or strict compile mode, or whatever the correct term is, but I do want to
use them when developing on my computer.
I'm still trying to figure out why anyone would want to. Some people insist
it's a better way to work, but I've never seen any advantages, only
restrictions. The occasional typo isn't worth the trouble to me.
You obviously make fewer typos than me!

I am one of these (apparently rare?) people who do try to run with it on - and
indeed this only causes me problems, in general, with my own old code. I've
found that it's worth it - those typos may be occasional, but the bugs they
cause can be subtle and hard to track down.

YMMV, of course.

Ben
Ben Rubinstein
2012-10-19 18:06:56 UTC
Permalink
IIRC, explicitvars were seen as too cumbersome to work with, since as a truly
global property the required that EVERYTHING you're using comply with it, and
too many plugins didn't.
I don't think the problem was with plugins, so much as the basic IDE. And as
one of those in the let-the-compiler-help-me camp, I spent some time years ago
trying to persuade RunRev to invest the effort in making the IDE
explicitVars-clean, so that we could then safely switch it on for ourselves.

In the end they implemented the cunning hack round the script editor instead,
which gave us that ability and indeed something better... but dodged the issue
of cleaning up the IDE. I remain convinced that if RR did put the time in to
make the IDE ev-clean, they would in the process fix at least a few bugs. But
I can't actually pretend that it should be a priority for their overstretched
team now (good introductory job for a new hire, perhaps?)

Ben
Continue reading on narkive:
Loading...