Printer Version Table of Contents Project Home Page
.PARAMETER...: /J - Justifying Output
.CATEGORY....: parameters
.DISCUSSION..:
Using the /J (justify) parameter, it is possible to right, center, or left- justify Fdate's output, truncate it, or pad it with a certain character or character string.

Note that /J is not a function, but a parameter. The /J parameter may be used in conjunction with any of Fdate's functions. (It is discussed here, with the string-handling functions, because that's where it seemed most at home.)

Justification takes place BEFORE the strings specified on the /P (prefix) and /S (suffix) parms are added to the output.

The format of the /J parm is:

       /J"TP##"
In this example:

          - - - - - - my output string - - - - - -
          -*--*--*--*- my output string -*--*--*--*-
Note that when the pad string is more than one character, output will be slightly unpredictable, as it will depend on the length of the pad string, the length of the field in which the output is to be justified, and the length of the (pre-justification) output string.

SOME USES FOR THE /J PARM

(Most of these uses are illustrated in HOLIDAYS.BAT, which is included in the Fdate distribution ZIP file.)

In conjunction with the "echo" function (/Fe), the /J parm can be used to justify any value that you wish, not just output dates created by Fdate. Put the value to be justified in the /Q parm. Put a title, for example, as the value of the /Q parm, and specify center justification, padded with spaces, to a length of 79 characters (/J"c 79"). This will display the title, centered on the screen.

If you use the "echo" function and the /J parm, and specify the /Q parm but do not specify a value for it, then only the pad character will be displayed. (That is, the null string will be padded with the pad character to the desired length.)

.EXAMPLE.....:
  This is a handy way to draw horizontal lines of dashes,
  dots, or any other desired character.
                    Fdate /FE  /Q  /JC-79

  The /J parm can be used to left-pad a number with zeroes.

.EXAMPLE.....:
  Many of Fdate's input formats require the year to be in
  complete 4-digit CCYY format.  If your batch file obtains a
  value for YEAR from the user, the user might enter a YEAR
  that is less than 1000.  You can add leading zeroes to YEAR
  by right justifying it, padded it with '0' to a length of 4.

  Fdate  /Fe  /Q%year%  /JR04  /vyear

  Because /J can be used to truncate a string to a specified length, it
  can be used to extract the rightmost, leftmost, or centermost ##
  characters of a string.

.EXAMPLE.....:
  Fdate /Fe /J"C 79" /Q"SCREEN TITLE"

     Fdate's output is not put into an environment variable, so it will be
     displayed on the screen.  This command will echo the string "SCREEN
     TITLE" to the screen, centered in a field 79 characters long (that is,
     centered on the screen), and padded to the left and right with blanks.

.EXAMPLE.....:
  Fdate /Fe /J"L.40" /Q"Next report due date" /Vtitle
  Fdate /fadd /N60  /Od1 /Q"%title% "

  The first command left-justifies "Next report due date" in a
  string 40 characters wide, padded to the right with periods, and
  puts it into the TITLE environment variable.

  In the second step, the TITLE environment variable is used as
  the label for a date 60 days in the future.  In the second step,
  note the space between the end of %title% and the trailing
  double-quote.  This leaves a nice space between the dot leader
  and the date.

.EXAMPLE.....:
  For more examples, see HOLIDAYS.BAT.