1. Koen de Vos
  2. PowerBuilder
  3. Wednesday, 3 January 2018 10:00 AM UTC

We are migrating from PowerBuilder 12.5 (4953) to PowerBuilder 2017 (1681)

In PowerBuilder 2017 when i Post to an event which has a reference Long array as argument it is no longer an array when it arrives in the event. If i call the event without a post it works fine. In PowerBuilder 12.5 this worked fine with a Post.

See the code below, the upperbound returns -1 because al_rowarray is not an array:

event clicked;LONG ll_selectedrows[]

io_paneDwControl.Event Post PopUp("sendEmail", ll_selectedrows)

end event

event popup(string as_message, ref long al_rowarray[]);

IF UpperBound(al_rowarray) = 0 THEN
TS_DATAWINDOW.GetSelectedRows(dw_list, al_rowarray)
END IF
 
end event
Accepted Answer
René Ullrich Accepted Answer Pending Moderation
  1. Wednesday, 3 January 2018 12:57 PM UTC
  2. PowerBuilder
  3. # Permalink

I think it's not a bug but normal behavior!

You want to post an event and this event should access the memory of a local variable from calling script (argument by reference!) that is no longer valid.

Possible solutions:

- Argument not by reference

- If you really need the argument by reference: Make sure that the variable in the calling object is still available if the called event is running. It may be an global, instance or shared variable but never a local variable.

- Don't post the event

Comment
  1. Koen de Vos
  2. Thursday, 4 January 2018 09:45 AM UTC
Good point about the argument by reference!

Changing it to 'by value' and now it works...



Now i only have to find an other solution to populate my array argument in the ancestor for use in the descendent...

  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Wednesday, 3 January 2018 14:42 PM UTC
  2. PowerBuilder
  3. # 1

Posted events/functions are not allowed to update anything in the calling script. It was probably a bug that allowed it to work and that bug has since been fixed.

When you post an event/function, the calling script continues and could end before the called script even starts. That would mean the calling script variables are no longer present so cannot be updated by the called script.

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.