what's wrong? (what am I doing wrong??)

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

what's wrong? (what am I doing wrong??)

christel.u.w.pachl christel.u.w.pachl
/* NetRexx program ****************************************************
* 03.11.2012 Walter Pachl
**********************************************************************/
options replace format comments java crossref savelog symbols nobinary
  values='triangle quadrilateral pentagon hexagon heptagon octagon' -
         'nonagon decagon dodecagon'
  keys  ='three four five six seven eight nine ten twelve'
  kcopy=keys
  Loop i=1 By 1 to 2 While kcopy>''
    Parse kcopy  k kcopy;  k[i]=k
    Parse values v values; v[i]=v
    say i k v k[i] v[i]
    End
  say 1 k[1] v[1]
/**********************************************************************
1 three triangle three triangle
2 four quadrilateral four quadrilateral
1 four quadrilateral  ???? WHY *** ???????????
**********************************************************************/                        

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

Reply | Threaded
Open this post in threaded view
|

Re: what's wrong? (what am I doing wrong??)

Jeff Hennick
You tell it to do it a maximum of 2 times:
> Loop i=1 By 1 to 2 While kcopy>''
Change to :

Loop i=1 While kcopy>''

(The "By 1" is the default and is optional.)


On 11/4/2012 5:04 AM, Walter Pachl wrote:

> /* NetRexx program ****************************************************
> * 03.11.2012 Walter Pachl
> **********************************************************************/
> options replace format comments java crossref savelog symbols nobinary
>    values='triangle quadrilateral pentagon hexagon heptagon octagon' -
>           'nonagon decagon dodecagon'
>    keys  ='three four five six seven eight nine ten twelve'
>    kcopy=keys
>    Loop i=1 By 1 to 2 While kcopy>''
>      Parse kcopy  k kcopy;  k[i]=k
>      Parse values v values; v[i]=v
>      say i k v k[i] v[i]
>      End
>    say 1 k[1] v[1]
> /**********************************************************************
> 1 three triangle three triangle
> 2 four quadrilateral four quadrilateral
> 1 four quadrilateral  ???? WHY *** ???????????
> **********************************************************************/
>
> _______________________________________________
> 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/

Reply | Threaded
Open this post in threaded view
|

Re: what's wrong? (what am I doing wrong??)

alansam
Walter,

It's because you keep re-initializing k and v inside the loop so you blow away earlier entries (k[1], v[1] etc.) on each iteration. The only indexed values in the k and v indexed strings will be the last ones you set (in your example k[2] & v[2]) all others will contain the default empty string.

Try this:

ka = ''; va = ''
Loop i=1 By 1 to 2 While kcopy>''
  Parse kcopy  k kcopy;  ka[i]=k
  Parse values v values; va[i]=v
  say i k v ka[i] va[i]
  End
say 1 ka[1] va[1]

Alan.

On 11/4/2012 5:04 AM, Walter Pachl wrote:
/* NetRexx program ****************************************************
* 03.11.2012 Walter Pachl
**********************************************************************/
options replace format comments java crossref savelog symbols nobinary
   values='triangle quadrilateral pentagon hexagon heptagon octagon' -
          'nonagon decagon dodecagon'
   keys  ='three four five six seven eight nine ten twelve'
   kcopy=keys
   Loop i=1 By 1 to 2 While kcopy>''
     Parse kcopy  k kcopy;  k[i]=k
     Parse values v values; v[i]=v
     say i k v k[i] v[i]
     End
   say 1 k[1] v[1]
/**********************************************************************
1 three triangle three triangle
2 four quadrilateral four quadrilateral
1 four quadrilateral  ???? WHY *** ???????????
**********************************************************************/
--
Can't tweet, won't tweet!

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

Alan

--
Needs more cowbell.
Reply | Threaded
Open this post in threaded view
|

Re: what's wrong? (what am I doing wrong??)

christel.u.w.pachl christel.u.w.pachl
zjanks!!!
In good old rexx k and k.i were (and are) different entities :-)
Learning process continued
Walter

---- Alan Sampson <[hidden email]> schrieb:

