put the filename = error

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Preston Shea
Posts: 73
Joined: Sat Apr 08, 2006 6:51 pm

put the filename = error

Post by Preston Shea » Sun Feb 01, 2009 1:43 am

This button script works great:

on mouseUp
put the filename of this stack into msg
end mouseUp

but this button script produces and error:

on mouseUp
put the filename of this stack into nameToSave
end mouseUp

here's the error:
button "Answer File": compilation error at line 2 (Chunk: can't create a variable with that name (explicitVariables?)) near "nameToSave", char 35

what gives?
In nova fert animus mutatas dicere formas corpora.

gmccarthy
Posts: 62
Joined: Sat Feb 17, 2007 4:56 am

RE: put the filename = error

Post by gmccarthy » Sun Feb 01, 2009 2:26 am

With the global explicitVariables set to true local variables must be explicitly declared with the local command.

Try the following:

on mouseUp
local nameToSave
put the filename of this stack into nameToSave
end mouseUp


on mouseUp
set the explicitVariables to false
put the filename of this stack into nameToSave
end mouseUp


Gerard McCarthy

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Sun Feb 01, 2009 10:51 am

With the global explicitVariables set to true local variables must be explicitly declared with the local command.
What Gerard is saying is that in the preferences under 'script editor' 'strict compilation mode' is turned on.
Rev then enforces that you declare variables as Gerard showed. If you turn this option off your script compiles without the error. It is a way to protect you from typos in your script since if you misspell a variable name in a script it will alert you to it since you did not declare it. Misspelled variable names are hard to debug as a typo may be hard to detect.
Also this option forces you to enclose literals in quotes.
I don't use the 'strict compilation mode' since I am too lazy to declare all the variables, but that has a downside as noted above. I do enclose literals in quotes because it can get really messy without.
regards
Bernd

Preston Shea
Posts: 73
Joined: Sat Apr 08, 2006 6:51 pm

loccal variables

Post by Preston Shea » Sun Feb 01, 2009 1:57 pm

Thanks for the immediate rescue. I'm an old Hyper Carder who uses Revolutionn on and off. The amazing feature growth of the system leaves me dazzled.
In nova fert animus mutatas dicere formas corpora.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Sun Feb 01, 2009 6:37 pm

In nova fert animus mutatas dicere formas corpora.
to which I reply
quamvis sint sub aqua, sub aqua errordicere temptant
which you could translate with a grain of salt as
although they are all under water, they throw an error (the bugs)
my oh my, what would Ovid say to that? Was he using Hypercard? Probably the random syntax generator which shipped with version .01. It allowed to randomly switch the order of subject object and verb on the fly as well as providing sophisticated interposition of relative clauses into the main clause with no discernible pattern.
regards
Bernd

:)

Preston Shea
Posts: 73
Joined: Sat Apr 08, 2006 6:51 pm

Post by Preston Shea » Sun Feb 01, 2009 9:30 pm

bn wrote:
In nova fert animus mutatas dicere formas corpora.
to which I reply
quamvis sint sub aqua, sub aqua errordicere temptant
which you could translate with a grain of salt as
although they are all under water, they throw an error (the bugs)
my oh my, what would Ovid say to that? Was he using Hypercard? Probably the random syntax generator which shipped with version .01. It allowed to randomly switch the order of subject object and verb on the fly as well as providing sophisticated interposition of relative clauses into the main clause with no discernible pattern.
regards
Bernd

:)
A bit of humanist wit and much appreciated, along with the technical help. My quote of Ovid refers to the RunRev project I have been working on for too many years, conversion of the textbook Latin Via Ovid to an interactive stack of stacks.
In nova fert animus mutatas dicere formas corpora.

Post Reply