Jump to content
spacegremlin

const variable

Recommended Posts

basicly a simple question, but i dont know.

I want to place TESTVARIABLE there, so i can place the value of that somewhere else.
but if i use this i got an error.
because if you would do this in a define command, it does work.


  const MODULE_CONTENT_I_TITLE_DESCRIPTION  = 'link "blablabla'.TESTVARIABLE.'" end';
  
thank you

    
    
    
    
    
    

Edited by spacegremlin

Share this post


Link to post
Share on other sites

You can only use const in global or class context, not inside a function.  So if you have something like

function do_stuff() {
  const WHATEVER = 'whatever';
}

you'll get an error. 

You also can only do const with things that can be done at compile time.  So

function do_stuff() {
  return 'whatever';
}

const WHATEVER = do_stuff();

for anything that needs to be calculated at run time.  The define is done at run time, so it doesn't care about that. 


Always back up before making changes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×