> Walter,
>
> It's because you keep re-initializing k and v inside the loop so you blow
> away earlier entries (k[1], v[1] etc.) on each iteration. The only indexed
> values in the k and v indexed strings will be the last ones you set (in
> your example k[2] & v[2]) all others will contain the default empty string.
>
> Try this:
>
> *ka = ''; va = ''*
> *Loop i=1 By 1 to 2 While kcopy>''
>   Parse kcopy  k kcopy;  ka[i]=k
>   Parse values v values; va[i]=v
>   say i k v ka[i] va[i]
>   End*
> *say 1 ka[1] va[1]*
>
> Alan.
>
> On 11/4/2012 5:04 AM, Walter Pachl wrote:
> >
> >> /* NetRexx program ******************************************************
> >> * 03.11.2012 Walter Pachl
> >> ****************************************************************
> >> **********/
> >> options replace format comments java crossref savelog symbols nobinary
> >>    values='triangle quadrilateral pentagon hexagon heptagon octagon' -
> >>           'nonagon decagon dodecagon'
> >>    keys  ='three four five six seven eight nine ten twelve'
> >>    kcopy=keys
> >>    Loop i=1 By 1 to 2 While kcopy>''
> >>      Parse kcopy  k kcopy;  k[i]=k
> >>      Parse values v values; v[i]=v
> >>      say i k v k[i] v[i]
> >>      End
> >>    say 1 k[1] v[1]
> >> /***************************************************************
> >> ***********
> >> 1 three triangle three triangle
> >> 2 four quadrilateral four quadrilateral
> >> 1 four quadrilateral  ???? WHY *** ???????????
> >> ****************************************************************
> >> **********/
> >>
> > --
> Can't tweet, won't tweet!

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

Reply | Threaded
Open this post in threaded view
|

Re: what's wrong? (what am I doing wrong??)

alansam
In reply to this post by alansam
Correction; v & k default values will be the last set so all k index values will be 'four' and those for v will be 'quadrilateral' (not the empty string.)

A.

On 4 November 2012 10:16, Alan Sampson <[hidden email]> wrote:
Walter,

It's because you keep re-initializing k and v inside the loop so you blow away earlier entries (k[1], v[1] etc.) on each iteration. The only indexed values in the k and v indexed strings will be the last ones you set (in your example k[2] & v[2]) all others will contain the default empty string.

Try this:

ka = ''; va = ''
Loop i=1 By 1 to 2 While kcopy>''
  Parse kcopy  k kcopy;  ka[i]=k
  Parse values v values; va[i]=v
  say i k v ka[i] va[i]
  End
say 1 ka[1] va[1]

Alan.


On 11/4/2012 5:04 AM, Walter Pachl wrote:
/* NetRexx program ****************************************************
* 03.11.2012 Walter Pachl
**********************************************************************/
options replace format comments java crossref savelog symbols nobinary
   values='triangle quadrilateral pentagon hexagon heptagon octagon' -
          'nonagon decagon dodecagon'
   keys  ='three four five six seven eight nine ten twelve'
   kcopy=keys
   Loop i=1 By 1 to 2 While kcopy>''
     Parse kcopy  k kcopy;  k[i]=k
     Parse values v values; v[i]=v
     say i k v k[i] v[i]
     End
   say 1 k[1] v[1]
/**********************************************************************
1 three triangle three triangle
2 four quadrilateral four quadrilateral
1 four quadrilateral  ???? WHY *** ???????????
**********************************************************************/
--
Can't tweet, won't tweet!



--
Can't tweet, won't tweet!

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

Alan

--
Needs more cowbell.
Reply | Threaded
Open this post in threaded view
|

Re: what's wrong? (what am I doing wrong??)

christel.u.w.pachl christel.u.w.pachl
In reply to this post by Jeff Hennick
The 'by 2' was for testing only
See furthrton for thr cause of my problem  (k and k. used to be different
entities)
See rosetta.org task Hash for the final program
Regards
Walter

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

Reply | Threaded
Open this post in threaded view
|

Re: what's wrong? (what am I doing wrong??)

Mike Cowlishaw
In reply to this post by christel.u.w.pachl christel.u.w.pachl

> zjanks!!!
> In good old rexx k and k.i were (and are) different entities

Essentially the NetRexx

  k=whatever

is the same as

  k.=whatever

in Rexx.

Hence your test is the equivalent of the Rexx:

---------
 values='triangle quadrilateral pentagon hexagon heptagon octagon' -
        'nonagon decagon dodecagon'
 keys  ='three four five six seven eight nine ten twelve'
 kcopy=keys
 Loop i=1 By 1 to 2 While kcopy>''
   Parse var kcopy  k. kcopy;  ka.i=k.
   Parse var values v. values; va.i=v.
   say i k. v. ka.i va.i
   End
 say 1 ka.1 va.1
---------

which indeed displays:

1 three triangle three triangle
2 four quadrilateral four quadrilateral
1 three triangle

Mike

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

Reply | Threaded
Open this post in threaded view
|

Re: what's wrong? (what am I doing wrong??)

Aviatrexx
It's always so simple and obvious when Mike explains it.  Wish I could
do that (and so do my students...)  :-/

-Chip-

On 11/5/2012 02:55 Mike Cowlishaw said:

