fun with setq and set

This is a moderated forum that collects tutorials, guides, and references for creating Transcendence extensions and scripts.
Post Reply
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

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)
Crying is not a proper retort!
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

really ? no more need to declare a variable at the beginning of the block ?
no more (block (bob) ... ?
george moromisato
Developer
Developer
Posts: 2997
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

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.
Post Reply