Form S_152FC: HTML Browser Demonstration C

LANSA

Form S_152FC: HTML Browser Demonstration C
Name: S_152FC

Description: The following RDMLX form is a demonstration of techniques for interfacing LANSA applications with an HTML browser.
FUNCTION OPTIONS(*DIRECT);
BEGIN_COM FORMPOSITION(ScreenCenter) HEIGHT(109) WIDTH(313);
;
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#BTN_BUILD) BUTTONDEFAULT(True) CAPTION('Build Example Employee Information "Site"') DISPLAYPOSITION(1) LEFT(40) PARENT(#COM_OWNER) TABPOSITION(2) TOP(16) WIDTH(233);
DEFINE_COM CLASS(#PRIM_STBR) NAME(#STBR_1) DISPLAYPOSITION(3) HEIGHT(22) LEFT(0) MESSAGEPOSITION(1) PARENT(#COM_OWNER) TABPOSITION(3) TABSTOP(False) TOP(60) WIDTH(305);
;
DEFINE_COM CLASS(#S_152RHT) NAME(#DOC) DISPLAYPOSITION(2) LEFT(8) PARENT(#COM_OWNER) TABSTOP(False) VISIBLE(False);
DEFINE_COM CLASS(#PRIM_PGBR) NAME(#PROGBAR) DISPLAYPOSITION(1) HEIGHT(16) LEFT(174) MAXIMUMVALUE(5) MINIMUMVALUE(0) PARENT(#STBR_1) TABPOSITION(1) TOP(4) VALUE(0) VISUALSTYLE(#VS_GROUP) VISUALSTYLEOFPARENT(False) WIDTH(112);
;
Define #Caption RefFld(#SysVar$AV);
Define #AlpVal RefFld(#SysVar$Av);
Define #NumVal RefFld(#Std_NumL);
Define #Row RefFld(#Std_Num);
Define #Decimals RefFld(#Std_Num);
Define #OutFile RefFld(#SysVar$av);
Define #PctWidth RefFld(#Std_Num) Default(70);
;
* =============================================================================== ;
;
EVTROUTINE handling(#com_owner.Initialize);
;
SET #com_owner caption(*component_desc);
;
ENDROUTINE ;
;
* ================================================================================;
;
;
EVTROUTINE HANDLING(#BTN_BUILD.Click);
;
* Build the individual Employee pages;
;
Set #ProgBar Value(1);
Execute BldEMP;
;
* Build the individual Section pages;
;
Set #ProgBar Value(2) ;
Execute BldSEC;
;
* Build the individual Department pages;
;
Set #ProgBar Value(3) ;
Execute BldDEP;
;
* Build and Show the "Home" page;
;
Set #ProgBar Value(4) ;
Execute BldHOME;
;
* Finished;
;
Set #ProgBar Value(5) ;
Message 'Build Completed' ;
Set #ProgBar Value(0);
;
ENDROUTINE ;
;
;
* ================================================================================;
;
Subroutine StdStyles;
;
Invoke #DOC.DefineStyle Named(Caption) Italic(True) ;
Invoke #DOC.DefineStyle Named(AlphaValue) Alignment(Left) ;
Invoke #DOC.DefineStyle Named(NumericValue) Alignment(Left) ;
Invoke #DOC.DefineStyle Named(Stamp) Face('Arial') Size(1) ;
;
EndRoutine ;
;
* ================================================================================;
;
SubRoutine BldHOME;
;
Message 'Building the "Home" page' Type(*Status) ;
;
* Define the styles we want to use ;
;
Execute StdStyles;
;
* Define the table(s);
;
Invoke #DOC.DefineTable WithName(Depts) Order(1) Border(0) Frame(void) Rules(none) WithTitle('Select the Department you are interested in') TitleStyle(Caption) PctWidth(#PctWidth) SpaceAft(5);
Invoke #DOC.DefineTableCell InTable(Depts) WithName(Name) Order(1) CellStyle(AlphaValue) ;
;
Change #Row 0 ;
Select *all From_File(DepTab) ;
Change #Row '#Row + 1' ;
Use TConcat (*Component #Deptment '.htm') (#OutFile) ;
Invoke #DOC.SetTableCell InTable(Depts) WithName(Name) RowNum(#Row) Type(alpha) Alphavalue(#DeptDesc) HRef(#OutFile) ;
Endselect ;
;
* Insert the stamping details ;
;
Execute InsStamp ( N );
;
* Save the document ;
;
Use TConcat (*Temp_Dir *Component '.htm') (#OutFile) ;
;
Invoke #DOC.Save InFile(#OutFile);
;
* Close the document ;
;
Invoke #DOC.Close;
;
* Show the root document ;
;
Invoke #DOC.Show InFile(#OutFile);
;
EndRoutine ;
;
* ================================================================================;
;
SubRoutine BldDEP;
;
Message 'Building individual Department pages' Type(*Status) ;
;
Select *all From_File(DepTab) ;
;
* Define the styles we want to use ;
;
Execute StdStyles;
;
* Define the table(s);
;
Use BConcat ('Details of the' #DeptDesc 'Department') (#SysVar$Av) ;
Invoke #DOC.DefineTable WithName(Main) Order(1) Border(0) Frame(void) Rules(none) SpaceAft(1) WithTitle(#SysVar$Av) RuleBef(1) PctWidth(#PctWidth);
Invoke #DOC.DefineTableCell InTable(Main) WithName(Cap) Order(1) CellStyle(Caption) ;
Invoke #DOC.DefineTableCell InTable(Main) WithName(Val) Order(2) ;
;
Invoke #DOC.DefineTable WithName(Secs) Order(2) Border(0) Frame(void) Rules(none) WithTitle('These are the Sections within this Department. Select the Section that you are interested in ....') TitleStyle(Caption) RuleBef(1) PctWidth(#PctWidth) SpaceAft(5);
Invoke #DOC.DefineTableCell InTable(Secs) WithName(Name) Order(1) CellStyle(AlphaValue) ;
;
* Do the flat piece of the table ;
;
Change #Row 0 ;
Execute InsAlp ('Department Code' #Deptment);
Execute InsAlp ('Department Description' #DeptDesc);
;
* Do the section list ;
;
Change #Row 0 ;
;
Select (#Section #SecDesc) From_File(SecTab) With_Key(#Deptment);
Change #Row '#Row + 1' ;
Use TConcat (*Component #Deptment #Section '.htm') (#OutFile) ;
Invoke #DOC.SetTableCell InTable(Secs) WithName(Name) RowNum(#Row) Type(alpha) Alphavalue(#SecDesc) HRef(#OutFile) ;
Endselect ;
;
* Insert the stamping details ;
;
Execute InsStamp ( Y );
;
* Save the document ;
;
Use TConcat (*Temp_Dir *Component #Deptment '.htm') (#OutFile) ;
;
Invoke #DOC.Save InFile(#OutFile);
;
* Close the document ;
;
Invoke #DOC.Close;
;
EndSelect ;
;
EndRoutine ;
;
;
* ================================================================================;
;
SubRoutine BldSEC;
;
Message 'Building individual Section pages' Type(*Status) ;
;
Select *all From_File(SecTab) ;
;
Fetch *All From_File(DepTab) With_Key(#Deptment) Keep_Last(50) ;
;
* Define the styles we want to use ;
;
Execute StdStyles;
;
* Define the table(s);
;
Use BConcat ('Details of' #SecDesc 'Section in the' #DeptDesc 'Department') (#SysVar$Av) ;
Invoke #DOC.DefineTable WithName(Main) Order(1) Border(0) Frame(void) Rules(none) SpaceAft(1) WithTitle(#SysVar$Av) RuleBef(1) PctWidth(#PctWidth);
Invoke #DOC.DefineTableCell InTable(Main) WithName(Cap) Order(1) CellStyle(Caption) ;
Invoke #DOC.DefineTableCell InTable(Main) WithName(Val) Order(2) ;
;
Invoke #DOC.DefineTable WithName(Emps) Order(2) Border(0) Frame(void) Rules(none) WithTitle('These are the Employees that work in this Section. Select the Employee that you are interested in ....') TitleStyle(Caption) RuleBef(1) PctWidth(#PctWidth) SpaceAft(5);
Invoke #DOC.DefineTableCell InTable(Emps) WithName(Name) Order(1) CellStyle(AlphaValue) ;
;
* Do the flat piece of the table ;
;
Change #Row 0 ;
Execute InsAlp ('Department Code' #Deptment);
Execute InsAlp ('Department Description' #DeptDesc);
Execute InsAlp ('Section Code' #Section);
Execute InsAlp ('Section Description' #SecDesc);
Execute InsAlp ('Address' #SecAddr1);
Execute InsAlp (' ' #SecAddr2);
Execute InsAlp (' ' #SecAddr3);
Execute InsNum ('Zip Code' #SecPCode 0);
Execute InsAlp ('Phone' #SecPhBus);
;
* Do the employee list ;
;
Change #Row 0 ;
;
Select (#Empno #SurName #GiveName) From_File(PslMst1) With_Key(#Deptment #Section);
Change #Row '#Row + 1' ;
Use BConcat (#GiveName #SurName) (#FullName);
Use TConcat (*Component #Empno '.htm') (#OutFile) ;
Invoke #DOC.SetTableCell InTable(Emps) WithName(Name) Rownum(#Row) Type(alpha) Alphavalue(#FullName) HRef(#OutFile) ;
Endselect ;
;
* Insert the stamping details ;
;
Execute InsStamp ( Y );
;
* Save the document ;
;
Use TConcat (*Temp_Dir *Component #Deptment #Section '.htm') (#OutFile) ;
;
Invoke #DOC.Save InFile(#OutFile);
;
* Close the document ;
;
Invoke #DOC.Close;
;
EndSelect ;
;
EndRoutine ;
;
* ================================================================================;
;
SubRoutine BldEMP;
;
Message 'Building individual Employee pages' Type(*Status) ;
;
Select *all From_File(PslMst) ;
;
* Define the styles we want to use ;
;
Execute StdStyles;
;
* Define the table(s);
;
Invoke #DOC.DefineTable WithName(Main) Order(1) Border(0) Frame(void) Rules(none) SpaceAft(1) WithTitle('Employee Details') RuleBef(1) PctWidth(#PctWidth);
Invoke #DOC.DefineTableCell InTable(Main) WithName(Cap) Order(1) CellStyle(Caption) ;
Invoke #DOC.DefineTableCell InTable(Main) WithName(Val) Order(2) ;
;
Invoke #DOC.DefineTable WithName(Skill) Order(2) Border(0) Frame(void) Rules(none) WithTitle('Skills Associated with this Employee') TitleStyle(Caption) RuleBef(1) PctWidth(#PctWidth) SpaceAft(5);
Invoke #DOC.DefineTableCell InTable(Skill) WithName(Code) ColHdg1('Code') HdgStyle(Caption) Order(1) CellStyle(AlphaValue) ;
Invoke #DOC.DefineTableCell InTable(SKill) WithName(Description) ColHdg1('Description') HdgStyle(Caption) Order(2) CellStyle(AlphaValue) ;
;
* Get the department and section details ;
;
Change (#DeptDesc #SecDesc) '''Not Found''';
Fetch (#DeptDesc) From_File(DepTab) With_Key(#DeptMent) Keep_Last(50);
Fetch (#SecDesc) From_File(SecTab) With_Key(#DeptMent #Section) Keep_Last(50);
;
* Insert the details into the flat employee table ;
;
Change #Row 0 ;
Execute InsAlp ('Employee Number' #EmpNo);
Execute InsAlp ('First Name' #GiveName);
Execute InsAlp ('Last Name' #SurName);
Execute InsAlp ('Address' #Address1);
Execute InsAlp (' ' #Address2);
Execute InsAlp (' ' #Address3);
Execute InsNum ('Zip Code' #PostCode 0);
Execute InsAlp ('Home Phone Number' #PhoneHme);
Execute InsAlp ('Business Phone Number' #PhoneBus);
Execute InsAlp ('Department' #DeptDesc);
Execute InsAlp ('Section' #SecDesc);
Execute InsNum ('Yearly Salary' #Salary 2);
Execute InsNum ('Monthly Salary' #MnthSal 2);
;
* Now Insert the Skill Details;
;
Change #Row 0 ;
Select (#SkilCode) From_File(PslSkl) With_Key(#EmpNo);
Change #Row '#Row + 1' ;
Fetch (#SkilDesc) From_File(SklTab) With_Key(#SkilCode) Keep_Last(50);
Invoke #DOC.SetTableCell InTable(Skill) WithName(Code) Rownum(#Row) Type(alpha) Alphavalue(#SkilCode) ;
Invoke #DOC.SetTableCell InTable(Skill) WithName(Description) Rownum(#Row) Type(alpha) Alphavalue(#SkilDesc) ;
EndSelect ;
;
* Insert the stamping details ;
;
Execute InsStamp ( Y );
;
* Save the document ;
;
Use TConcat (*Temp_Dir *Component #Empno '.htm') (#OutFile) ;
;
Invoke #DOC.Save InFile(#OutFile);
;
* Close the document ;
;
Invoke #DOC.Close;
;
EndSelect ;
;
* Finished ;
;
EndRoutine ;
;
* ================================================================================;
;
SubRoutine InsAlp ((#Caption *Received)(#AlpVal *Received));
;
If '(#AlpVal = *blanks) and (#Caption = *Blanks)';
Return ;
Endif ;
;
Change #Row '#Row + 1';
Invoke #DOC.SetTableCell InTable(Main) withName(Cap) Rownum(#Row) Type(alpha) Alphavalue(#Caption) ;
Invoke #DOC.SetTableCell InTable(Main) withName(Val) Rownum(#Row) Type(alpha) Alphavalue(#AlpVal) CellStyle(AlphaValue);
;
EndRoutine ;
;
* ================================================================================;
;
SubRoutine InsNum ((#Caption *Received)(#NumVal *Received)(#Decimals *Received));
;
Change #Row '#Row + 1';
Invoke #DOC.SetTableCell InTable(Main) withName(Cap) Rownum(#Row) Type(alpha) Alphavalue(#Caption) ;
Invoke #DOC.SetTableCell InTable(Main) withName(Val) Rownum(#Row) Type(numeric) Decimals(#Decimals) Numvalue(#NumVal) CellStyle(NumericValue);
;
EndRoutine ;
;
* ================================================================================;
;
SubRoutine InsStamp ((#HomePage *Received));
Define #HomePage RefFld(#Std_CodeS);
;
Define #X_Mask RefFld(#Date) Length(6) decimals(0) Edit_Code(4) Default(0);
Define #X_MaskAA *char 2 To_Overlay(#X_Mask 1) ;
Define #X_MaskBB *char 2 To_Overlay(#X_Mask 3) ;
Define #X_MaskCC *char 2 To_Overlay(#X_Mask 5) ;
;
* Build and inert the references table;
;
Invoke #DOC.DefineTable WithName(Return) Order(9998) Border(0) Frame(void) Rules(none) PctWidth(#PctWidth) ;
Invoke #DOC.DefineTableCell InTable(Return) WithName(Text) Order(1) ;
;
If '#HomePage = Y' ;
Use TConcat (*Component '.htm') (#OutFile) ;
Invoke #DOC.SetTableCell InTable(Return) WithName(Text) RowNum(1) Type(alpha) Alphavalue('Return to Employee Example Site "Home" Page') HRef(#OutFile) CellStyle(Caption);
Endif ;
;
Invoke #DOC.SetTableCell InTable(Return) WithName(Text) RowNum(2) Type(alpha) Alphavalue('LANSA Web Site') HRef('http://www.lansa.com') CellStyle(Caption);
Invoke #DOC.SetTableCell InTable(Return) WithName(Text) RowNum(3) Type(alpha) Alphavalue('IBM Web Site') HRef('http://www.ibm.com') CellStyle(Caption);
Invoke #DOC.SetTableCell InTable(Return) WithName(Text) RowNum(4) Type(alpha) Alphavalue('Microsoft Web Site') HRef('http://www.microsoft.com') CellStyle(Caption);
;
* Build and insert the stamping table;
;
Invoke #DOC.DefineTable WithName(Stamp) Order(9999) Border(0) Frame(void) Rules(none) SpaceBef(1) RuleAft(1) PctWidth(#PctWidth) ;
Invoke #DOC.DefineTableCell InTable(Stamp) WithName(Text) Order(1) ;
;
Use BConcat ('This page automatically generated by :' *User) (#SysVar$Av) ;
Invoke #DOC.SetTableCell InTable(Stamp) WithName(Text) RowNum(1) Type(alpha) Alphavalue(#SysVar$Av) CellStyle(Stamp);
;
Change #X_Mask *Date ;
Use BConcat ('On Date :' #X_MaskAA '/' #X_MaskBB '/' ) (#SysVar$Av) ;
Use BConcat (#SysVar$Av #X_MaskCC) (#SysVar$Av) ;
Invoke #DOC.SetTableCell InTable(Stamp) WithName(Text) RowNum(2) Type(alpha) Alphavalue(#SysVar$Av) CellStyle(Stamp);
;
Change #X_Mask *Time ;
Use BConcat ('At Time :' #X_MaskAA ':' #X_MaskBB ':' ) (#SysVar$Av) ;
Use BConcat (#SysVar$Av #X_MaskCC) (#SysVar$Av) ;
Invoke #DOC.SetTableCell InTable(Stamp) WithName(Text) RowNum(3) Type(alpha) Alphavalue(#SysVar$Av) CellStyle(Stamp);
;
Use BConcat ('(C) Copyright' *Company ',1999' ) (#SysVar$Av) ;
Invoke #DOC.SetTableCell InTable(Stamp) WithName(Text) RowNum(4) Type(alpha) Alphavalue(#SysVar$Av) CellStyle(Stamp);
;
EndRoutine ;
;
END_COM ;