[Migrated content. Thread originally posted on 05 February 2003]
Has anyone had any success using/making the precompiler? I would like to conditionally compile certain files based on certain circumstances.In particular, I am considering using the I$IO routine as a general replacement for all file actions. Using it is much less tedius than writing the select, file descriptor, etc. It would also provide the nice benefit of being able to access files by a variable filename (and with a little work, by field name via a special call) I would like to conditionally compile the .fd files (using C preprocessor syntax).
#ifdef _FILE-CONTROL
FD MY-FILE
LABEL RECORDS ARE STANDARD
RECORD CONTAINS 300 CHARACTERS
DATA RECORD IS MY-FILE-RECORD.
01 MY-FILE-RECORD.
05 MY-KEY-1.
...
#endif
In the file control section, I could
#define _FILE-CONTROL
In FILE-CONTROL, in front of the copy commands, I could
#define _FILE-CONTROL
In working storage, I could
#undef _FILE-CONTROL
This would allow fd files to be included as regular file descriptors or as working storage items based on the need. Unfortunately, as far as I can tell, conditional compilation is only possible in the following circumstances:
1. using -Si compile time switch. This is pretty much useless for this application because you can't change behavior at compilation time.
2. REPLACE command. The replace command has some crippling limitations, notably it does not apply to COPY'd files. It is also not switchable at compile time.
3. Custom preprocessor. AcuCorp has an interface for a custom preprocessor. This would easiest and most direct way to solve the problem, but experimentation with a quick and dirty processor (it just echoed the text to the compiler) showed that:
a. you lose ability to jump to compiler errors
b. compilation takes about 10 times as long
c. for some strange reason, sometimes when doing this compiler misses some copy books.
All togehter this makes a preprocessor option not usable.
If the compiler used stdin/stdout, the problem will be simple, as I could front end the compiler with a special program. Unfortuantely it doesn't...the filename is passed in as a compiler parameter. :(
Any suggestions?