>
>> zjanks!!!
>> In good old rexx k and k.i were (and are) different entities
>
> Essentially the NetRexx
>
>    k=whatever
>
> is the same as
>
>    k.=whatever
>
> in Rexx.
>
> Hence your test is the equivalent of the Rexx:
>
> ---------
>   values='triangle quadrilateral pentagon hexagon heptagon octagon' -
>          'nonagon decagon dodecagon'
>   keys  ='three four five six seven eight nine ten twelve'
>   kcopy=keys
>   Loop i=1 By 1 to 2 While kcopy>''
>     Parse var kcopy  k. kcopy;  ka.i=k.
>     Parse var values v. values; va.i=v.
>     say i k. v. ka.i va.i
>     End
>   say 1 ka.1 va.1
> ---------
>
> which indeed displays:
>
> 1 three triangle three triangle
> 2 four quadrilateral four quadrilateral
> 1 three triangle
>
> Mike
>
> _______________________________________________
> 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/

Reply | Threaded
Open this post in threaded view
|

Re: what's wrong? (what am I doing wrong??)

kenner

Maybe someone on this list can figure this out faster than I. On a windows box, xp and Win 7, the box appears long, thin and at the top of the screen. Same code on my Mac is the same accept that the JTextareas on the far left are pushed off the left edge of the JFrame. Any hints or clues are most welcome.


-- place all the components on the frame  
        DrawTheCard_Frame = JFrame(tittleInstruction)
        gbl = GridBagLayout()
        DrawTheCard_Frame.setLayout(gbl)
        myConstraints = GridBagConstraints()
        myConstraints.anchor=GridBagConstraints.PAGE_START
        myConstraints.fill=GridBagConstraints.BOTH
        myConstraints.insets.top = 5
        myConstraints.insets.left = 4
        myConstraints.insets.bottom = 5
        myConstraints.insets.right = 4
        PhysScreenDimensions = DrawTheCard_Frame.getToolkit().getScreenSize()
-- Set the size of the DrawTheCard_Frame
        DrawTheCard_Frame.setSize(PhysScreenDimensions.width/2, PhysScreenDimensions.height/2)
        thisFrameSize = DrawTheCard_Frame.getSize()
        say "PhysScreenDimensions" PhysScreenDimensions.width PhysScreenDimensions.height
        say "thisFrameSize" thisFrameSize.width thisFrameSize.height
-- Set the DrawTheCard_Frame position to the middle of the screen
        DrawTheCard_Frame.setLocation((PhysScreenDimensions.width - thisFrameSize.width) % 2,(PhysScreenDimensions.height - thisFrameSize.height)%2)
--
-- Create a label with the question.
        QBox_1 = JTextarea()
        QBox_1.setForeground( Color.blue )
        QBox_1.setFont(Font("Arial", Font.BOLD, 14))
          QBox_1.setEditable(boolean 0)
        QBox_1.setLineWrap(boolean 1);
          QBox_1.setWrapStyleWord(boolean 1)
--         myConstraints.gridwidth = 3
--         myConstraints.gridheight = 3
        myConstraints.fill=GridBagConstraints.BOTH
        myConstraints.weighty = 0.5
          myConstraints.gridx=0
        myConstraints.gridy=0
        gbl.setConstraints(QBox_1,myConstraints)
        DrawTheCard_Frame.add( QBox_1, myConstraints )
       
        InputText = JTextarea(123456789012345678901234567890)
        InputText.setLineWrap(mytrue)
        InputText.setForeground( Color.red )
        InputText.setFont( Font( "Arial", Font.BOLD, 14) )
        InputText.addKeyListener(this)
        myConstraints.fill=GridBagConstraints.BOTH
        myConstraints.weighty = 0.5
        myConstraints.gridx=1
        myConstraints.gridy=0
        myConstraints.weightx = 2
--        myConstraints.ipadx=1
--        myConstraints.REMAINDER =  2        DrawTheCard_Frame.add( InputText, myConstraints )
--        myConstraints.gridwidth=GridBagConstraints.REMAINDER
--        myConstraints.gridwidth=3
        gbl.setConstraints(InputText,myConstraints)
        DrawTheCard_Frame.add(InputText, myConstraints)
               
        text3 = JTextarea()
-- build the text3 text on the frame
--        f = SimpleDateFormat("H:mm:ss" ) -- Formats hours:minutes:seconds
        if (rightAnswers + wrongAnswers) == 0 then DaScore = 0
                else DaScore = (rightAnswers  / (rightAnswers + wrongAnswers) * 100 %1)
        textForSetting = "Starting at: 00:00:00      Elapsed time:"  000000 "minutes."
        text3.setText(textForSetting)
        myConstraints.fill=GridBagConstraints.BOTH
        myConstraints.weighty = 0.3
        myConstraints.gridx=0
          myConstraints.gridy=1
          myConstraints.ipadx=0
        gbl.setConstraints(text3,myConstraints)
        DrawTheCard_Frame.add(text3, myConstraints)
                 
