X-Mailer: ELM [version 2.3 PL8]
Newsgroups: bit.listserv.dbase-l
Date:         Tue, 10 Nov 1992 14:31:48 PST
Reply-To:     thamilto@pcocd2.intel.com
              dialects" <DBASE-L@NMSUVM1.BITNET>
From:         "(Tony Hamilton - FES~)" <thamilto@PCOCD2.INTEL.COM>
Subject:      dBase IV 1.5 question

First of all, thanks to everyone who has responded to my previous questions.
This list is a great resource!

Now, next problem:

This problem relates to the SET MESSAGE TO command. The problem surrounds
an ON KEY procedure, and the only way to explain it is to give you a scaled
down portion of the code in question:

...
SET FORMAT TO form
ON KEY LABEL Ctrl-U DO Del_record
READ
ON KEY
...

PROCEDURE Del_record
  DEFINE WINDOW d_input FROM ...
  ACTIVATE WINDOW d_input
  answer = SPACE(1)
  @ 0,0 SAY "Are you sure (y/n) ?"
  answer = INKEY(0)
  IF answer = 121                    && 121 = "y"
    ...
    KEYBOARD CHR(27)
  ENDIF
  DEACTIVATE WINDOW d_input
RETURN

Okay, the scenario is as follows. In the top procedure, I am editing a record
in the database using a format file and the READ command. I want to be able
to escape to a verification sequence when the user hits Ctrl-U to delete the
record they are editing. The ON KEY commands work fine, as does everything
else for that matter.

The Del_record procedure must use INKEY instead of READ, because it was
executed in the middle of another READ, and you can only have one at a time.
I tried this, and dBase didn't like it very well. Well, my problem is
two-fold:

1. The parent procedure above also sets the MESSAGE to something, like
   "hit ctrl-u to delete" or whatever. I would like to get a MESSAGE to display
   when the Del_Record procedure is executed, but the book says that MESSAGEs
   only work with full-screen editing commands. So, my thought is that I must
   simply write my message with SAY to the message line, and then erase it
   when done. For many reasons, I would rather have a better way, if there is
   one.

2. More importantly, when Del_record finishes, dBase apparently gets to the
   "deactivate window d_input" line, and then, strangely enough, removes
   the message defined in the parent procedure, and displays the message
   before that (from a popup not listed here). Apparently, there is a MESSAGE
   stack somewhere, and the DEACTIVATE WINDOW command (or something in there)
   is taking the last MESSAGE off of the stack, even though there wasn't one
   associated with that window. At least, this is my assessment. Does anyone
   understand what is happening, and how I can fix it? It is hardly appropriate
   for someone to hit Ctrl-U to delete the record, get the verification window
   and then answer "n" for NO, return to editing the record, and now see
   "Function Menu" on the message line, when they should still see
   "Hit ctrl-u to delete".

As an FYI, SET STATUS is OFF, and needs to be in this application. However,
after toggling this to ON, the above two problems disappeared. The documentation
offers some clues as to why this is, but is a little unclear. I have also
tried (with set status off, as it needs to be), to use a SET MESSAGE TO
command at the end of the Del_record procedure to try to "add" another
MESSAGE to the "message stack" (if there is such a monster) to fool dBase,
in order to fix problem #2, but it did not work. Finally, the KEYBOARD command,
executed when the user hits "y" to confirm deletion, simply automates the
exiting of the above READ session, since you wouldn't want to continue editing
a record you just deleted, would you...

Any help would be greatly appreciated...


--
Tony Hamilton                 |
-Intel Corporation            | voice: 916-356-3070
--Folsom Engineering Services | mailstop: FM2-55
---Engineering Resource Group | email: thamilto@pcocd2.intel.com
----Software Technician       |