Page 1 of 1

fun with setq and set

Posted: Thu Aug 21, 2008 3:54 pm
by Betelgeuse
They just put the second argument into the first argument.
A change from the old setq in .99 I just noticed is you don't need to make the variable before hand.

for example this is valid in .99 but not .98

Code: Select all

(block nil
	(setq bob 9)
	bob
)
Set is also a fun little thing that allows you to put in a string to name the variable instead of the variable itself. There are several uses of this one is making or storing variables in a series like armor1-6 without a list. The other thing that it allows you to do is store or pass in variables to use. Like if you want to use the same function but storing in different global variables. (see intInstallDevicePrep in Transcendence.xml for an example)

Posted: Thu Aug 21, 2008 6:04 pm
by digdug
really ? no more need to declare a variable at the beginning of the block ?
no more (block (bob) ... ?

Posted: Thu Aug 21, 2008 6:23 pm
by george moromisato
digdug wrote:really ? no more need to declare a variable at the beginning of the block ?
no more (block (bob) ... ?
If you don't declare a variable at the beginning of a block, then it becomes a global variable.

Try not to use too many global variables because they use up memory.