-- build the text4 text on the frame
        text4 = JTextarea()
        if rightAnswers + totalQCount >  0 then perCentRight = ( 100 * ( rightAnswers / ( rightAnswers + totalQCount ) ) %1)
        if rightAnswers + totalQCount == 0 then perCentRight = 0
        textForSetting = rightAnswers 'of' fcgui.totalQCount 'complete.' perCentRight  '% \n' "Overall percent of correct responses: " DaScore '% \n'
        text4.setText(textForSetting)
        myConstraints.weighty = 0.3
    myConstraints.gridx=1
        myConstraints.gridy=1
        myConstraints.fill=GridBagConstraints.BOTH
        gbl.setConstraints(text4,myConstraints)
        DrawTheCard_Frame.add(text4, myConstraints)
         
-- Create a submit and check the answer button, add it, and set up its event handler.
        Submit_Check = JButton("Submit and check your answer now.")
        Submit_Check.setMnemonic('C')
        Submit_Check.setActionCommand("Submit_Check")
        Submit_Check.addActionListener(this)
         Submit_Check.setToolTipText("Click this button to check to see if your answer is correct.")
         Submit_Check.addKeyListener(this)
        myConstraints.weighty = 0.2
        myConstraints.gridx=0
        myConstraints.gridy=2
        myConstraints.fill=GridBagConstraints.BOTH
         gbl.setConstraints(Submit_Check,myConstraints)        
         DrawTheCard_Frame.add(Submit_Check, myConstraints)
       
-- Create a save and exit button, add it, and set up its event handler.
        SaveExit = JButton("Save score and exit now.")
        SaveExit.setMnemonic('S')
        SaveExit.setActionCommand("WriteItOut")
        SaveExit.addActionListener(this)
         SaveExit.setToolTipText("Click this button to save your score and exit the program.")
        myConstraints.fill=GridBagConstraints.BOTH
        myConstraints.weighty = 0.2
         myConstraints.gridx=1
        myConstraints.gridy=2
        gbl.setConstraints(SaveExit,myConstraints)
        DrawTheCard_Frame.add(SaveExit, myConstraints)
       
-- Create a button to pick the next card
        advanceThruDeck = JButton("Display the next card.")
        advanceThruDeck.setMnemonic('D')
        advanceThruDeck.setActionCommand("Advance")
        advanceThruDeck.addActionListener(this)
         advanceThruDeck.setToolTipText("Click this button to advance to the next card.")
        myConstraints.fill=GridBagConstraints.BOTH
        myConstraints.weighty = 0.2
        myConstraints.gridx=0
        myConstraints.gridy=3
        myConstraints.anchor=GridBagConstraints.PAGE_END
         gbl.setConstraints(advanceThruDeck,myConstraints)
         DrawTheCard_Frame.add(advanceThruDeck, myConstraints)
                 
-- show the DrawTheCard_Frame
        DrawTheCard_Frame.setVisible(1)
-- InputText.requestFocusinWindow()
-- add the window event listener to the window for close window events
        DrawTheCard_Frame.addWindowListener( CloseWindowAdapter())
        return 1
       


Kenneth Klein



Chip Davis <[hidden email]>
Sent by: [hidden email]

11/05/2012 01:18 PM

Please respond to
IBM Netrexx <[hidden email]>

To
IBM Netrexx <[hidden email]>
cc
Subject
Re: [Ibm-netrexx] what's wrong? (what am I doing wrong??)





It's always so simple and obvious when Mike explains it.  Wish I could
do that (and so do my students...)  :-/

-Chip-

On 11/5/2012 02:55 Mike Cowlishaw said:
>
>> zjanks!!!
>> In good old rexx k and k.i were (and are) different entities
>
> Essentially the NetRexx
>
>    k=whatever
>
> is the same as
>
>    k.=whatever
>
> in Rexx.
>
> Hence your test is the equivalent of the Rexx:
>
> ---------
>   values='triangle quadrilateral pentagon hexagon heptagon octagon' -
>          'nonagon decagon dodecagon'
>   keys  ='three four five six seven eight nine ten twelve'
>   kcopy=keys
>   Loop i=1 By 1 to 2 While kcopy>''
>     Parse var kcopy  k. kcopy;  ka.i=k.
>     Parse var values v. values; va.i=v.
>     say i k. v. ka.i va.i
>     End
>   say 1 ka.1 va.1
> ---------
>
> which indeed displays:
>
> 1 three triangle three triangle
> 2 four quadrilateral four quadrilateral
> 1 three triangle
>
> Mike
>
> _______________________________________________
> 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/



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