Announcement

Collapse
No announcement yet.

writing to stderr

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • writing to stderr

    I want to send all of my normal output to stdout so the user
    can easily get it into a disk file or on the screen, and I don't
    have to implement command line options. But one thing I do want
    as an option is the ability to see *'s appear while the program
    is at work. (If you used "hash" in command line ftp you will
    know what I'm talking about.) So how do I channel these *'s to
    stderr so they won't mess up the user's output text?


    ------------------
    Erich Schulman (KT4VOL/KTN4CA)
    Go Big Orange

  • #2
    To send to stdout, use the STDOUT statement.
    To send to stderr, use the STDERR statement.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Comment


    • #3
      STDOUT and STDERR are not in my manual. The only method I
      find to write to stdout is
      OPEN "CONS:" FOR OUTPUT AS #1
      PRINT #1, MYTEXT$
      CLOSE #1
      And I find nothing for writing to stderr.


      ------------------
      Erich Schulman (KT4VOL/KTN4CA)
      Go Big Orange

      Comment


      • #4
        Which version of PB/DOS are you using? PB/DOS 3.5 supports STDOUT, etc.

        Upgrading from PB3.x to PB3.5 is now only US$49 + shipping. Please see http://www.powerbasic.com/products/pbdos for more information.


        ------------------
        Lance
        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        Lance
        mailto:[email protected]

        Comment


        • #5
          try using this

          open "scrn:" for output as #2
          print #2, "this is can't be redirected"

          or to make matters simpler:

          print "this can't either"

          I'm not sure if the print statement sends
          your text to stderr, but it can't be
          redirected, so it shouldn't be a problem.

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

          Comment


          • #6
            Excellent point David, but there are other significant advantages to upgrading to PB3.5 (and the upgrade price is now just US$49 + shipping and the manuals are in electronic format too (or you can purchase a set of printed manuals too).
            What's New in PowerBASIC 3.5
            ============================

            + $ELSEIF metastatement added for enhanced control of conditional
            compiling.

            + The ampersand character (&) can now be used to concatenate strings:

            MyString$ = MyString$ & "1"

            + ASC statement added to allow placing a byte value into an existing
            string:

            ASC(MyString$, 5) = 65 'change the 5th char to an "A"

            This is functionally equivalent to:

            MID$(MyString$, 5, 1) = CHR$(65)

            However, the ASC statement uses more efficient code.

            + ASC/ASCII functions support an optional parameter, which allows
            you to get the byte value of a character beyond the first byte
            in a string.

            + ASCIIZ string data type has been added. An ASCIIZ string is the
            same as a fixed-length string, except that the last character in
            the string is always a null [CHR$(0)].

            + CONSIN function returns the status of input (keyboard) redirection.
            If standard input originates from the console (keyboard), it returns
            true (-1). If redirected from a file, it returns false (0).

            + CONSOUT function returns the status of output (screen) redirection.
            If standard output displays on the console (screen), it returns
            true (-1). If redirected to a file, it returns false (0).

            + The CVI, CVL, etc. functions now support an optional parameter
            which is the starting location within a string to extract a value.
            For example, to extract an integer value from the 5th position in
            a binary string:

            x% = CVI(My$, 5)

            + FRE(-11) function added to return the number of free bytes in EMS
            memory. Before you allocate a virtual array, you should use FRE
            to make sure enough memory exists to hold the array.

            + Pointer variables now support 'indexes'. This allows you to assign
            a value to a pointer variable and access data as if it were an array.

            DIM x AS INTEGER PTR
            x = Address???
            a = @x 'get integer at Address&
            b = @x[4] 'get integer at Address& + 8

            In this example, the 5th integer (index pointers all start at zero
            and are not effected by the OPTION BASE value) is retrieved without
            us having to modify the Address& value.

            + The REDIM statement now supports the optional PRESERVE modifier.
            This allows you to change the number of elements in an existing
            array without destroying its contents. Note: REDIM PRESERVE does
            not work with virtual arrays.

            + The RND function has been enhanced to return integer class random
            numbers using the RND(a, z) syntax. Where 'a' is the lowest random
            value to return and 'z' is the highest random value to return.

            + SETEOF statement has been added to truncate an open file at the
            current file pointer. This is equivalent to using PUT$ to store
            a null (zero length) string in binary mode.

            + SIZEOF function has been added to return the memory size of
            variables. Unlike the LEN function, SIZEOF will return the size
            of the storage buffer available in ASCIIZ strings and the size of
            a string's handle (not the size of the string contents).

            + STDERR statement has been added to print data to the "standard
            error device". Typically, this is the screen, and output using
            STDERR can not be redirected to a file.

            + STDIN/STDIN LINE statements have been added to read keyboard
            data from the "standard input" device. Typically this is the
            keyboard. However, if a file has been redirected to your program
            STDIN will read from the file instead.

            + STDOUT statement has been added to print data to the "standard
            output device". Typically, this is the screen, and output using
            STDOUT can be redirected to a file or other device.

            Note: Only text printed with the the STDOUT statement will be
            redirected to a file. The PRINT statement prints data to the
            screen, regardless of output redirect status.

            + TRIM$ function added to trim the spaces (or other optional
            characters) from both the front and back of strings.

            + User-Defined Type and Union variables now support static arrays:

            TYPE a
            b(1 to 50) AS INTEGER
            c AS LONG
            END TYPE

            + Virtual Arrays in EMS memory. PowerBASIC now allows you to create
            numeric, fixed-length string, ASCIIZ string, and user-defined type
            arrays in EMS memory up to the LIM specification (16 megabytes).

            DIM VIRTUAL x&(1 to 10000)


            ------------------
            Lance
            PowerBASIC Support
            mailto:[email protected][email protected]</A>
            Lance
            mailto:[email protected]

            Comment

            Working...
            X