1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

@BPokeStr vs. @BRead

Discussion in 'Support' started by Howard Goldstein, Jul 12, 2009.

  1. Howard Goldstein

    Joined:
    Jun 1, 2008
    Messages:
    111
    Likes Received:
    1
    C:\temp>ver /r
    TCC 10.00.70 Windows XP [Version 5.1.2600]
    TCC Build 70 Windows XP Build 2600 Service Pack 3
    Registered to Howard Goldstein - 1 System License
    C:\temp>set h=%@balloc[80]
    C:\temp>echo %@bpokestr[%h,0,a,ABCDEFGHIJ]
    0
    C:\temp>echo %@bpeekstr[%h,0,a,10]
    ABCDEFGHIJ
    C:\temp>type insert.txt
    Insert
    C:\temp>set f=%@fileopen[insert.txt,r]
    C:\temp>echo %@bread[%h,0,%f,0,6]
    6
    C:\temp>echo %@bpeekstr[%h,0,a,10]
    InsertGHIJ
    C:\temp>echo %@bpokestr[%h,0,a,xyz]
    0
    C:\temp>echo %@bpeekstr[%h,0,a,10]
    xyz
    C:\temp>

    Note that @BRead does not truncate the buffer but @BPokeStr does. Is this
    WAD? I don't see anything about this behavior in the help topics.

    --
    Howard
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,854
    Likes Received:
    83
    Howard Goldstein wrote:


    WAD. @BPOKESTR doesn't truncate the buffer; however it does write the
    trailing null in the string to the buffer. So if you try to display
    your binary data as text, TCC will only output the data up to the first
    null.

    Rex Conn
    JP Software
     
  3. dcantor

    Joined:
    May 29, 2008
    Messages:
    507
    Likes Received:
    3
    (In addition to what Rex wrote,) I think that it's necessary that @BREAD does not write anything into the buffer other than what was in the file. In general, ANYTHING could be in the file, not necessarily ASCII text.

    Rex, the documentation on @BPOKESTR doesn't mention the fact that a trailing null is written. I had never used @BPOKESTR before and hadn't noticed it. Please add the warning that a terminating null is written.
    (And perhaps there could be an option to inhibit it.)
     

Share This Page