home *** CD-ROM | disk | FTP | other *** search
- {Demo Program to demonstrate how to use unit123.PAS}
- {R. G. Minutillo: 7/1/95}
- unit demo123;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, unit123, StdCtrls;
-
- type
- TForm1 = class(TForm)
- Button1: TButton;
- Edit1: TEdit;
- Edit2: TEdit;
- Edit3: TEdit;
- Edit4: TEdit;
- Button2: TButton;
- Button3: TButton;
- OpenDialog1: TOpenDialog;
- Edit5: TEdit;
- Edit6: TEdit;
- Button4: TButton;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure LotusFormat(a: byte);
- procedure Button4Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
-
- procedure TForm1.Button1Click(Sender: TObject);
- var
- i: integer;
- s: string;
- t: string;
- begin
- if not Lotus_end_of_File then begin
- repeat Read_Lotus_Record
- until ((Lotus.Cell_Type<>Blank_Type) and (Lotus.Cell_Type<>Unidentified_Type));
-
- {}
- Case Lotus.Cell_Type of
- End_Of_File_Type:
- begin
- Edit1.TEXT:='End of File';
- EDIT2.TEXT:='';
- EDIT3.TEXT:='Row:'+inttostr(lotus.Row)+ ' - Col:' + inttostr(lotus.column);
- EDIT4.TEXT:='';
- end;
- Column_Width_Type:
- begin
- EDIT1.TEXT:='Column Width';
- EDIT2.TEXT:=Lotus.Alpha_Column;
- EDIT3.TEXT:='';
- EDIT4.TEXT:='';
- end;
-
- Range_Type:
- begin
- EDIT1.TEXT:='Lotus Range';
- EDIT2.TEXT:=Lotus.Alpha_Range_Start;
- EDIT3.TEXT:=Lotus.Alpha_Range_End;
- EDIT4.TEXT:=Lotus.range_name;
- end;
-
- PRange_Type:
- begin
- EDIT1.TEXT:='Lotus Print Range';
- EDIT2.TEXT:=Lotus.Alpha_PRange_Start;
- EDIT3.TEXT:=Lotus.Alpha_PRange_End;
- EDIT4.TEXT:='';
- end;
-
- PMargins_Type:
- begin
- EDIT1.TEXT:='Lotus Print Margins';
- EDIT2.TEXT:='Top: '+inttostr(lotus.PMargins_Top)+ ' - Bot: ' + inttostr(lotus.PMargins_Bottom);
- EDIT2.TEXT:='Left: '+inttostr(lotus.PMargins_Left)+ ' - Right: ' + inttostr(lotus.PMargins_Right);
- EDIT4.TEXT:='Lines: ' + inttostr(lotus.PMargins_Page_Lines);
- end;
-
- ARange_Type:
- begin
- EDIT1.TEXT:='Lotus Active Range';
- EDIT2.TEXT:=Lotus.Alpha_ARange_Start;
- EDIT3.TEXT:=Lotus.Alpha_ARange_End;
- EDIT4.TEXT:='';
- end;
-
- Print_Setup_Type:
- begin
- EDIT1.TEXT:='Print Setup String';
- EDIT2.TEXT:=Lotus.Print_Setup_Value;
- EDIT3.TEXT:='';
- EDIT4.TEXT:='';
- end;
-
- Blank_Type:
- begin
- EDIT1.TEXT:='Blank Cell';
- EDIT2.TEXT:=Lotus.Alpha_Column;
- EDIT3.TEXT:='Row:'+inttostr(lotus.Row)+ ' - Col:' + inttostr(lotus.column);
- EDIT4.TEXT:='';
- end;
-
- Integer_Type:
- begin
- EDIT1.TEXT:='Integer Cell';
- EDIT2.TEXT:=Lotus.Alpha_Column;
- EDIT3.TEXT:='Row:'+inttostr(lotus.Row)+ ' - Col:' + inttostr(lotus.column);
- EDIT4.TEXT:=inttostr(Lotus.integer_value);
- end;
-
- Real_Type:
- begin
- EDIT1.TEXT:='Real Number Cell';
- EDIT2.TEXT:=Lotus.Alpha_Column;
- EDIT3.TEXT:='Row:'+inttostr(lotus.Row)+ ' - Col:' + inttostr(lotus.column);
- EDIT4.TEXT:=floattostr(lotus.real_value);
- end;
-
- Label_Type:
- begin
- EDIT1.TEXT:='Label Cell';
- EDIT2.TEXT:=Lotus.Alpha_Column;
- EDIT3.TEXT:='Row:'+inttostr(lotus.Row)+ ' - Col:' + inttostr(lotus.column);
- EDIT4.TEXT:=lotus.label_value;
- end;
-
- Formula_Type:
- begin
- EDIT1.TEXT:='Formula Cell';
- EDIT2.TEXT:=Lotus.Alpha_Column;
- EDIT3.TEXT:='Row:'+inttostr(lotus.Row)+ ' - Col:' + inttostr(lotus.column);
- EDIT4.TEXT:=floattostr(lotus.formula_value);
- end;
-
- Protection_Type:
- begin
- EDIT1.TEXT:='Global Protection';
- if ord(Lotus.Protection_Value)<> 0 then
- EDIT2.TEXT:='On' else EDIT2.TEXT:='Off';
- EDIT3.TEXT:='';
- EDIT4.TEXT:='';
- end;
-
- Unidentified_Type:
- begin
- EDIT1.TEXT:='Unidentified Cell';
- EDIT2.TEXT:=Lotus.Alpha_Column;
- EDIT3.TEXT:='Row:'+inttostr(lotus.Row)+ ' - Col:' + inttostr(lotus.column);
- EDIT4.TEXT:='';
- end;
-
- Else
- begin
- EDIT1.TEXT:='Unidentified Cell';
- EDIT2.TEXT:=Lotus.Alpha_Column;
- EDIT3.TEXT:='Row:'+inttostr(lotus.Row)+ ' - Col:' + inttostr(lotus.column);
- EDIT4.TEXT:='';
- end;
- end;
-
- LotusFormat(Lotus.Format);
- end;
- end;
-
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- if opendialog1.execute then begin
- Lotus_Read_File_Name:=opendialog1.filename;
- Open_Lotus_Read_File; {Open a WKS, WK1 file and read version }
- Edit1.Text:=opendialog1.filename;
- Edit2.Text:=Lotus_Version_Name;
- end;
- end;
-
- procedure TForm1.Button3Click(Sender: TObject);
- begin
- CLose;
- end;
- procedure Tform1.LotusFormat(a: byte);
- begin
- if a >=128 then edit5.text:='protected' else edit5.text:='unprotected';
- {b:=(a and 112) div 16;}
- case (a and 112) div 16 of
- 0: edit5.text:=edit5.text + ' ' + 'fixed';
- 1: edit5.text:=edit5.text + ' ' + 'scientific';
- 2: edit5.text:=edit5.text + ' ' + 'currency';
- 3: edit5.text:=edit5.text + ' ' + 'percent';
- 4: edit5.text:=edit5.text + ' ' + 'comma';
- 5: edit5.text:=edit5.text + ' ' + 'unused';
- 6: edit5.text:=edit5.text + ' ' + 'unused';
- 7: edit5.text:=edit5.text + ' ' + 'special';
- end;
-
- if ((a and 112)div 16)< 7 then
- edit5.text:=edit5.text + ' ' + inttostr(a and 15)+' decimal places'
- else
- case a and 15 of
- 0: edit5.text:=edit5.text + ' ' + '+/-';
- 1: edit5.text:=edit5.text + ' ' + 'general';
- 2: edit5.text:=edit5.text + ' ' + 'day-month-year';
- 3: edit5.text:=edit5.text + ' ' + 'day-month';
- 4: edit5.text:=edit5.text + ' ' + 'month-year';
- 5: edit5.text:=edit5.text + ' ' + 'text';
- 6: edit5.text:=edit5.text + ' ' + 'hidden';
- 7: edit5.text:=edit5.text + ' ' + 'date:h:m:s';
- 8: edit5.text:=edit5.text + ' ' + 'date:h:m';
- 9: edit5.text:=edit5.text + ' ' + 'date: intl';
- 10: edit5.text:=edit5.text + ' ' + 'date: intl';
- 11: edit5.text:=edit5.text + ' ' + 'time: intl';
- 12: edit5.text:=edit5.text + ' ' + 'time: intl';
- 13: edit5.text:=edit5.text + ' ' + 'unused';
- 14: edit5.text:=edit5.text + ' ' + 'unused';
- 15: edit5.text:=edit5.text + ' ' + 'default';
- end;
- edit6.text:=inttostr(ord(a));
- end;
-
- procedure TForm1.Button4Click(Sender: TObject);
- var i,j: integer;
- d: real;
- s: string;
- begin
- Lotus_Write_File_Name:='123test.wk1';
- Open_Lotus_Write_File;
-
- Lotus.Row:=0;
- Lotus.Column:=0;
-
- Lotus.Cell_Type:=Protection_Type;
- Lotus.Protection_Value:=1;
- Write_Lotus_Record;
-
- Lotus.Cell_Type:=Print_Setup_Type;
- Lotus.Print_Setup_Value:='\027E\027&l1O\027(0U\027(s0p18.75H';
- Write_Lotus_Record;
-
- Lotus.Cell_Type:=PRange_Type;
- Lotus.PRange_Start_Column:=0;
- Lotus.PRange_Start_Row:=0;
- Lotus.PRange_End_Column:=4;
- Lotus.PRange_End_Row:=14;
- Write_Lotus_Record;
-
- Lotus.Cell_Type:=ARange_Type;
- Lotus.ARange_Start_Column:=0;
- Lotus.ARange_Start_Row:=0;
- Lotus.ARange_End_Column:=4;
- Lotus.ARange_End_Row:=14;
- Write_Lotus_Record;
-
- Lotus.Cell_Type:=PMargins_type;
- Lotus.PMargins_left:=5;
- Lotus.PMargins_Right:=70;
- Lotus.PMargins_Page_Lines:=60;
- Lotus.PMargins_Top:=5;
- Lotus.PMargins_Bottom:=5;
- Write_Lotus_Record;
-
- Lotus.Cell_Type:=Label_Type;
- Lotus.Label_Value:='^This is a Lotus Test File!';
- Write_Lotus_Record;
-
- Lotus.Cell_type:=Column_Width_Type;
- Lotus.Column_Width:=16;
- Write_Lotus_Record;
-
- for i:=1 to 4 do
- for j:=0 to 4 do begin
- Lotus.Row:=i;
- Lotus.Column:=j;
-
- if j>0 then begin
- Lotus.Real_Value:=i * j + 6;
- if i mod 2 = 0 then Lotus.Format:=162 else Lotus.Format:=130;
- Lotus.Cell_Type:=Real_Type;
- end
- else begin
- Lotus.Integer_Value:= i*(2*j)+8;
- if i mod 2 = 0 then Lotus.Format:=192 else Lotus.Format:=150;
- Lotus.Cell_Type:=Integer_Type;
- end;
- Write_Lotus_Record;
- end;
-
- Lotus.Cell_Type:=Formula_Type;
- Lotus.Row:=14;
- Lotus.Column:=1;
- Lotus.Format:=255;
- Lotus.Formula_Length:=12;
-
- {the formula is in reverse polish notation, so read up, sort of}
-
- Lotus.Formula[0] := 2; {The opcode 2 indicates that a cell range follows}
-
- Lotus.Formula[1] := 0; {this sequence is a range, two bytes each}
- Lotus.Formula[2] := 128; {for start row, start col, end row, and}
- Lotus.Formula[3] := 244; {end column. This particular range consists}
- Lotus.Formula[4] := 159; {of all relative addresses. and represents}
- Lotus.Formula[5] := 0; {the range B3..B14, in cell B15.}
- Lotus.Formula[6] := 128; {There's something in the two bytes}
- Lotus.Formula[7] := 255; {for each row or column which must}
- Lotus.Formula[8] := 159; {represent an offset and a relative direction}
-
- Lotus.Formula[9] := 80; {Opcode 80 represents @SUM}
- Lotus.Formula[10] := 1; {Byte for the number of arguments}
-
- Lotus.Formula[11] := 3; {End of Formula indicator, opcode 3}
-
- {no need for a formula_value, it will}
- {get updated on the load recalc anyway}
- Write_Lotus_Record;
-
- Close_Lotus_Write_File;
-
- end;
-
- end.
-
-