for 
    
    
    proc f(size=1) =
        if size == 1:
            var
                widFrame = 320
                hiFrame = 200
        else:
            var
                widFrame = 3200
                hiFrame = 2000
        
        echo (widFrame, hiFrame)
    
    f()
    
    
    Run

I get 
    
    
    t_bug.nim(11, 11) Error: undeclared identifier: 'widFrame'
    
    
    Run

Why?

I know there is a solution 
    
    
    proc f(size=1) =
        var
            widFrame:int = 0
            hiFrame:int = 0
        if size == 1:
            (widFrame, hiFrame) = (320, 200)
        else:
            (widFrame, hiFrame) = (3200, 2000)
        
        echo (widFrame, hiFrame)
    
    f()
    
    
    Run

but in fact widFrame and hiFrame should be read-only if the parameter size is 
given, what I expect is 
    
    
    proc f(size=1) =
        if size == 1:
            var
                widFrame = 320
                hiFrame = 200
        else:
            var
                widFrame = 3200
                hiFrame = 2000
        
        echo (widFrame, hiFrame)
    
    f()
    
    
    Run

which of cause failed with message t_bug.nim(11, 11) Error: undeclared 
identifier: 'widFrame'. What is the solution for this case?

Thanks 

Reply via email to