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 >
Text File  |  1991-10-06  |  4KB  |  153 lines

  1. unit WP_Lib;
  2.  
  3. (*  -----------------------------------
  4.  
  5.     Listing 1:  Unit WP_Lib
  6.  
  7.     Unit WP_Lib enables the programmer to use Turbo
  8.     Pascal's Write procedure to write to files in
  9.     WordPerfect 5.0 format.
  10.  
  11.     by David A. Price
  12.  
  13.     Version 1.0
  14.  
  15.     -----------------------------------  *)
  16.  
  17. interface
  18.  
  19. type
  20.    WP_TextAttribute = (WP_ExtraLarge,
  21.                        WP_VeryLarge,
  22.                        WP_Large,
  23.                        WP_Small,
  24.                        WP_Fine,
  25.                        WP_Superscript,
  26.                        WP_Subscript,
  27.                        WP_Outline,
  28.                        WP_Italics,
  29.                        WP_Shadow,
  30.                        WP_Redline,
  31.                        WP_DoubleUnderline,
  32.                        WP_Bold,
  33.                        WP_StrikeOut,
  34.                        WP_Underline,
  35.                        WP_SmallCaps);
  36.  
  37.    WP_PageNumPos = (WP_NoNum,
  38.                     WP_TopLeftNum,
  39.                     WP_TopCenterNum,
  40.                     WP_TopRightNum,
  41.                     WP_AltTopLeftRightNum,
  42.                     WP_BottomLeftNum,
  43.                     WP_BottomCenterNum,
  44.                     WP_BottomRightNum,
  45.                     WP_AltBottomLeftRightNum);
  46.  
  47. const
  48.    WP_HardReturn     = ^J;
  49.    WP_HardPage       = ^L;
  50.    WP_HardSpace      = #160;
  51.    WP_RightJustOn    = #129;
  52.    WP_RightJustOff   = #130;
  53.    WP_MergeFieldEnd  = ^R^J;
  54.    WP_MergeRecordEnd = ^E^L;
  55.  
  56.  
  57. function WP_Header : String;
  58. (*  Returns string containing header for WP 5.0
  59.     document.  The calling program should write
  60.     the string at the beginning of the WP 5.0
  61.     file.  *)
  62.  
  63. function WP_Attrib_On(Attrib : WP_TextAttribute)
  64.                              : String;
  65. (*  Returns string containing code to turn on
  66.     specified print attribute, e.g., WP_Underline.  *)
  67.  
  68. function WP_Attrib_Off(Attrib : WP_TextAttribute)
  69.                               : String;
  70. (*  Returns string containing code to turn off
  71.     specified print attribute.  *)
  72.  
  73. function WP_Set_PageNumPos(Pos : WP_PageNumPos)
  74.                                : String;
  75. (*  Returns string containing code to set page number
  76.     position.  *)
  77.  
  78.  
  79.  
  80. (*  -----------------------------------  *)
  81.  
  82. implementation
  83.  
  84.  
  85. function WP_Header : String;
  86.  
  87. (*  Returns string containing header for WP 5.0
  88.     document.  The calling program should write
  89.     the string at the beginning of the WP 5.0
  90.     file.  *)
  91.  
  92. const
  93.       HeaderSize = 76;
  94.  
  95.       HeaderInfo : array[1..HeaderSize] of Char =
  96.       (#$FF, #$57, #$50, #$43, #$4C, #$00, #$00, #$00,
  97.       #$01, #$0A, #$00, #$00, #$00, #$00, #$00, #$00,
  98.       #$FB, #$FF, #$05, #$00, #$32, #$00, #$00, #$00,
  99.       #$00, #$00, #$06, #$00, #$08, #$00, #$00, #$00,
  100.       #$42, #$00, #$00, #$00, #$08, #$00, #$02, #$00,
  101.       #$00, #$00, #$4A, #$00, #$00, #$00, #$00, #$00,
  102.       #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00,
  103.       #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00,
  104.       #$00, #$00, #$08, #$00, #$7C, #$00, #$78, #$00,
  105.       #$00, #$00, #$00, #$00);
  106.  
  107. begin
  108.    WP_Header := HeaderInfo
  109. end; (* of WP_Header *)
  110.  
  111.  
  112. function WP_Attrib_On(Attrib : WP_TextAttribute)
  113.                              : String;
  114.  
  115. (*  Returns string containing code to turn on
  116.     specified print attribute, e.g., WP_Underline.  *)
  117.  
  118. begin
  119.    WP_Attrib_On := Chr($C3) + Chr(Ord(Attrib))
  120.                             + Chr($C3)
  121. end;
  122.  
  123.  
  124. function WP_Attrib_Off(Attrib : WP_TextAttribute)
  125.                               : String;
  126.  
  127. (*  Returns string containing code to turn off
  128.     specified print attribute  *)
  129.  
  130. begin
  131.    WP_Attrib_Off := Chr($C4) + Chr(Ord(Attrib))
  132.                              + Chr($C4)
  133. end;
  134.  
  135.  
  136. function WP_Set_PageNumPos(Pos : WP_PageNumPos)
  137.                                : String;
  138.  
  139. (*  Returns string containing code to set page number
  140.     position.  *)
  141.  
  142. begin
  143.    WP_Set_PageNumPos := Chr($D0) + #8 + #10#0 + #0#0#0
  144.                         + Chr(Ord(Pos))
  145.                         + #0#0 + #10#0 + #8 + Chr($D0)
  146. end;
  147.  
  148.  
  149.  
  150.  
  151. begin
  152.   (*  No initialization code  *)
  153. end.