this make no sense

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

this make no sense

kenner
This program was working and then I made a few _small_ enhancements. The trace shows the select block getting executed, the PbtRevertToZeros when-clause getting selected and then the first method in that do-block is executed but then it directly falls thru to the otherwise statement. WTF?

method actionPerformed(evt=ActionEvent) -- signals IOException  
    if Debug_Level > 3 then trace results
         select
                         when evt.getSource().equals(advanceThruDeck) then do
                                         ShowNextCard(Rand1)
                         end
                         when evt.getSource() == SaveExit then do
                                         SaveScoreLine(DaScore)
                                         SaveTheRightWrongStatus()
                                         catch e=RuntimeException
                                             say 'I/O Exception.' e.getMessage()
                                         GuiClose()
                         end
                         when evt.getSource().equals(Submit_Check) then do
                                         Submit_Check(A_answer)
                         end
                         when evt.getSource().equals(PbtRevertToZeros) then do
                                         PbtRevertToZeros()
                                         if Debug_Level > 10 then trace results
                                  reset()
                                         DisplayScore(DaScore)
                                         ShowNextCard(Rand1)
                                                 end
                 otherwise say "This should not have happened, darn." -- we don't expect anything else
                catch e3=IOException
                    say 'Exception caught:' e3 '\n  ' e3.getMessage()
--                catch e4 = NullPointerException
--                    say 'Exception caught:' e4 '\n  ' e4.getMessage()
--            finally say "Caught something." -- awkward when exception is not thrown
         End

590 *=* method actionPerformed(evt=ActionEvent) -- signals IOException
     >a> evt "java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=Reset,when=1361472751949,modifiers=Button1] on javax.swing.JButton[,421,183,359x34,alignmentX=0.0,alignmentY=0.5,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@c7833c,flags=424,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2,right=14],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=true,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=Reset all scores,defaultCapable=true]"
 592 *=*   select
 593 *=*     when evt.getSource().equals(advanceThruDeck)
     >>> "javax.swing.JButton[,4,183,409x34,alignmentX=0.0,alignmentY=0.5,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@c7833c,flags=424,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2,right=14],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=true,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=Display the next card.,defaultCapable=true]"
     >>> "0"
 596 *=*     when evt.getSource() == SaveExit
     >>> "0"
 603 *=*     when evt.getSource().equals(Submit_Check)
     >>> "javax.swing.JButton[,4,139,409x34,alignmentX=0.0,alignmentY=0.5,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@c7833c,flags=424,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2,right=14],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=true,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=Submit and check your answer now.,defaultCapable=true]"
     >>> "0"
 606 *=*     when evt.getSource().equals(PbtRevertToZeros)
 700 *=* method PbtRevertToZeros -- SIGNALS RuntimeException
 702 *=*   rightAnswers = 0
     >p> rightAnswers "0"
 703 *=*   wrongAnswers = 0
     >p> wrongAnswers "0"
 704 *=*   pb.setValue(0) -- increment the progress bar value
     >>> "0"
 705 *=*   pb2.setValue(0) -- increment the progress bar value
     >>> "0"
 706 *=*   totalMinutes = 0
     >p> totalMinutes "0"
 707 *=*   if Debug_Level < 60
     >>> "1"
     *=*                       then
     *=*                            trace off
     >>> "4"
     >>> "0"
 613 *=*           otherwise
     *=*                     say "This should not have happened, darn." -- we don't expect anything else
     >>> "This should not have happened, darn."
This should not have happened, darn.
 619 *=*   end

And this is the mehod that you can see actually get executed in the when-do-clause:

method PbtRevertToZeros -- SIGNALS RuntimeException
         if Debug_Level > 10 then trace results
         rightAnswers = 0
         wrongAnswers = 0
         pb.setValue(0) -- increment the progress bar value
         pb2.setValue(0) -- increment the progress bar value
         totalMinutes = 0
         if Debug_Level < 60 then trace off
         loop label writeAns_doneTable qNumber = 1 to totalQCount
                 myCard[qNumber,3] = 0
                 myCard[qNumber,4] = 0
         end writeAns_DoneTable
         totalMinutes=0
        return 4

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: this make no sense

Kermit Kiser
In the absence of option "strictargs", PbtRevertToZeros is equivalent to
PbtRevertToZeros(). Hence the line:

"when evt.getSource().equals(PbtRevertToZeros) then do"

is calling method PbtRevertToZeros which returns a "4" which is unlikely
to equal evt.getSource(), so the otherwise clause will be executed in
that case.

