Code blocks

A code block is a unit of code executed on the call of an event or a flow-control statement.  It is much like a function or subroutine in conventional programming.    

 

Code blocks are illustrated in these moddable functions Utilities

Prim Coloring

A code block follows the calling statement and is demarked by braces at the beginning and end of the block. 

The good news for script modding is that you will often be able to make the changes you want by replacing a whole code block. 

{code block starts
code block line 2
code block ends on line 3}
A brace is often placed on a line by itself for visibility.  I do that in some cases, but often find that a more compact script is easier to work with.  Especially for the copy-paste moves that are the heart of script modding. 

In these web presentations, I use the table structure and indenting to show the code block structure

 
Variables defined within a code block are local to that code block and not known to other code blocks.  To transfer values from one code block to another, use global variables. Global variables
Common error: variable not defined within scope.  
The Thinkerer 09/13/2008
Copyright (c) D. F. Dansereau & S. H. Evans

Site Map

Where start?

LODScr
Famous fables