Examples—Initialize Statement
Set up two simple variables that can be specified as parameters and give them default values. Also set up two reference variables, one of type ADDR and the other a dynamic array of class EMP. Create a dummy row in the array with a Social Security number (ssn) attribute of 999999999:
initialize(
idnum = integer default 0,
idname = varchar(10) default 'none')=
declare
addr = ADDR;
emptable = array of EMP;
enddeclare
begin
emptable[1].ssn = 999999999;
end
Declare a simple integer variable, i, and set up two reference variables, one of type EMP and the other a dynamic array of class EMP. Fill the array emparray from the emptable table:
initialize(
emparray = array of EMP,
empptr = EMP) =
declare
i = integer;
enddeclare
begin
i = 1;
select :emparray[i].name = name
from emptable
begin
i = i + 1;
end
end;
Declare four reference variables; the first one is a collection of class worksheet that is a Microsoft Excel object. The others are references to other objects supported by Excel. The setup procedure opens a workbook and gets the worksheet named "sales" from the workbook's collection of worksheets.
initialize()=
declare
xlapp = Application;
wrkbook = Workbook default null;
wrksheet = Worksheet default null;
sheets_coll = Sheets collection of Worksheet default null;
setup = Procedure;
enddeclare
begin
end
on click setup_btn =
begin
callproc Setup();
end
procedure Setup() =
begin
wrkbook = xlapp.workbooks().open('example.xls');
sheets_coll = wrkbook.worksheets();
wrksheet = sheets_coll['sales'];
end