Reputation: 55
I need to throw a message box whenever a user enters specific characters(cents sign, '', "" and (parenthesis)) into the DataWindow column in PowerBuilder.
I tried :
ls_text = dw_1.getitemstring(1, 'column')
but don't know how to parse the entered text (ls_text) and search for those characters mentioned above.
Any help on this would be appreciated.
Thanks in advance
Upvotes: 2
Views: 2423
Reputation: 620
Do NOT use getItemString()
for this purpose. Use the data
argument to the itemChanged
event.
If the DW field contains the string "before", and your user types "after", getItemString()
in the itemChanged
event will return "before". The DW column does not contain the data the user typed until AFTER the itemChanged
event fires (and you didn't return a non-zero return code)
Upvotes: 0
Reputation: 640
fortunatelly there are many choices to do this. To find a particular string in an another string you can use the following functions:
Keep in mind, that the functions above are CASE SENSITIVE. For example if you would like to find the first "comma" in a string:
integer li_ret
li_ret = Pos("Luke, I am your father :)", ",") // li_ret will be 5
If( li_ret > 0 )then
Messagebox("Warning", "I'm Darth Vader!")
end if
If you need more, and you would like to search for "regular expression", you can use:
Match()
You have also many possibilities to do this check:
ItemChanged
eventEditChanged
eventIn the ItemChanged
event you have the possibility to reject the value if it is necessary!
I hope this help! Feel free to ask for more.
Br. Gábor
Upvotes: 1