[808] in Coldmud discussion meeting

root meeting help first previous next last

strfmt()

daemon@ATHENA.MIT.EDU (Sat Sep 16 20:54:14 1995 )

Date: Sat, 16 Sep 1995 18:48:23 -0600
From: 869683 Gillespie Brandon James <brandon@smithfield.declab.usu.edu>
To: coldstuff@pippin.ece.usu.edu

I'd appreciate it for those who are doing bug testing of ColdX-0.2-0 if they
would try to find all known problems with strfmt(), and suggest additional
functionalities.  This is a new function, and I'm sure it could use some work.

Right now its definition is:

// types: d or D       (literal data),
//        l or L       (string -- left aligned)
//        r or R       (string -- right)
//        c or C       (string -- centered)
//        e or E       (string, breaks with an elipse after pad width)
//
// args are integers, plus an optional colon seperator, which specifies
// the fill character.  If the fill character is any of the special
// characters, prefix it with a slash.  A period may eventually specify
// precision, with 'f'.  Capitalized versions of each string will
// cut the string, when it reaches the end of the specified padding.
//
//    "%r", "test"      => "test"
//    "%l", "test"      => "test"
//    "%c", "test"      => "test"
//    "%d", "test"      => "\"test\""
//
//    "%10r", "test"    => "      test"
//    "%10l", "test"    => "test      "
//    "%10c", "test"    => "   test   "
//    "%10:|r", "test"  => "||||||test"
//    "%10:|l", "test"  => "test||||||"
//    "%10:|c", "test"  => "|||test|||"
//
//    "%5e", "testing"  => "te..."

I messed up and forgot to put %d in (sorry), but the difference is that
with %d symbols are 'symbols and strings are "strings", right now symbols
are 'symbols (because I forgot about them), but they should just be their
regular string name (ala 'foo is just "foo"), and strings are not quoted,
so you could effectively create a $string thunk:

public format
  arg format, [args];
  
  return (> strfmt(format, args) <);
..

And use:

  "Method %s.%s() is invalid".format(obj.objname(), method);

Where objname is a "$string" and method is a 'symbol.

Enjoy

-Brandon