Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Printf

From: tim::johnsons-web::com at: 20-Dec-2003 12:19

Hello Rebols: I'm a parse-a-phobic, and use it infrequently. The following function uses 'parse dialect, and appears to work, but I'd appreciate a critique from anyone on it. Given my unfamiliarity with parse, you just might be preventing me from chasing a bug sometime: Thanks! Code follows: ; Replace "%s" with members of a block. In the spirit ; of C, LISP, python format strings printf: function[str[string!] subs[block!]] [delims non-delims blk ndx ][ delims: charset "%s" non-delims: complement delims blk: copy [] ndx: 1 parse/all str[ some [ copy txt some non-delims ( append blk txt if ndx <= (length? subs)[ append blk subs/:ndx ] ndx: ndx + 1 ) | delims ] ; end some ] rejoin blk ];end func ;I appreciate the input, also, there used to be a function ;posted at that might have done something similar. ;Couldn't find it last I looked. Regards -- Tim Johnson <[tim--johnsons-web--com]>