The CodeBlock Program
"A Visual FoxPro Runtime Interpreter"
[Current Version]
[Download]
[Revision History]
[Original 2.6 Version]
CodeBlock is a runtime FoxPro interpreter. It allows you to execute
blocks of uncompiled code that resides in memo fields, files, or
character strings, even in the runtime environment. There are two versions
available here and both have the same file name, CODEBLCK.PRG.
A new set of related tools has been created by
Randy Pearson for Visual FoxPro (VFP) 5.0 and later. Like the
original CodeBlock program, this is also in the
public domain. The tools contains three (3) separate
components:
- A CodeBlock execution class, which contains
the entire "engine" that acts as the
VFP runtime interpreter. This class
"cusCodeBlock" can be used entirely on
its own in cases where you have a source of
existing blocks of VFP code to execute at
runtime. Although there are many new properties
available for customization, TEXTMERGE processing, and error handling,
executing this class can be as simple as:
- SET PROCEDURE TO CodeBlck ADDITIVE
- oCodeBlock = CREATEOBJECT(
"cusCodeBlock")
- oCodeBlock.SetCodeBlock(
<YourTable.YourMemoFieldWithCode>)
- oCodeBlock.Execute()
- A form for testing CodeBlock by entering and executing
blocks of code named
"frmCodeBlockEditor". This form class
includes many new features such as modeless
operation, dynamic resizing, font selection, and
the ability to "test compile" your code
block from the VFP development environment. To
execute the code blocks you enter, you also need
the execution class discussed above. Calling this
editor is also simple:
- SET PROCEDURE TO CodeBlck ADDITIVE
- oCodeEditor = CREATEOBJECT(
"frmCodeBlockEditor")
- oCodeEditor.Show()
- Wrapper code in CodeBlck.PRG that accepts the
same parameters as the old 2.6 version of CodeBlck.PRG and calls
either of the above 2 classes as needed. This
wrapper program allows for in-line calls to the
CodeBlock classes and is included to allow
call-level compatability to developers who used the
original CodeBlck.PRG program that way. Note that
this program switches the editor class to modal,
if called, since a single return value to an
inline function may be required.
The latest version of CODEBLCK.PRG
is available for download here.
The following lists some of the
major changes since the 2.6 version. Changes are in reverse
chronological order. Please see the notes at the bottom of the PRG
itself for a much more thorough revision history.
- October 1998: Support for LOCAL ARRAY command, improved error handling
when errors occur in TEXT blocks or evaluated expressions.
- June 1998: Added limited support for FOR EACH. Added limited support
for #DEFINE, #IF, #INCLUDE, and some other compiler directives.
- May 1998: Major re-write that includes pre-processing the user's code
for greatly enhanced performance and error handling. Added support for LOCAL
declarations by implcitly treating LOCAL's as PRIVATE's to avoid scope
problems in recursive calls. Added implicit PRIVATE variable initialization.
The original program, CODEBLCK.PRG, is a "runtime
interpreter" of structured Microsoft FoxPro 2.6
code. That program can still be downloaded here. This
program has been modified slightly over the years
since its original publication in FoxTalk (see reference), but is still
fully compatible with FoxPro 2.6 (all platforms) and
Visual FoxPro. Extensive notes and calling syntax is
included in the program file itself.
|