Progress
Programming
Handbook


Example Procedures

The following examples show different ways that Progress scopes frames.

In the procedure p-frm10.p, the scope of frame aaa is the procedure block because that is the first block that references frame aaa. The scope of frame bbb is the REPEAT block. The DISPLAY statement in the REPEAT block uses frame bbb because it is the default frame for the REPEAT block. (The DISPLAY statement could override this by explicitly naming a frame: DISPLAY WITH FRAME.)

p-frm10.p
DISPLAY "Customer Display" WITH FRAME aaa.
REPEAT WITH FRAME bbb.
  PROMPT-FOR customer.cust-num WITH FRAME aaa.
  FIND customer USING cust-num.
  DISPLAY customer WITH 2 COLUMNS.
END. 

In the procedure p-frm11.p, the scope of frame bbb is the procedure block because that is where it is first referenced. The FORM statement counts as a use of a frame. The default frame of the REPEAT block is bbb, since bbb is specified in the block’s header statement. However, frame bbb is not scoped to the REPEAT block:

p-frm11.p
FORM WITH FRAME bbb.
DISPLAY "Customer Display" WITH FRAME aaa.
REPEAT WITH FRAME bbb:
  PROMPT-FOR customer.cust-num WITH FRAME aaa.
  FIND customer USING cust-num.
  DISPLAY customer WITH 2 COLUMNS.
END. 

Progress can scope a frame to only one block. You cannot reference or use a frame outside its scope except in HIDE and VIEW statements.

In the procedure p-frm12.p, the scope of frame a is the REPEAT block, since that is the first block that references frame a. If you try to run this procedure, Progress displays as error saying that you cannot reference a frame outside its scope. The FOR EACH block names frame a, but the FOR EACH block is outside the scope of frame a. You could explicitly scope frame a to the procedure and use it in both the REPEAT and FOR EACH blocks. To do this, you could add a DO WITH FRAME block that encompasses both the REPEAT and FOR EACH blocks:

p-frm12.p
/* This procedure will not run */

REPEAT WITH FRAME a:
  PROMPT-FOR customer.cust-num.
  FIND customer USING cust-num.
  DISPLAY name.
END.
FOR EACH customer WITH FRAME a:
  DISPLAY name.
END. 


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095