Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Any way to to include command line options into the code?
#2
The are called #pragmas (this is a standard compiler feature on most compilers). Instead of using #option, use #pragma option.

Unfortunately, YES, this is very undocumented. See how library/*.bas uses them. The reason they're undocumented is because they're being worked on and refactored at the moment.

A brief explanation follows:

To change any option use
Code:
#pragma option <optionName>=Value
For boolean options, you can use either "TRUE" | "FALSE" or 1 | 0

Example:
Disabling case-sensitive identifiers:
Code:
#pragma option case_insensitive = TRUE
Some times you might want to save current option status, to be recovered later. There is a "Stack" for this. So, to save a current option do:
Code:
#pragma push(case_insensitive)
#pragma option case_insensitive = TRUE
...
...
#pragma pop(case_insensitive)
Note: wrong push/pop sequences will lead to unpredictable results (can even crash the compiler).

The above technique is used in many library/*.bas files to make some functions case insensitive. For example, POINT and SCREEN$ functions came with Sinclair BASIC and they must be case insensitive. So saving the case_insensitive option temporarily we won't interfere with user's options status Idea

The options list grows almost day by day. But here are the most common and useful of them (at the moment), 'NAME', type, default value:
  • 'optimization', int, 0
  • 'case_insensitive', bool, False
  • 'array_base', int, 0
  • 'byref', bool, False // Whether function parameters are byRef or byVal if this is ommited
  • 'max_syntax_errors', int, DEFAULT_MAX_SYNTAX_ERRORS
  • 'string_base', int, 0
Some options (e.g. optimization) do not have effect until the parsing phase has ended. So using #pragma option with them makes no sense.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)