Collection and Buttons Are Created at Run Time

Visual LANSA

Collection and Buttons Are Created at Run-Time

At run-time, when the user enters the number of buttons to be created and clicks the Create Buttons button and if the collection does not already exist, it is created using the SET_REF command:

 

IF_REF com(#BUTTON_COLLECTION) is(*null)

SET_REF com(#BUTTON_COLLECTION) to(*Create_as #PRIM_KCOL<#prim_phbn #STD_NUM>)
 
ENDIF 

 

And then the number of buttons specified in the #STD_NUM field are created in the collection:

 

BEGIN_LOOP to(#STD_NUM)
 
CHANGE field(#BUTTINDEX) to('#ButtIndex + 1')
USE builtin(BCONCAT) with_args('Push Button' #BUTTCHAR) to_get(#STD_TEXTL)
SET_REF com(#Button_collection<#ButtIndex>) to(*CREATE_AS #PRIM_PHBN)
SET com(#BUTTON_COLLECTION<#ButtIndex>) PARENT(#Button_Panel) WIDTH(120) CAPTION(#Std_TextL)
 
END_LOOP

 

Lastly they are realized:

 

* Realize all the buttons just created. You can do this button by button
* but it is more efficient to do them all in one go by (re)realizing their parent ....
 
INVOKE method(#Button_Panel.Realize)
 

Ý Example 5: Dynamically Create Buttons