HPlogo System Debug Reference Manual > Chapter 6 System Debug Command Specifications M-X

W (write)

MPE documents

Complete PDF
Table of Contents
Index

E0201 Edition 4 ♥
E0300 Edition 3
E0692 Edition 3

Writes a list of values, with optional formatting, to output.

Syntax



   W    valuelist
   WL   valuelist
   WP   valuelist

   WCOL column
   WPAGE

W (Write), WL (Writeln), and WP (Prompt) write a list of values, with optional formatting, to output.

WP (Prompt) appends the new formatted values to the output buffer, flushes the buffer to output, and maintains the cursor on the same line.

W (Write) appends the new formatted values to the output buffer and advances the current buffer position.

WL (Writeln) appends the new formatted values to the output buffer, then flushes the buffer to output with a new line. The output buffer is reset.

WCOL advances the current output buffer position to the specified column position, blank-filling as necessary if the new position effectively expands the buffer.

WPAGE forces all buffered output to be flushed, and a page eject is emitted. The output buffer is reset.

Parameters


valuelist

An arbitrary list of values to be written. Values can be separated by blanks or with commas:


   value1, value2 value3 ...

An optional format specification can be appended to each value in the list in order to select specific output base, left or right justification, blank or zero fill, and field width for that value.

   value1[:fmtspec1] value2[:fmtspec2] ...

A format specification is a string list of selected format directives, with individual directives separated by commas or blanks:

   "directive1,directive2 directive3 ..."

The following table lists the supported format directives; they can be entered in uppercase or lowercase:
+

