When you edit or inspect a code block, a code block information box will appear similar to the following:
This section shows the variables that are within the scope of the codeblock. These variables can be variables that are detached, sometimes referred to as "bound" variables - these are variables that were in scope when the code block was created and the code block holds a copy of the variables. If the code block is created using a macro, then there will be no variables appearing here. │ │ │ ┌───────────────────────────────────┴─────────────────────────────────┐ ┌──────────────────────────────── CBLOCK ───────────────────────────────┐ │Variable Contents │ │nArea 35 │ │aRay {1...9} │ │I 24 │ │CBLOCK {|X, Y| QOUT("Hello World")} │ │bDetached {|| QOUT("Hey Look at me I'm detached")} │ │ │ │ │ ┌├──────────────┬────────────────────────────────────────────────────────┤┐ ││Block Locals │Defining Source File: TEST.PRG ││ ││X │ In Function: MAIN ││ ┌┤│Y │ At Line: 38 │├┐ │││ │ Detached: No │││ │└├──────────────┴────────────────────────────────────────────────────────┤┛│ │ │Code Block Code Dump ││ │ │{|X, Y| QOUT("Hello World")} ││ │ │ ││ │ │ ││ │ │ ││ │ └───────────────────────────────────────────────────────────────────────┛│ │ └────────────────────────────────┬────────────────────────────────────┛ │ │││ │This section contains a dump of the codeblock code that is run when the│ │codeblock is evaluated. If the code block can be deciphered, the code is│ │shown. If it cannot be shown then it is broken down into hex'n'text│ │sections. This is meaningful to those sad people among us who understand│ │these types of things!!│ ││ └───This section will contain the names of any block variables. Block│ variables are temporary variables that are declared within the ||│ characters of the codeblock when it is created or declared.│ │ This section will contain information regrading the nature of the code───┛ block. A Detached code block is one that contains information about variables that are no longer in scope. For further information refer to the Notes section below.
You can completely replace the contents of a codeblock (along with most other variables) by using the Command Window. To replace a codeblock you will need to use the command window to assign a new codeblock to the variable. For example:
cBlock := {|| QOUT('A Codeblock')}
Notes:
There are four different types of code blocks:
1. Detached code blocks - These are code blocks that make use of local variables from a specific level in the stack (external to the code block). In this case, the code block takes a copy of the variables at the specific stack level.
2. Semi-Detached code blocks - These are similar to detached code blocks, except that the variables are still in scope (at the current level in the stack). In this case the variables are copied into the code blocks, but the values have not yet been copied.
3. Non-Detached code blocks - These are codeblocks that do not use any external variables.
4. Macro'd code blocks - These are code blocks that have been brought into existance using a macro. The folllowing notes need to be kept in mind when viewing code blocks created with a macro:
i) Code blocks created with macros never contain any references to local variables - hence the Variables section of the code block viewer will be empty.
ii) Code blocks created with macros never contain real names for block locals - those that are created within the code block ||'. Instead they will appear within the Block Locals section of the code blocks viewer as BLOCK LOCAL 1, BLOCK LOCAL 2 etc.
iii) Code blocks created with macros do not contain line number information.