Jump to content

AU3Check error on constant declaration


Recommended Posts

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

 

 

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...