Input Validating

kunalpathak

New Member
Hi All!!!

I have to validate user input at the time of user entering the data in Item Master field the requirement is something like our Item Code is in a particular format e.g. 1234 5678 9012 345

now whenever user is entering data in itemcode filed he need to manually press spacebar in between whereas we want it to come automatically like after first 4 char. one space then after anothe 4 char nd space.

I tried a lot with my basic knowledge of editing commands but i failed with nothing. if any of you can give me hint or idea onto how to start with. Progress provides even of On GO or on leave but how to handle this during the user input

My versions details:
progress 9.1e
mfgproeb2
item master programme is ppptmt.p

any help is appreciated. Thanks a lot in advance.

Regards
Kunal
 

Casper

ProgressTalk.com Moderator
Staff member
Do you actually need the spaces in order to find/create data or is it just a format issue?
If it is a format issue then why not use use format 'XXXX XXXX XXXX XXXX' in the input field.

I think formatting issues should be of no concern to the user. Even if you for some strange reason need the spaces then you can better put them in yourself, on the leave of the field before the find/create of a record. (Well, at least that is my opinion).

Casper.
 

sphipp

Member
You could use the EDITING command with instructions, although that is probably not the best way to do it.

The easiest way would be to use the ANY-PRINTABLE trigger. The following works (V9), although you could probably put the trigger code inside a procedure to make it a bit easier to follow.

Code:
def var item as char form "x(18)".
 
form item with frame item.
 
on any-printable of item in frame item do:
  assign item.
  item = replace(item:screen-value in frame item + chr(lastkey)," ","").
  if length (item) > 12 then item = 
    substring (item,1,4) + " " + substring (item,5,4) + " " + 
    substring (item,9,4) + " " + substring (item,13).
  else if length (item) > 8 then item = 
    substring (item,1,4) + " " + substring (item,5,4) + " " + 
    substring (item,9).
  else if length (item) > 4 then item = 
    substring (item,1,4) + " " + substring (item,5).
 
  display item with frame item.
  return no-apply.
 
end.
 
update item with frame item.
 
message 
  item skip length (item) skip num-entries (item," ") 
  view-as alert-box.
 
Top