OS2 World Community Forum
OS/2, eCS & ArcaOS - Technical => Programming => Topic started by: Jean-Yves on October 15, 2014, 10:02:30 am
-
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):
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).
-
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.
-
Not sure I can test it at evening but maybe the line
cgiName = value.1
ist a problem.
Try this:
else do
rc = VpGetItemValue(window, 'CNT_CGI', index)
message = 'You selected the' rc.1 'CGI entry'
response = VpMessageBox(window, index, message)
end
-
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
-
Ah ok. This is a bug at Vispro documentation (there are some more bugs like this).
This code
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:
/* 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
-
Thank you so much! :)
-
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.