home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l210 / 1.ddi / EXAMPLES.ARC / CH12EX05.PRO < prev    next >
Encoding:
Text File  |  1988-06-21  |  1.1 KB  |  29 lines

  1. /*
  2.    Turbo Prolog 2.0 Chapter 12, Example Program 5
  3.       
  4.    Copyright (c) 1986, 88 by Borland International, Inc
  5.    
  6. */
  7.    
  8.    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  9.     * writef is similar to formatted-print statements in other    *
  10.     * programming languages. writef accepts an output string      *
  11.     * and a set of bound variables and constants as its arguments *
  12.     *                                                *
  13.     *          writef(FormatString, Arg1, Arg2,...)          *
  14.     *                                              *
  15.     * The arguments are inserted into the output string at the    *
  16.     * locations of the format specifiers.              *
  17.     *                                  *
  18.     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  19.     
  20. goal
  21.    A = one,
  22.    B = 330.12,
  23.    C = 4.3333375,
  24.    D = "one two three",
  25.    writef("A = '%-7' \nB = '%8.1e'\n",A,B),
  26.    writef("A = '%' \nB = '%8.4e'\n",A,B),nl,
  27.    writef("C = '%-7.7g' \nD = '%7.7e'\n",C,D),
  28.    writef("C = '%-7.0f' \nD = '%0'\n",C,D),
  29.    writef("char: %c, decimal: %d, hex: %x, unsigned: %u", 97,'a',33,-1).