Checking to see if a variable is defined?

Freeform discussion about anything related to modding Transcendence.
Post Reply
gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

I'm trying to use boundp to see if a variable is defined, but Transcendence gives me an error if I try to:
unknown function [boundp]
More specifically, I created a test device to see what would happen if I tried to use boundp. Here's the relevant part of the code. Is there a better way for me to go about this?

Code: Select all

		 <Invoke>
			
			(block Nil			
				(if (boundp 'auto-mode-alist)
					(objSendMessage gSource Nil "Variable is defined")
					(objSendMessage gSource Nil "Variable is NOT defined")
					)
				)

			</Invoke>

Here's where I got the idea to use the function:
http://ergoemacs.org/emacs/elisp_check_defined.html
User avatar
AssumedPseudonym
Fleet Officer
Fleet Officer
Posts: 1190
Joined: Thu Aug 29, 2013 5:18 am
Location: On the other side of the screen.

 The problem is that Transcendence uses a customized version of LISP, not the “real” version, so a lot of things that would work in “real” LISP won’t work in Transcendence. You can check what functions are available to use and usually how to use them here.
 As for checking whether a variable is defined:

Code: Select all

<Invoke>
  (block Nil         
    (if (isError variableName)
      (objSendMessage gSource Nil "Variable is NOT defined")
      (objSendMessage gSource Nil "Variable is defined")
    )
  )
</Invoke>
 That should do the trick.
Image

Mod prefixes: 0xA010 (registered) and 0xDCC8 (miscellaneous)

My mods on Xelerus: Click here!

Of all the things I’ve lost in life, I miss my mind the least. (I’m having a lot more fun without it!)
gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

That worked perfectly. Thank you!
Arkheias
Commonwealth Pilot
Commonwealth Pilot
Posts: 95
Joined: Mon Jun 02, 2014 8:06 pm

Alternatively, if you need something more specific:

Code: Select all

<Invoke>
  (block Nil         
    (if (isInt variableName)
      (objSendMessage gSource Nil "Variable is an integer")
      (objSendMessage gSource Nil "Variable is NOT an integer")
    )
  )
</Invoke>
Cabbage Corp, the only mod with cabbages!

Please feel free to submit bug reports or issues related to the Cabbage Corp mod on the GitHub page, the forum thread, in a private message or even on the Xelerus page. Suggestions are fine too.
Post Reply