"Process Events" statement in CHUI - Forum - OpenEdge Development - Progress Community

"Process Events" statement in CHUI

 Forum

"Process Events" statement in CHUI

  • Hello, first post

    I want my app to continuously update a value on screen while also accepting user input. I am currently using the following code (which works in GUI):

    def var sTextInput as char.

    def var i as integer.

    def var lStop as logical.

    display sTextInput.

    enable sTextInput.

    on return of sTextInput

    lStop = true.

    do i = 1 TO 100000:

    display i view-as text.

    process events.

    if lStop then

    do:

    assign sTextInput.

    message sTextInput view-as alert-box title "Inputted Text".

    leave.

    end.

    end.

    Can this be achieved in CHUI? It sort of works, but the sTextInput field keeps losing all but the first letter and the flashing rectangle is quite ugly.

    Any help would be much appreciated!

    Thanks

    APD999

  • I got very frustrated with this and eventually decided to break it down to a lower level. Apparently I need to override the default key actions. So:

    def var sTextInput as char.

    def var i as integer.

    def var lStop as logical initial false.

    def var lChanged as logical initial false.

    display sTextInput.

    enable sTextInput.

    on any-key of sTextInput

    do:

    sTextInput = sTextInput + chr(lastkey).

    lChanged = true.

    end.

    on return of sTextInput

    do:

    lStop = true.

    end.

    on backspace of sTextInput

    do:

    sTextInput = substring(sTextInput, 1, (length(sTextInput) - 1)).

    end.

    do i = 1 TO 100000:

    display i view-as text.

    process events.

    if lChanged then

    do:

    display sTextInput.

    lChanged = false.

    end.

    if lStop then

    do:

    message sTextInput view-as alert-box title "Inputted Text".

    return.

    end.

    end.

    This may need a few changes as i mashed it out without access to a procedure editor.

  • Seems to me that using PROCESS EVENTS here is like using a jack hammer to open a cereal box. That, or a secret plot to peg the CPU. Why not a wait-for with a time-out or, at worst, pstimer? Do you really need to update so frequently?

    I might also note that this question actually belongs on the ABL forum, not on the code share since you have no set of useful working code that you want to share with us. You might want to ask the PSDN folks to move it.

    Consulting in Model-Based Development, Transformation, and Object-Oriented Best Practice  http://www.cintegrity.com

  • Perhaps because ChUI doesn't support timers?

    Nice use case for why timers should be a native cross-platform feature of the 4GL. Perhaps product management would like to take it into consideration the next time they are reviewing the ERS.

    --
    Tom Bascom
    tom@wss.com

  • In the early days of the 4GL there was no "WAIT-FOR PAUSE x" statement and we had to use the "UPDATE EDITING: ... END" construct in CHUI. This is basically a loop that iterates on every key stroke. You have to inspect the keystrokes inside the loop.

    The WAIT-FOR and READKEY have the "PAUSE x" option, to time out after blocking for input.

    The flashing is probably happening because you're not explicitly scoping the variable(s) you're DISPLAYing in a FRAME. Define a FORM and do a "DISPLAY .... IN FRAME x" (or do "ASSIGN x:SCREEN-VALUE IN FRAME x = ...").

    Hope this still works...