Error ** PROMPT variable email should be used with INPUT prefix or ASSIGNed. (402)

Mady

New Member
Below query works fine with PROMPT-FOR

DISPLAY "Input" WITH FRAME a.
PROMPT-FOR ITEM.co_num ITEM.wh_num WITH FRAME a.

for first ITEM
WHERE using co_num and wh_num:
disp abs_num.

I have to take email address also from the user through screen and that email I will use to send an email with attachment. But when I use below code, I get this WARNING - ** PROMPT variable email should be used with INPUT prefix or ASSIGNed. (402). Progress advises to use SET or UPDATE statement. If I use SET or UPDATE, then it will show in a different frame. I want to capture all three values in single frame (without showing this warning) from user. How to do (any example would really help) ? Thanks.

DISPLAY "Input" WITH FRAME a.
define var email as char no-undo.
PROMPT-FOR ITEM.co_num ITEM.wh_num email WITH FRAME a.

for first ITEM
WHERE using co_num and wh_num:
disp abs_num.
 

Mady

New Member
I can use SET email with FRAME a.
But, is there any other good coding standard technique ?
 

TomBascom

Curmudgeon
You seem to have zeroed in on several highly effective ways to write impenetrable code.

Try this instead:

Code:
/* use variables for data entry - you should never let users type directly into a database field
 */

define variable email                   as character no-undo.
define variable companyNum    as integer      no-undo.
define variable warehouseNum  as integer     no-undo.

/* just use UPDATE
 * PROMPT-FOR, SET, and friends are sub components of UPDATE
 * actually it is 2022 and you really probably ought to be using event driven UI but that's probably a bridge too far right now
 */

update "Input data:" compNum warehouseNum email with frame a.

/* FOR FIRST does not do what you think that it does
 * you did not specify a lock so the code is defaulting to SHARE-LOCK which you neither want nor need and which will cause big problems in real code
 * furthermore what are you doing about the rest of the records that meet your criteria?
 * FOR EACH is much more appropriate
 * spell out the WHERE clause in detail, "USING" is extremely obscure in this context
 */

for each item no-lock where item.co_num = companyNum and item.warehouseNum = wh_num:

    display item.co_num item.wh_num item.abs_num.

    run sendMail( email, substitute( "Some message about company: &1 warehouse: &2 abs: &3", item.co_num, item.wh_num, item.abs_num )).

end.

/* an exercise for later
 */

procedure sendMail:

  define input parameter emailAddr as character no-undo.
  define input parameter emailBody as character no-undo.
  
  /* write some code to send an email - but that is a new thread, or a search of old threads */

end.
 
Top