home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_03_03 / 3n03051a < prev    next >
Text File  |  1991-10-06  |  3KB  |  85 lines

  1. program Try_WP_Lib;
  2.  
  3. (*  -------------------------------
  4.  
  5.     Listing 2:  Demo program
  6.  
  7.     Program Try_WP_Lib illustrates the use of WP_Lib.
  8.     It uses WP_Lib to create a sample WordPerfect
  9.     document.
  10.  
  11.     by David Andrew Price
  12.  
  13.     Version 1.0
  14.  
  15.     -------------------------------  *)
  16.  
  17. uses Dos, Crt, WP_Lib;
  18.  
  19. var OutFileName : String;
  20.     OutFile : Text;
  21.     Attrib : WP_TextAttribute;
  22.     Para, Sentence : Integer;
  23.  
  24. begin (* main *)
  25.    Writeln('What is the file you want to write to?');
  26.    Readln(OutFileName);
  27.    Assign(OutFile, OutFileName);
  28.    Rewrite(OutFile);
  29.  
  30.    (*  Write the header for WP 5.0 documents  *)
  31.    Write(OutFile, WP_Header);
  32.  
  33.    (*  Put page numbers at the bottom center of each
  34.        page  *)
  35.    Write(OutFile,
  36.          WP_Set_PageNumPos(WP_BottomCenterNum));
  37.  
  38.    (*  Write ten paragraphs and end each with two hard
  39.        returns.  The paragraphs alternate between
  40.        justified right margins and ragged right
  41.        margins.  *)
  42.    for Para := 1 to 10 do
  43.       begin
  44.          if Odd(Para) then
  45.             Write(OutFile, WP_RightJustOn)
  46.          else
  47.             Write(OutFile, WP_RightJustOff);
  48.          for Sentence := 1 to 5 do
  49.             Write(OutFile,
  50.                   'This is a sample sentence.  ');
  51.          Write(OutFile, WP_HardReturn, WP_HardReturn)
  52.       end;
  53.  
  54.    (*  An example of a hard page break  *)
  55.    Write(OutFile, 'A hard page break occurs below:',
  56.                   WP_HardPage);
  57.  
  58.    (*  An example of underlined text  *)
  59.    Write(OutFile, 'This is an example of ',
  60.                   WP_Attrib_On(WP_Underline),
  61.                   'underlined',
  62.                   WP_Attrib_Off(WP_Underline),
  63.                   ' text.', WP_HardReturn);
  64.  
  65.    (*  An example of a hard space  *)
  66.    Write(OutFile, 'There is a hard',WP_HardSpace,
  67.                   'space between ');
  68.    Write(OutFile, 'the fourth and fifth words of ',
  69.                   'this sentence.');
  70.    Write(OutFile, WP_HardReturn);
  71.  
  72.    (*  Print an example of all sixteen print
  73.        attributes  *)
  74.    Write(OutFile, WP_HardReturn, WP_HardReturn);
  75.    Write(OutFile, 'The following shows all sixteen ');
  76.    Write(OutFile, 'WordPerfect print attributes:');
  77.    Write(OutFile, WP_HardReturn, WP_HardReturn);
  78.    for Attrib := WP_ExtraLarge to WP_SmallCaps do
  79.       Write(OutFile, WP_Attrib_On(Attrib),
  80.                      'ABCDE fghij',
  81.                      WP_Attrib_Off(Attrib),
  82.                      WP_HardReturn);
  83.  
  84.    Close(OutFile)
  85. end.