Current output base ($, #, or % prefix displayed).

-<

Current output base (no prefix).

+<

Current input base ($, #, or % prefix displayed).

-<

Current input base (no prefix).

$

Hex output base ($ prefix displayed).

#

Decimal output base (# prefix displayed).

%

Octal output base (% prefix displayed).

H

Hex output base (no prefix).

D

Decimal output base (no prefix).

O

Octal output base (no prefix).

A

ASCII base (use "." for nonprintable chars).

N

ASCII base (loads actual nonprintable chars).

L

Left-justified.

R

Right-justified.

B

Blank-filled.

Z

Zero-filled.

M

Minimum field width, based on value.

F

Fixed field width, based on the type of value.

Wn

User specified field width n.

Cn

Position the output starting at column n.

T

Typed (display the type of the value).

U

Untyped (do not display the type of the value).

QS

Quote single (surround w/ single quotes).

QD

Quote double (surround w/ double quotes).

QO

Quote original (surround w/ original quote character).

QN

Quote none (no quotes).

The M directive (minimum field width) selects the minimum possible field width necessary to format all significant digits (or characters in the case of string inputs).

The F directive (fixed field width) selects a fixed field width based on type of the value and the selected output base. Fixed field widths are listed in the following table:

Table 6-6 Fixed Field Widths

hex($,H) dec(#,D) oct(%,0) ascii(A,N)
S16,U164662
$32,U32810114
S641620228
SPTR810114
LPTR Class8.810.1011.118
EADDR Class8.1610.2011.2212
STRfield width = length of the string.

The Wn directive (variable field width) allows the user to specify the desired field width. The W directive can be specified with an arbitrary expression. If the specified width is less than the minimum necessary width to display the value, the user width is ignored, and the minimum width used instead. All significant digits are always printed. For example:

   number:"w6", or
   number:"w2*3"

The number of positions specified (either by Wn or F) does not include the characters required for the radix indicator (if specified) or sign (if negative). Also, the sign and radix indicator are always positioned just preceding the first (leftmost) character.

Zero versus blank fill applies to leading spaces (for right justification) only. Trailing spaces are always blank filled.

In specifications with quotes, the quotes do not count in the number of positions specified. The string is built such that it appears inside the quotes as it would without the quotes.

The T directive (typed) displays the type of the value, preceding the value. The U directive (untyped) suppresses the display of the type. Types are displayed in uppercase, with a single trailing blank. The width of the type display string varies, based on the type, and it is independent of any specified width (M, F, or Wn) for the value display.

For values of type LPTR (long pointer, sid.offset, or seg.offset) and EADDR (extended address, sid.offset or ldev.offset), two separate format directives can be specified. Each is separated by a dot, ".", to indicate individual formatting choices for the "sid" portion and the "offset" portion. This is true for all code pointers (ACPTR - absolute code pointers: CST, CSTX; LCPTR - logical code pointers: PROG, GRP, PUB, LGRP, LPUB, SYS, USER, TRANS). For example:

   pc:"+.-, w4.8, r.l, b.z"

The following default values are used for omitted format directives. Note that the default format directives depend on the type of value to be formatted:

       value type                 default format

       ----------                 --------------

       STR, BOOL                  - R B M U
       U16,S16,U32,S32,S64        + R B M U
       SPTR                       + R Z F U
       LPTR                       +.-  R.L  B.Z  M.F  U
        ACPTR    LCPTR            +.-  R.L  B.Z  M.F  T
         CST      PROG            +.-  R.L  B.Z  M.F  T
         CSTX     GRP             +.-  R.L  B.Z  M.F  T
                  PUB             +.-  R.L  B.Z  M.F  T
                  LGRP            +.-  R.L  B.Z  M.F  T
                  LPUB            +.-  R.L  B.Z  M.F  T
                  SYS             +.-  R.L  B.Z  M.F  T
                  USER            +.-  R.L  B.Z  M.F  T
                  TRANS           +.-  R.L  B.Z  M.F  T
       EADDR                      +.-  R.L  B.Z  M.F  U
        SADDR                     +.-  R.L  B.Z  M.F  T

Note that absolute code pointers, logical code pointers and extended addresses display their types (T) by default. All other types default to untyped (U).

The Cn (column n) directive moves the current output buffer position to the specified column position prior to the next write into the output buffer. Column numbers start at column 1. For example:

   number:"c6"


NOTE: The Cn directive is ignored by the ASC function but is honored by the W, WL and WP commands.

Examples



   $nmdat > var cost 100

   $nmdat > w  "the price is "
   $nmdat > w  cost
   $nmdat > wl " for the goodies."
   the price is $100 for the goodies
   $nmdat > wl "the price is ", cost, " for the goodies."
   the price is $100 for the goodies

Two different methods of writing mixed text and formatted numbers.

   $nmdat > var number:u32=123

   $nmdat > wl number
   $123
   $nmdat > wl number:"-"
   123
   $nmdat > wl number:"#"
   #291
   $nmdat > wl number:"d"
   291
   $nmdat > wl number:"f,r"
        $123
   $nmdat > wl number:"r,w6,- z"
   $nmdat > wl number:"r,w6,- z t"
   U32 000123

Several examples of formatting an unsigned 32-bit value.

   $nmdat > var test='test'

   $nmdat > wl test
   test
   $nmdat > wl test:"t"
   STR test
   $nmdat > wl test:"+"
   $test
   $nmdat > wl test:"w2"
   test
   $nmdat > wl test:"w8,r"
       test
   $nmdat > wl test:"w8, r qd"
   "    test"

Several examples of formatting a string.

   $nmdat > var long 2f.42c8

   $nmdat > wl long
   $2f.42c8
   $nmdat > wl long:"t"
   LPTR $2f.42c8
   $nmdat > wl long:"-.+"
   2f.$42c8
   $nmdat > wl long:"#.$,m.m"
   #47.$42c8
   $nmdat > wl long:"r.r f.m z"
         $2f.42c8
   $nmdat > wl long:"r.r,w6.6,z.z"
   $00002f.0042c8
   $nmdat > wl long:"r.r w6.6, z.z, qd"
   "$00002f.0042c8
   $nmdat > wl long:"r.r w6.6, b.b, $.$"
       $2f.  $42c8
   $nmdat > wl long:"r.l w6.6, b.b, $.$"
   $2f    .  $42c8

Several examples of formatting a long pointer.

   $nmdat > wcol 6
         $nmdat > wcol 3
      $nmdat > wcol 6; w 12345; wcol 2; wl 2
    2    $12345


   $nmdat > wl '2':'c2' '6':"c6" "4":'c4' "<-- column control":"c8"
    2 4 6 <-- column control


   $nmdat > w "123456 <-- column control";wl " ":"c1", " ":"c3", " ":"c5"
    2 4 6 <-- column control

These examples demonstrate how the output buffer can be positioned to a specific column number. In the first sequence, the WCOL command is used to specify a new column position. Note that the prompt forces the buffer to be output, and consequently may appear in an unexpected position immediately after a WCOL command.

In the second sequence, the Cn column directive is used to specify a column position for each formatted value. The third example demonstrates how portions of the output buffer may be overwritten by new formatted values.

Limitations, Restrictions


none




VARL[IST]


WHELP