|
Deutsch |
Home - - POV-Ray Details - About Variables Built-in Identifiers > #declare, #local Expressions - A short |
- Why is it so helpfull to declare variables instead of using only floats? Arguments: Easier handling, because less to write! It's basic for modular working! Who use it is more sucessful! - Better Overview! (Don't forget to add some explaining comments!) [Sure! You remember also 8 weeks later the meaning of 'A', ... but, they all say that! :-) ] What should we '#declare'? - Values, which were used at many statement - for easier change/adapting - that gives more indepency in design. If we want to changes a value, which is needed several times in a scene, we need only to change it at one place! (faster + less error sources!) Example: Height of a column, textures, ... - Textures, before using them in an object. - Why is it so helpfull to declare textures before using them at an object? - Try to declare all textures used in a scene somewhere before the objects. Doing so allows us very easily to change some textures later. - Creation of new objects for multible use in a scene Erzeugung von neuen Objekten für mehrfachen Gebrauch in einer Szene Why is it so helpfull to declare objects which are used several times? Arguments: - less to write, specially by changing an object! - prefabricated objects allow modulare working which is much clearer than many multiple descriptions of parts. '#declare' or '#local'? - The difference between '#declare' and #local'. Local identifiers are important to avoid Identifier Name Collisions. Inside of an include file or inside of a macro (between the word '#macro' and the according '#end') declaring an identifier by #local has no effect on identifiers of the same name declared outside of this include file or macro. That means it temporary overrides an outside identifier of the same name without destroying it's value outside. After the inclusion of the include file or after the end of the macro all there declared local identifiers are destroyed. A '#local' used in the main scene file is identical to #declare (if it's not in an include file or macro). As a result: We can use in a macro or in an include file the identifier names that are already used in the main scene file or in other macros or include files without destroying the according identifier values in the main scene file. Destroying Identifiers User defined identifiers can be destroyed with "#undef MyVariable" . User defined identifiers can be created dependent on if they were not defined: "#ifndef ( MyVariable ) #declare MyVariable = 0.5; #end" This is an elegant method to create objects in include files with default values, which can be overwritten by the user, if its necessary. See also Check for Existence |
© Friedrich A. Lohmüller, 2011 |