Jump to content
Sign in to follow this  
Thomymaster

AU3Check error on constant declaration

Recommended Posts

Thomymaster

Hi everybody

 

I want to declare a constant according to values of an evaluation, like this:

 

    Switch $iTemp
        Case -1 And @error=6
            Global Const $g_iOption1="-1"
        Case 0
            Global Const $g_iOption1="0"

        Case else
            Global Const $g_iOption1="1" 
    EndSwitch

 

However when i do this, my code checker (AU3Check 3.3.13.19) tells me:

 

error: $g_iOption1 previously declared as a 'Const'.

 

But the syntax i use is correct. What can i do?

 

Best,

Thomas

 

 

Share this post


Link to post
Share on other sites
Jos

Au3check doesnt run your script aso merely tells you that you have multiple definitions of the same constant.

It feels you are trying to emulate a directive but you really should avoid using a constant when you still have script logic to set the variable.

jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
jaberwacky

You have this option too:

Global Const $g_iOption1 = _name_of_function($iTemp, @error)
 
Func _name_of_function(Const $name_of_variable, Const $error)
    Switch $name_of_variable
            Case -1 And $error = 6
                Return "-1"
                
            Case 0
                Return "0"

            Case else
                Return "1" 
    EndSwitch
EndFunc

 

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
Sign in to follow this  

×