- Rex Chivers
- PowerBuilder
- Tuesday, 7 January 2020 05:45 PM UTC
PB2017r3
Windows 10
I had an issue that I have not seen before. I did not see anything in the questions and answers about it, I was wondering if anybody else has seen a similar issue.
I have a window opened as a sheet. This window, when a user clicks in a field a response window is opened. I am passing a structure with information into the response window when opening. The user makes a selection on the response window and when closing it the selection is stored in the structure and passed back to the parent window.
In the parent window script I use isvalid on the powerobject being returned to test before continuing. If the powerobject is valid then I put the structure being passed into a local structure and process it. The same structure object is used when opening the response window, passing back to the parent, and loading the powerobject into the local structure.
The response window has two command buttons ok and cancel, ok passes the structure back, and cancel close the response window and does not pass back the structure.
The issue comes when the user presses cancel and the window closes without returning a structure. I expected the is valid check on the powerobject parm to recognize no structure had been returned and not process the remainder of the code. However the powerobjectparm passed the isvalid test even though no object had been passed back.
Watching in the debugger, we could see the response window close, and the code resume in the main window. Watching to see why the isvalid did not handle as I expected I noted that the parent window grabbed another structure that had a totally different number of elements and changed the structure of my local variable declared structure to match it and loaded its data into the local declared structure.
I was a little shocked, thought I would at the very least have encountered an error that the two structure types did not match. The 'phantom' structure had many more elements and different datatypes. Has this behavior been noticed before ? Is this a bug or do I need a better way to check the returning structure ? Is this a feature that I have not been aware of that passing a structure as a powerobject could dynamically alter the structure it was being loaded into ???
Thanks for any advice or thoughts
Rex Chivers
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.