Author Topic: [solved] Vispro Rexx container problem - always returning last item's values  (Read 1853 times)

Jean-Yves

  • Jr. Member
  • **
  • Thank You
  • -Given: 17
  • -Receive: 1
  • Posts: 81
    • View Profile
    • shimeril.com
Hi,

I wonder whether anyone has seen this behaviour with containers in VisPro Rexx:

I have a container (details view) within a notebook page.  I can load up data into it no problem.  However, no matter which row I select, the VpGetItemValue (using index) always returns me the last row's values, even though the index returned does change as I click through the rows .

The container has a symbol of CNT_CGI and I have an Edit button who's When Clicked/Selected event code is as follows (this is test code to just show some message boxes: I have commented out the fuller version but the same bug of the last row's values returned persists):

Code: [Select]
Arg window self

/* Get index of selected item */
index = VpGetIndex(window, 'CNT_CGI', 'SELECTED', 0)

if index = 0 then
    response = VpMessageBox(window, 'Error', 'No CGI item was selected')
else do
    value = VpGetItemValue(window, 'CNT_CGI', index)

    cgiName = value.1
    message = 'You selected the' cgiName 'CGI entry'
    response = VpMessageBox(window, index, message)
end

value = ''
index = 0

The initial VpGetIndex() call seems to work as when I click through entries, the 'index' variable is shown to change and returns consistent values for the rows I click on (eg if row 1 is 1234567 and row 2 is 567879, I always get 1234567 for row 1 and always get 56789 for row 2)

But the cgiName value is always the last row's value

The problem seems to be with the subsequent VpGetItemValue() call.  For some reason it seems to disregard the value of index.

Any ideas?

PS - I tried using a list box as thses use the same methods, and it works fine for those (ie always returns me the correct row's single value).

« Last Edit: November 04, 2014, 06:42:03 pm by Jean-Yves »



Jean-Yves

  • Jr. Member
  • **
  • Thank You
  • -Given: 17
  • -Receive: 1
  • Posts: 81
    • View Profile
    • shimeril.com
Re: Vispro Rexx container problem - always returning last item's values
« Reply #1 on: October 15, 2014, 11:30:19 am »
I should have added that I'm using the Vispro Rexx package from hobbes (the .wpi one with all the latest fixes) under eCS 1.2R in VirtualBox on OS X.   Just in case the environment might play a role.

Fr4nk

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 32
    • View Profile
    • subsys.de
Re: Vispro Rexx container problem - always returning last item's values
« Reply #2 on: October 15, 2014, 02:01:55 pm »
Not sure I can test it at evening but maybe the line

  cgiName = value.1

ist a problem.

Try this:
Code: [Select]
else do
   rc = VpGetItemValue(window, 'CNT_CGI', index)

    message = 'You selected the' rc.1 'CGI entry'
    response = VpMessageBox(window, index, message)
end


Jean-Yves

  • Jr. Member
  • **
  • Thank You
  • -Given: 17
  • -Receive: 1
  • Posts: 81
    • View Profile
    • shimeril.com
Re: Vispro Rexx container problem - always returning last item's values
« Reply #3 on: October 15, 2014, 05:38:17 pm »
Thanks for your help :)

I've tried changing names etc already, to no avail. However, changing the name from value to another name, eg rowfields does show that the VpGetItemValue call does not work, as the message box then returns ROWFIELDS.1

I've just tried a very quick test by creating a new project that just has a container and a button (no notebook). clicking the button activates the code, and I've also stripped out all extra code. It just does 3 VP methods:

Get index
Get value at index
Plain Message Box showing index and first element of value

Same error.

Most puzzling and very frustrating as if this is a bug then it's a showstopper for me. I can't build this app without containers :(

I've attached the massively simplified example (ie just two fields on one form) if that helps? If you could try it out and let me know if you get the same problem, that would be very helpful. Thanks

Fr4nk

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 32
    • View Profile
    • subsys.de
Re: Vispro Rexx container problem - always returning last item's values
« Reply #4 on: October 15, 2014, 09:23:22 pm »
Ah ok. This is a bug at Vispro documentation (there are some more bugs like this).

This code
Code: [Select]
rc=VpGetItemValue(window,'CNT_CGI',index)
returns the value of column 2 into "rc", but you don't get the whole data set of one entry into a stem. So don't use "rc.1" just use "rc" for you message box.

But if you need the whole dataset (which means all columns of a selected entry) you need this one:

Code: [Select]
/* Event ~Get Value BTN_GETVALUE, Clicked/selected */
Arg window self

index = VpGetIndex(window, 'CNT_CGI', 'SELECTED', 0)


CALL VpGetItemValue window,'CNT_CGI','DETAILS','COLUMNS.',index

say COLUMNS.0 /*count*/
say COLUMNS.1 /* column 1*/
say COLUMNS.2 /* column 2*/
say COLUMNS.3 /* column 3*/
say COLUMNS.4 /* column 4*/



HTH!
Fr4nk

Jean-Yves

  • Jr. Member
  • **
  • Thank You
  • -Given: 17
  • -Receive: 1
  • Posts: 81
    • View Profile
    • shimeril.com
Re: Vispro Rexx container problem - always returning last item's values
« Reply #5 on: October 15, 2014, 11:30:10 pm »
Thank you so much!  :)


Jean-Yves

  • Jr. Member
  • **
  • Thank You
  • -Given: 17
  • -Receive: 1
  • Posts: 81
    • View Profile
    • shimeril.com
Re: Vispro Rexx container problem - always returning last item's values
« Reply #6 on: October 17, 2014, 10:31:46 am »
Rather embarrassingly, after you supplied the solution I looked at the manual again and it does mention this very thing, and on the very page I was looking at!  So sorry for that.

Anyway, just reporting back to say that my container code is now all working fine thanks to you.