I am trying to figure out how OMIT works - better said I want to eventually create a template in which one can define a value - but I want to have a fallback value, or better said a default value for the equate if it’s not set - but I can’t get the following piece of code to work - it throws a Unknown Identifier unless I remove the OMIT (comment it out is enough`
The above was inside my .inc file which I include - but it does act the same inside the Global Data section - my program is currently Clarion 8 (Legacy)
The thing I don’t understand is that it should only be omitted when it has a value other than 0 - it’s 0 by default if not defined according to the documentation - but clearly it does have a value, otherwise it wouldn’t be omitted right?
Read the help carefully. If your Expression is just an Equate Label without an operator (no = <> ) e.g.
OMIT('xxx', _IncludeMyCode_)
xxx
Of _IncludeMyCode_help says
If the Expression contains an EQUATE that has not yet been defined, then the referenced EQUATE is assumed to be zero (0). COMPILE and OMIT are opposites.
Possibly you didn’t understand, but you’re essentially writing OMIT('*My Equate*', 'I did something' )
Now, when interpreting the string 'I did something' as a NUMBER, it becomes 0
as the first character is a capital ‘i’ which which is neither a digit nor white space
I’ll repeat myself again as I understand a STRING is not a NUMBER - the second example, with MyEquateOverride doesn’t work either - I repeated it below
Inside After Global Includes
MyEquateOverride EQUATE(1)
MyEquate EQUATE('I did something')
INCLUDE('MyInclude.inc'),ONCE
The way it looks to me is you have Omit( ,1) so the EQUATE('TEST') should be omitted i.e. not compiled. If it did compile it would cause a compile error because MyEquate is defined twice.
Your snippets look ok. The best way to resolve this is to zip up a complete example project and attach it so others can build exactly what you have.
Sorry, I see now that you’re using ,MyEquateOverride as the expression on the condition. My apologies.
Where does MyInclude.inc appear?
Are there multiple locations?
Is one of the locations inside of a module that has an empty MEMBER statement?
If so, then please be aware that the module with empty member statement doesn’t see the global scope.
Note, its often better to use pragma defines for the conditions on omit/compiles
as they you don’t have scoping problems Note: pragma can be associated with a single module
What are you expecting to happen?
Compile time warning about a duplicate label ?
Create a new file with a .PR or .PRJ extension
I put it in the same folder as my .CWProj
add lines like #pragma define(MyEquateValue=>On) #pragma define(MyEquateValue2=>1)
On is the same as 1
Off is the same as 0
Then In the SV.IDE
— View > Solution Explorer
------ Highlight “Projects to Include”
---------- Right Click > Add Project to Include
-------------- In File Dialog set File types to “Legacy Clarion Files”
------------------ Select the .PR|.PRJ file you created