Just goes to show you. I learn something every day about this language.
It would never have occurred to me to use an equal sign that way in
Rev. I'm almost sorry I know that!
:-D
Dan
On Aug 28, 2005, at 8:46 PM, Trevor DeVore wrote:
On Aug 28, 2005, at 6:12 PM, Dan Shafer 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:
local tDbA
put empty into tDbA (or you can use double quotes instead of "empty")
local i
put 0 into i
local tDataA
put empty into tDataA
Dan,
Declaring a variable as local initializes to an empty variable. So -
local tDbA,tDataA
would initialize both variables as empty. For example:
on doSomething
local tVar
put tVar &cr& tVar2
end doSomething
Would display and empty line, a return and "tVar2" on the second
line in the message box. You can initialize a variable to value as
well.
on doSomething
local i = 0
put i
end doSomething
would print 0 in the message box.
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.
The person probably got the code from original libDatabase example
code. Back in the day I used to initialize variables with ""
before I knew that just declaring them set them to empty. Now I
just define all local variables en mass:
local tVar1,tVar2
local tDataA,tWhateverA
For integers, such as i, I used to always initialize them to 0.
Now I only initialize them with 0 if there is a possibility of a
math error later on in the code that could be caused by having a
non-numeric value.
It is true that most people don't declare local variables but I do
in all of my code.
--
Trevor DeVore
Blue Mango Multimedia
[EMAIL PROTECTED]
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution