Having to press ESC twice in I4GL
Posted in 1994
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL
Background:
I'm trying to verify information entered previously with a new entry.
The user is in an INPUT field which does a select to verify the record
exists. It's the first field, which means if they enter the last
field and hit return, they end up here.
The user enters the serial id of the record, which the 4gl program
looks to see if the original actually exists. If not, an error message is
produced and the user re-enters the record id. If it does exist it
goes on to the next field.
Problem:
When the user hits the Accept key, the program does the verify and goes
to the next field, instead of leaving the INPUT as I thought it should.
Code:
INPUT BY NAME
tmp[2].id,
tmp[2].owner
WITHOUT DEFAULTS
AFTER FIELD id
# look to see if the ID has already been entered
SELECT * INTO tmp[1].* FROM entry
WHERE entry.id = tmp[2].id
# if not, give error and stay in field
IF status = NOTFOUND THEN
ERROR "Record not found: Bad ID or missing record"
NEXT FIELD id
ELSE
IF tmp[1].ent_by IS NOT NULL THEN
DISPLAY tmp[1].ent_by to scr_form.ent_by
DISPLAY tmp[1].ent_date to scr_form.ent_date
END IF
IF tmp[1].ver_by IS NOT NULL AND
tmp[1].ver_date IS NOT NULL THEN
DISPLAY BY NAME tmp[1].*
MESSAGE "Record has already been verified"
RETURN
END IF
NEXT FIELD owner
END IF
-----------
I know this isn't very clear. And it's not something that's dreadfully
wrong, it's just something that is irritating for the user, and I'd
like to work around it. I've tried checking to see if the ID was new
or changed, and just checking it under those conditions, but that didn't
seem to help:
AFTER FIELD id
IF (( tmp_id IS NULL ) OR ( tmp_id <> tmp[2].id )) THEN
MESSAGE tmp_id, tmp[2].id
LET tmp_id = tmp[2].id
SELECT * INTO tmp[1].* FROM entry
WHERE entry.id = tmp[2].id
IF status = NOTFOUND THEN
ERROR "Record not found: Bad ID or missing record"
NEXT FIELD id
ELSE
IF tmp[1].ent_by IS NOT NULL THEN
DISPLAY tmp[1].ent_by to scr_form.ent_by
DISPLAY tmp[1].ent_date to scr_form.ent_date
END IF
IF tmp[1].ver_by IS NOT NULL AND
tmp[1].ver_date IS NOT NULL THEN
DISPLAY BY NAME tmp[1].*
CALL messp("Record has already been verified",22)
RETURN
END IF
NEXT FIELD owner
END IF
ELSE
MESSAGE tmp_id, tmp[2].id
NEXT FIELD owner
END IF
Any suggestions would be useful.
Thanks,
John Blomberg
johnb@ux1.cso.uiuc.edu