diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | doc/binary.n | 21 |
2 files changed, 20 insertions, 5 deletions
@@ -1,3 +1,7 @@ +2002-10-09 Donal K. Fellows <fellowsd@cs.man.ac.uk> + + * doc/binary.n: More clarification of [binary scan]'s behaviour. + 2002-10-09 Daniel Steffen <das@users.sourceforge.net> * generic/tclIntDecls.h: fixed botched regen. diff --git a/doc/binary.n b/doc/binary.n index 7064b99..3be7d59 100644 --- a/doc/binary.n +++ b/doc/binary.n @@ -4,7 +4,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: binary.n,v 1.10 2002/10/04 10:23:33 dkf Exp $ +'\" RCS: @(#) $Id: binary.n,v 1.11 2002/10/09 14:07:43 dkf Exp $ '\" .so man.macros .TH binary n 8.0 Tcl "Tcl Built-In Commands" @@ -337,16 +337,27 @@ A similar example as with \fBbinary format\fR should explain the relation between field specifiers and arguments in case of the binary scan subcommand: .CS -\fBbinary scan $bytes i3i first second\fR +\fBbinary scan $bytes s3s first second\fR .CE .PP This command (provided the binary string in the variable \fIbytes\fR is long enough) assigns a list of three integers to the variable \fIfirst\fR and assigns a single value to the variable \fIsecond\fR. -If \fIbytes\fR contains fewer than 16 bytes (i.e. four 4-byte +If \fIbytes\fR contains fewer than 8 bytes (i.e. four 2-byte integers), no assignment to \fIsecond\fR will be made, and if -\fIbytes\fR contains fewer than 12 bytes (i.e. three 4-byte integers), -no assignment to \fIfirst\fR will be made. +\fIbytes\fR contains fewer than 6 bytes (i.e. three 2-byte integers), +no assignment to \fIfirst\fR will be made. Hence: +.CS +\fBputs [binary scan abcdefg s3s first second]\fR +\fBputs $first\fR +\fBputs $second\fR +.CE +will print (assuming neither variable is set previously): +.CS +\fB1\fR +\fB25185 25699 26213\fR +\fIcan't read "second": no such variable\fR +.CE .PP It is \fBimportant\fR to note that the \fBc\fR, \fBs\fR, and \fBS\fR (and \fBi\fR and \fBI\fR on 64bit systems) will be scanned into |