home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_03_03
/
3n03050a
< prev
next >
Wrap
Text File
|
1991-10-06
|
4KB
|
153 lines
unit WP_Lib;
(* -----------------------------------
Listing 1: Unit WP_Lib
Unit WP_Lib enables the programmer to use Turbo
Pascal's Write procedure to write to files in
WordPerfect 5.0 format.
by David A. Price
Version 1.0
----------------------------------- *)
interface
type
WP_TextAttribute = (WP_ExtraLarge,
WP_VeryLarge,
WP_Large,
WP_Small,
WP_Fine,
WP_Superscript,
WP_Subscript,
WP_Outline,
WP_Italics,
WP_Shadow,
WP_Redline,
WP_DoubleUnderline,
WP_Bold,
WP_StrikeOut,
WP_Underline,
WP_SmallCaps);
WP_PageNumPos = (WP_NoNum,
WP_TopLeftNum,
WP_TopCenterNum,
WP_TopRightNum,
WP_AltTopLeftRightNum,
WP_BottomLeftNum,
WP_BottomCenterNum,
WP_BottomRightNum,
WP_AltBottomLeftRightNum);
const
WP_HardReturn = ^J;
WP_HardPage = ^L;
WP_HardSpace = #160;
WP_RightJustOn = #129;
WP_RightJustOff = #130;
WP_MergeFieldEnd = ^R^J;
WP_MergeRecordEnd = ^E^L;
function WP_Header : String;
(* Returns string containing header for WP 5.0
document. The calling program should write
the string at the beginning of the WP 5.0
file. *)
function WP_Attrib_On(Attrib : WP_TextAttribute)
: String;
(* Returns string containing code to turn on
specified print attribute, e.g., WP_Underline. *)
function WP_Attrib_Off(Attrib : WP_TextAttribute)
: String;
(* Returns string containing code to turn off
specified print attribute. *)
function WP_Set_PageNumPos(Pos : WP_PageNumPos)
: String;
(* Returns string containing code to set page number
position. *)
(* ----------------------------------- *)
implementation
function WP_Header : String;
(* Returns string containing header for WP 5.0
document. The calling program should write
the string at the beginning of the WP 5.0
file. *)
const
HeaderSize = 76;
HeaderInfo : array[1..HeaderSize] of Char =
(#$FF, #$57, #$50, #$43, #$4C, #$00, #$00, #$00,
#$01, #$0A, #$00, #$00, #$00, #$00, #$00, #$00,
#$FB, #$FF, #$05, #$00, #$32, #$00, #$00, #$00,
#$00, #$00, #$06, #$00, #$08, #$00, #$00, #$00,
#$42, #$00, #$00, #$00, #$08, #$00, #$02, #$00,
#$00, #$00, #$4A, #$00, #$00, #$00, #$00, #$00,
#$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00,
#$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00,
#$00, #$00, #$08, #$00, #$7C, #$00, #$78, #$00,
#$00, #$00, #$00, #$00);
begin
WP_Header := HeaderInfo
end; (* of WP_Header *)
function WP_Attrib_On(Attrib : WP_TextAttribute)
: String;
(* Returns string containing code to turn on
specified print attribute, e.g., WP_Underline. *)
begin
WP_Attrib_On := Chr($C3) + Chr(Ord(Attrib))
+ Chr($C3)
end;
function WP_Attrib_Off(Attrib : WP_TextAttribute)
: String;
(* Returns string containing code to turn off
specified print attribute *)
begin
WP_Attrib_Off := Chr($C4) + Chr(Ord(Attrib))
+ Chr($C4)
end;
function WP_Set_PageNumPos(Pos : WP_PageNumPos)
: String;
(* Returns string containing code to set page number
position. *)
begin
WP_Set_PageNumPos := Chr($D0) + #8 + #10#0 + #0#0#0
+ Chr(Ord(Pos))
+ #0#0 + #10#0 + #8 + Chr($D0)
end;
begin
(* No initialization code *)
end.