Skip to content
Tcl Source Code View Ticket
Login

View Ticket

format %n

Closed / Out of Date654927ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 21 years ago
Descriptionplain2002-12-17 00:10:47
(Greg Beauchesne, [email protected])

This patch adds %n and %N specifiers to [format]. They
work like the ones for sprintf(), except you give the
name of a variable. %n is for character length, and %N
is for byte length (should byte length ever be needed)

Ex.
format "%08x%n%08x%n" 5 varlen1 10 varlen2
$varlen1 is now 8 and $varlen2 is now 16

format "%s%N" "My string" bytelen
...has nearly the same effect as:
set bytelen [string bytelength "My string"]

A simple change, but it wasn't in there, or so the
manpages told me.

Made from tcl8.4.1.
nobodyplain2002-12-17 07:10:48
File Added - 37756: tcl-nformat.patch
dkfplain2002-12-17 22:03:12
Logged In: YES 
user_id=79902

This'll need a TIP before going any further.  (Don't know
what's wrong with just interpolating the results of [string
length] and [string bytelength] though.)
dkf Ticket [654927ffff]: 2 changes [History diff]2003-02-23 00:29:45
dgpplain2005-11-02 00:20:06
Logged In: YES 
user_id=80530


[format] got a rewrite for 8.5, so
this patch is out of date.
Log in (anonymous is fine) to add a comment.

Attachments: