Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / #CONSTANT question

Author
Message
Vandetta
21
Years of Service
User Offline
Joined: 17th Dec 2002
Location:
Posted: 22nd Dec 2002 13:18
Is it possible to assign a value to a constant from a value returned from a function? Example:

#CONSTANT MyConst TIMER()

If not, is it possible to make a variable that can only be written to once?
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Dec 2002 13:20
No. All #constant does is a simple text substitution. Using your example, everywhere you use MyConst in your code will be replaced during compilation by TIMER().

If you want a write-once variable, you are going to have to control it yourself - maybe in a function.
n3t3r453r
21
Years of Service
User Offline
Joined: 8th Nov 2002
Location: Russia
Posted: 22nd Dec 2002 13:40
OK. And are there any other preprocessor functions in DBpro, like in C/CPP such as #error or pragma or #define and ect.?
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Dec 2002 13:44
Just #constant and #incldue at the moment I think.

I would be great to have a proper pre-processor so that you could have different sections of code, depending on compiler options. And if it was a stand-alone pre-processor, it could easily be used with DBv1 too.

Login to post a reply

Server time is: 2024-05-04 23:48:15
Your offset time is: 2024-05-04 23:48:15