I usually rely on knowledge of the prefix - like using 3&}. - but a more
general solution might use something like this (in J7):

   *./\&.|.'a2b33c00100' e. Num_j_
0 0 0 0 0 0 1 1 1 1 1

to generate the boolean selector for the number portion.  This assumes that
the prefix has a non-numeric ending to separate it from the number part.

On Mon, Jan 31, 2011 at 8:03 PM, Ian Clark <[email protected]> wrote:

> Smart stuff.
>
> I make heavy use of my own routines to do this sort of stuff and I see
> I needn't have bothered. It's not my inability to cobble up what's
> needed, as it's needed (a mundane skill for someone who hates looking
> up documentation), but the time entailed in testing out homespun
> routines (voluntary or enforced). Freedom from gotchas is more vital
> to me than naked machine efficiency, so it's good to use something
> venerable like printf.
>
> Henry's solution will suit a requirement I often encounter: handling
> ids of the form: abc00123, ie treating those trailing digits as a sort
> of Veeder counter. But let me just ask this, as a rider to Skip's
> request:
>
> What's people's fave way to generate the next (or previous) id in a
> series, eg 'abc00100' from the string 'abc00099'?
>
> Much software bilks the user, stepping say from: "image9.tiff" to:
> "image10.tiff". This is unhelpful when sorting generated filenames in
> a Fileman or Finder window
>
> Ignore the obvious problem with: abc99999 --depend on having enough 0s
> in there. Don't demand a parameter like 3 or 'abc' to isolate the
> suffix. Oh, and don't assume the prefix is digit-free. There can be 1
> to 8 digits in the suffix, so you can employ 100000000+y and drop the
> '1'. Restrict to +integer suffixes (stepping back abc00000 should
> wraparound to abc99999) but beware the prefix might actually end with
> '-' or '_', viz: abc_002.
>
>
>
> On Mon, Jan 31, 2011 at 10:53 PM, Skip Cave <[email protected]>
> wrote:
> > On 1/31/2011 3:29 PM, Henry Rich wrote:
> >>       >  'abc _%d = %s.txt' vbsprintf (3{.a) ;"0 (3{. b)
> >
> > That's very nice. I hadn't looked into printf much before, but it makes
> > those kinds of text manipulations pretty easy.
> >
> > Thanks for the help.
> >
> > Skip
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>



-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to