-- Kermit


On 2/21/2013 9:37 AM, Kenneth Klein (TEMA TPC) wrote:

> This program was working and then I made a few _small_ enhancements. The trace shows the select block getting executed, the PbtRevertToZeros when-clause getting selected and then the first method in that do-block is executed but then it directly falls thru to the otherwise statement. WTF?
>
> method actionPerformed(evt=ActionEvent) -- signals IOException
>      if Debug_Level > 3 then trace results
> select
> when evt.getSource().equals(advanceThruDeck) then do
> ShowNextCard(Rand1)
> end
> when evt.getSource() == SaveExit then do
> SaveScoreLine(DaScore)
> SaveTheRightWrongStatus()
> catch e=RuntimeException
>     say 'I/O Exception.' e.getMessage()
> GuiClose()
> end
> when evt.getSource().equals(Submit_Check) then do
> Submit_Check(A_answer)
> end
> when evt.getSource().equals(PbtRevertToZeros) then do
> PbtRevertToZeros()
> if Debug_Level > 10 then trace results
> reset()
> DisplayScore(DaScore)
> ShowNextCard(Rand1)
>                                                   end
>         otherwise say "This should not have happened, darn." -- we don't expect anything else
>                  catch e3=IOException
>                      say 'Exception caught:' e3 '\n  ' e3.getMessage()
> --                catch e4 = NullPointerException
> --                    say 'Exception caught:' e4 '\n  ' e4.getMessage()
> --            finally say "Caught something." -- awkward when exception is not thrown
> End
>
> 590 *=* method actionPerformed(evt=ActionEvent) -- signals IOException
>       >a> evt "java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=Reset,when=1361472751949,modifiers=Button1] on javax.swing.JButton[,421,183,359x34,alignmentX=0.0,alignmentY=0.5,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@c7833c,flags=424,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2,right=14],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=true,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=Reset all scores,defaultCapable=true]"
>   592 *=*   select
>   593 *=*     when evt.getSource().equals(advanceThruDeck)
>       >>> "javax.swing.JButton[,4,183,409x34,alignmentX=0.0,alignmentY=0.5,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@c7833c,flags=424,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2,right=14],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=true,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=Display the next card.,defaultCapable=true]"
>       >>> "0"
>   596 *=*     when evt.getSource() == SaveExit
>       >>> "0"
>   603 *=*     when evt.getSource().equals(Submit_Check)
>       >>> "javax.swing.JButton[,4,139,409x34,alignmentX=0.0,alignmentY=0.5,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@c7833c,flags=424,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2,right=14],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=true,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=Submit and check your answer now.,defaultCapable=true]"
>       >>> "0"
>   606 *=*     when evt.getSource().equals(PbtRevertToZeros)
>   700 *=* method PbtRevertToZeros -- SIGNALS RuntimeException
>   702 *=*   rightAnswers = 0
>       >p> rightAnswers "0"
>   703 *=*   wrongAnswers = 0
>       >p> wrongAnswers "0"
>   704 *=*   pb.setValue(0) -- increment the progress bar value
>       >>> "0"
>   705 *=*   pb2.setValue(0) -- increment the progress bar value
>       >>> "0"
>   706 *=*   totalMinutes = 0
>       >p> totalMinutes "0"
>   707 *=*   if Debug_Level < 60
>       >>> "1"
>       *=*                       then
>       *=*                            trace off
>       >>> "4"
>       >>> "0"
>   613 *=*           otherwise
>       *=*                     say "This should not have happened, darn." -- we don't expect anything else
>       >>> "This should not have happened, darn."
> This should not have happened, darn.
>   619 *=*   end
>
> And this is the mehod that you can see actually get executed in the when-do-clause:
>
> method PbtRevertToZeros -- SIGNALS RuntimeException
> if Debug_Level > 10 then trace results
> rightAnswers = 0
> wrongAnswers = 0
> pb.setValue(0) -- increment the progress bar value
> pb2.setValue(0) -- increment the progress bar value
> totalMinutes = 0
> if Debug_Level < 60 then trace off
> loop label writeAns_doneTable qNumber = 1 to totalQCount
> myCard[qNumber,3] = 0
> myCard[qNumber,4] = 0
> end writeAns_DoneTable
> totalMinutes=0
> return 4
>
> _______________________________________________
> Ibm-netrexx mailing list
> [hidden email]
> Online Archive : http://ibm-netrexx.215625.n3.nabble.com/
>
>
>

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/