Unfortunately you cannot nest CFOR statements, because CNEXT_ can only hold one definition. On the plus side, the macro is designed to prevent nesting attempts from compiling:
- CFOR expects the CNEXT_ macro not to exist. If you try to nest CFOR (and the 'step' statement is different), you will get a Duplicated Definition error.
- CNEXT_ #undef's itself when used, ensuring that it can't be used afterwards without using CFOR again.
For convenience, a CNEXT #define is also included, to prevent having to put '()' after it.
A couple of examples:
Code: Select all
start: while cond
#define CNEXT CNEXT_()
dim i as integer
CFOR(i = 0, i < 10, i += 1)
CFOR(i = 1, i <= 256, i shl= 1)