1. Sivaprakash BKR
  2. PowerBuilder
  3. Monday, 22 July 2024 12:31 PM UTC

Hello,

Using Pb 2022 R3 build 3356

One of the user wants to convert the input characters to a string field either to uppercase or wordcap based on the option given in a setup window.

Say, if the setupoption is set to UPPER, means
the input value of string field has to be converted to uppercase. 
If Platinum or platinum has been entered it has to be converted to PLATINUM.

Else if the setup option is to set Wordcap mans,
the input value of the string field has to be converted to wordcap, 
If PLATINUM PIECE or platinum piece has been entered to has to be converted to Platinum Piece.

I tried with the following code in the itemchanged event;

String              ls_data

ls_data = Data
If option = 'upper' Then
    SetText(ls_data)
ElseIf option = 'Wordcap' Then
    ls_data = lo_string.of_wordcap(ls_data)
    SetText(ls_data)
End If
Return 1                         <=  Without this Return value doesn't change, but the focus remains in the input field.

The above code works, but the control remains in the respective input field.  So we have to tab out twice to move out of that field.  

Removing Return 1 doesn't modify the value to converted value, but control moves to the next input field.

Is there any way to accomplish the above, without tabbing twice from the corresponding input field?

Happiness Always
BKR Sivaprakash

 

Miguel Leeuwe Accepted Answer Pending Moderation
  1. Monday, 22 July 2024 15:08 PM UTC
  2. PowerBuilder
  3. # 1

Try doing a return 2 and don't use SetText() but instead assign it to the field using SetItem() or .object notation.

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 23 July 2024 15:06 PM UTC
  2. PowerBuilder
  3. # 2

Hi, Sivaprakash,

If I was having to code this, I would try creating a “PostItemChanged” event (returning -none-, since posted methods do not return a value), passing it the same arguments that are supplied to the ItemChanged event, then POSTing that event from ItemChanged whenever it returns a value of zero. 

In the PostItemChanged event, do nothing if the “data” argument is null or empty. Perform a Describe to check the data type of the column and do nothing more unless the column type begins with “char”.

Then apply the configured transform operation, compare with the user-supplied value and only set the transformed value it differs.

I’m not 100% sure this will work, but this is what I would try initially. If the concept works and I have an object framework, I’d consider adding this event to the ancestor DW control so that I could utilize when needed.

Best regards, John

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.