libdatabase : connection problem
Alex Tweedly
alex at tweedly.net
Mon Aug 29 05:54:55 EDT 2005
Dan Shafer wrote:
> Off-hand I spotted a couple of potential problem spots (haven't spent
> a lot of time analyzing whether these are the only problems):
>
> On Aug 28, 2005, at 2:46 AM, Revolution wrote:
>
>> Sunday, August 28, 2005 12:45:34 PM (GMT +02:00)
>>
>> event from button :
>>
>> local tDbA = ""
>> local i = 0
>> local tDataA = ""
>
> The above lines are doing nothing for you because they are incorrect
> syntax for Revolution. The expression "i = 0" evaluates to either
> true or valse but does nothing with the result. IF what you intend to
> do here is to initialize local variables, then you need the slightly
> more verbose:
>
Sorry, Dan, but the above *is* correct syntax, and does do what you'd
expect.
From the docs:
> Declares one or more local variables and assigns initial values to them.
>
> local variablesList
>
> local currentStatus -- creates one local variable
> local thisThing,thatThing,theOtherThing -- creates three variables
> local A=1,B=2,C=3 -- creates variables with initial values
>
and
> Description
> Use the local command to define a local variable for a handler, or to
> define a script local variable that is shared between all the handlers
> in a script.
>
> Parameters:
> The variablesList consists of one or more name=value pairs, separated
> by commas:
> * The name is any string.
> * The value is any literal string.
> The value is optional; you can specify just the variable name. In this
> case, the specified local variables contain empty when created.
>
[end of docs quotation]
Dan said:
> Having said that, it is strictly optional in Transcript to use the
> word "local" and I'd venture to say that the vast majority of us
> never use it. Variables are local unless they're explicitly defined
> to be global. In that case, you eliminate the three "local" lines in
> the above and just assign the initialization values to the variables
> with the same effect.
>
I use it often - mostly because my typing is bad and I often mistype
variable names - therefore I always use explicitVariables to help detect
my typos - and therefore need to use "local", but also I use it to
initialize locals as above. (And you can use the initialization form to
assign values to script-local variables too).
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.16/83 - Release Date: 26/08/2005
More information about the use-livecode
mailing list