Page 1 of 1

Use OPTION to Include a module

Posted: Tue Feb 28, 2017 11:00 am
by Coccoliso
Hi at all,

there is a way to specify a module to be included through OPTION ?

Code: Select all

#option LOGO = "mylogo.jpg"
#if IsOption(LOGO)
    Public Const cLOGO_IMAGE_NAME  = LOGO
#else
    #error "Undefined option LOGO"
#endif
.. this works perfectly and I can refer to the file by replacing his name with cLOGO_IMAGE_NAME .
But

Code: Select all

#option MY_MODULE= "mymodule.bas"
#if IsOption(LOGO)
    Public Const cMY_MODULE  = MY_MODULE
#else
    #error "Undefined option MY_MODULE"
#endif

Include cMY_MODULE 
.. does not get the desired result, and the module is not included.

There is a way to do so? Also with some macro?

Thanks to all !

Re: Use OPTION to Include a module

Posted: Tue Feb 28, 2017 11:26 am
by Coccoliso
Hi,

I found the solution looking Firewing and it's all easier than expected and if it helps someone else :

Code: Select all

#option MY_MODULE = mymodule   // (module name without .BAS and spaces)
or

Code: Select all

#option MY_MODULE = "mymodule.bas"
.. and now ..

Code: Select all

#If Not(IsOption(MY_MODULE )) 
    #error "Undefined option MY_MODULE"
#endif

Include MY_MODULE                 // Directly refer to an #OPTION

Re: Use OPTION to Include a module

Posted: Tue Feb 28, 2017 6:54 pm
by octal
Check Jerry's last USB library. If I remember, he use options to include various modules depending on user choices.