简体   繁体   中英

Fill-In validation with N format

I have a fill-in with the following code, made using the AppBuilder

DEFINE VARIABLE fichNoBuktiTransfer AS CHARACTER FORMAT "N(18)":U 
     LABEL "No.Bukti Transfer" 
     VIEW-AS FILL-IN NATIVE 
     SIZE 37.2 BY 1 NO-UNDO.

Since the format is N, it blocks the user from entering non-alphanumeric entries. However, it does not prevent the user from copypasting such entries into the fill-in. I have an error checking like thusly to prevent such entries using the on leave trigger:

IF LENGTH(SELF:Screen-value) > 18 THEN DO:
      SELF:SCREEN-VALUE = ''.
      RETURN NO-APPLY.
END.
        vch-list = "!,*, ,@,#,$,%,^,&,*,(,),-,+,_,=".
        REPEAT vinl-entry = 1 TO NUM-ENTRIES(vch-list):
            IF INDEX(SELF:SCREEN-VALUE,ENTRY(vinl-entry,vch-list) ) > 0 THEN DO:
                SELF:SCREEN-VALUE = ''.
            RETURN NO-APPLY.
            END.
        END.

However, after the error handling kicked in, when the user inputs any string and triggers on leave, error 632 occurs:

error 632 occurs

Is there any way to disable the error message? Or should I approach the error handling in a different way?

EDIT: Forgot to mention, I am running on Openedge version 10.2B

You didn't mention the version, but I'll assume you have a version in which the CLIPBOARD system handle already exists. I've simulated your program and I believe it shouldn't behave that way. It seems to me the error flag is raised anyway. My guess is even though those symbols can't be displayed, they are assigned to the screen value somehow.

Conjectures put aside, I've managed to suppress it by adding the following code:

ON CTRL-V OF FILL-IN-1 IN FRAME DEFAULT-FRAME 
DO:
  if index(clipboard:value, vch-list) > 0 then
     return no-apply.
END.

Of course this means vch-list can't be scoped to your trigger anymore, in case it is, because you'll need the value before the leave. So I assigned the special characters list as an INIT value to the variable. After doing this, I didn't get the error anymore. Hope it helps.

To track changes in a fill-in I always use at first this code:

ON VALUE-CHANGED OF FILL-IN-1 IN FRAME DEFAULT-FRAME 
DO:
  /* proofing part */
  if ( index( clipboard:value, vch-list ) > 0 ) then do:
    return no-apply.
  end.
END.

You could add some mouse or developer events via AppBuilder to track changes in a fill-in.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM