Re: SWITCH problem - need thoughts

new topic     » goto parent     » topic index » view thread      » older message » newer message

Thanks for your reply. Further information.

"4.1.0 development (6300:57179171dbed, 2015-02-02 14:18:53)"

pf() is just a printing procedure that prints whatever is inside the parenthesis pair. It's for quick debugging.

------------------------------------ 
--print routine for tests 
-- 
 
 
public procedure pf(atom nbr,sequence txt = "") 
 
printf(1,"%s => %d\n",{txt,nbr}) 
printf(fn,"%s => %d\n",{txt,nbr})          --this is a log file fn is global 
end procedure 
-------------------------------------- 

The following code works as expected:

include std/console.e 
 
constant ctrl1=8247618  
constant ctrl2=9247618  
constant ctrl0=0  
sequence cases = {ctrl1,ctrl2,ctrl0} 
integer fn = open("test_5.txt","w") 
 
for i = 1 to 3 do 
  
    atom evntownr=cases[i] 
    printf(fn,"Test %d\n",i)  
 
    switch evntownr do  
    case ctrl1 then  
        puts(fn, "CASE ONE 8247618\n")  
    case ctrl2 then  
        puts(fn, "CASE TWO 9247618\n")  
    case else  
        puts(fn, "CASE THREE Uhh... what?\n")  
    end switch  
end for  
 
puts(1, "\n\nend...\n")  
any_key()  

Test 1 
CASE ONE 8247618 
Test 2 
CASE TWO 9247618 
Test 3 
CASE THREE Uhh... what? 

Returning to the original problem:

Note the values I printed out and that the constant changed while INSIDE the Switch block. Thus-->

line #5  point 2C - cancel btn  => 9247618  
line #11  cancel btn @ point 6A  => 9247616  <====  Here is the problem! Between these two lines the value has changed.  Something would have to have the ability to assign a new value 
                                                    to a constant.  I have noticed that the value always changes by either 2 or 4.     

I can't say that it's the switch block at fault BUT, the value of the constant cat_sel_cancel_btn changed from just before the switch statement and the case where it is tested for. This behavior is NOT possible. The switch mechanism is passive. You can easily see this by following the point markers I left and their appearance in the printout. I ran the program with no changes 10 times. In 8 of the runs the value changed. In two case it did not change; however, the switch statement did not catch it. It just ended up in the else case.

For now I'm going to go with the if/else coding. I know it works. I'll report if I find something.

Thanks, jd

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu