home *** CD-ROM | disk | FTP | other *** search
- {$V-,K-} { Speed up the program}
-
- {
- This Program converts a Symphony worksheet into a 1-2-3 worksheet.
- Since portions of Symphony worksheets are incompatible with 1-2-3,
- those parts are ommitted.
-
- A Symphony worksheet shares a number of record types with 1-2-3.
- These record types are duplicated. The Symphony record types which
- have no corresponding match in 1-2-3 are ignored, with the exception
- of record type 71. A 71 is the Symphony range name. Since it is
- reasonably important to have those in the 1-2-3 worksheet. The
- Symphony record type 71 is converted to a 1-2-3 type 11.
-
- There is one type of record problem that cannot be detected and
- corrected. A Symphony formula can contain a construct like:
- @IF(+C23=0,"",+C23*1.1)
- Since a 1-2-3 formula cannot return a string, this will cause 1-2-3
- to lock up when loading the worksheet. Pure string formulas are not
- affected since they use a different record type.
-
- }
-
- Program SymTo123;
-
- Var RecType,RecLen : Integer;
- FileLength : Real; { has to be real for }
- Fpoint : Real; { handling large files }
- SFile : File of Byte; { We need to read the file }
- LFile : File of Byte; { a byte at a time }
- SfileName : String[14];
- LFileName : String[14];
- Byte1,Byte2 : Byte;
- I,Pct : Integer;
- SCount,LCount : Integer;
-
-
- { Declarations done, get the two filenames from the user and open the
- files. We assume the user knows what he's doing so we don't worry
- about overwriting any existing files. If there is an I/O problem
- let the program crash.
- }
-
- Begin
- ClrScr;
- Write('Enter the FULL name of the Symphony worksheet: ');
- Read(SFileName);
- Writeln;
- Write('Enter the FULL name of the new 1-2-3 worksheet: ');
- Read(LFileName);
- For I := 1 to 14 Do Begin
- SFileName[I] := UpCase(SFileName[I]);
- LFileName[I] := UpCase(LFileName[I]);
- End;
- ClrScr;
- Assign(Sfile,SfileName);
- Assign(LFile,LFileName);
- Reset(Sfile);
- Rewrite(LFile);
-
-
-
- { The files are open. Display the length of the file and setup a
- display of the % of the file processed so the user doesn't get
- impatient. }
-
-
- FileLength := LongFileSize(Sfile);
- Writeln('The size of: ',SFileName,' is: ',FileLength:8:0);
- Fpoint := 0.0;
- SCount := 0;
- LCount := 0;
- GoToXY(9,5);
- Write(' of the file has been processed.');
-
-
- { Processing from the beginning to the end of the file, read each
- record and the length (the 1st two words); determine what to do.
- If it's a Symphony only record, skip to the beginning of the next
- record. If it's a 1-2-3 record, write the header out then write
- the rest of the record. If it's a beginning of file record, change
- the ID field to show it's really a 1-2-3 worksheet. Finally, if it's
- a type 71 record, change it to a type 11 record. }
-
- While Fpoint<FileLength Do
- Begin
- GoToXY(5,5);
- Pct := Round(Fpoint/FileLength*100);
- Write(Pct,'%');
- Read(SFile,Byte1);
- Read(SFile,Byte2);
- RecType := Swap(Byte2) + Byte1;
- Read(Sfile,Byte1);
- Read(Sfile,Byte2);
- RecLen := Swap(Byte2) + Byte1;
- Fpoint := Fpoint + 4.0;
- SCount := SCount + 1;
- If RecType=71 Then RecType := 11;
- If RecType<50 Then
- Begin
- LCount := Lcount + 1;
- Byte1 := RecType;
- Byte2 := Swap(RecType);
- Write(LFile,Byte1);
- Write(LFile,Byte2);
- Byte1 := RecLen;
- Byte2 := Swap(RecLen);
- Write(LFile,Byte1);
- Write(LFile,Byte2);
- For I := 1 to RecLen Do
- Begin
- Read(Sfile,Byte1);
- If (RecType=0) and (I=1) Then Byte1 := Byte1 - 1;
- Write(Lfile,Byte1);
- End;
- End
- Else LongSeek(Sfile,Fpoint+RecLen);
- Fpoint := Fpoint + RecLen;
- End;
-
-
- { That's the entire file, close up everything and tell the people
- all about it. }
-
- Close(SFile);
- Close(Lfile);
- ClrScr;
- Writeln;
- Writeln(SCount:5,' records read from Symphony worksheet: ',SFileName);
- Writeln;
- Writeln(LCount:5,' records written to 1-2-3 worksheet: ',LFileName);
- Writeln;
- End.