[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Convert Integer to Text



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Great, thanx to all.

Marks hit works fine.

Special Thanx to Mark

Oliver

"Martin Schultz" <martin.schultz@dkrz.de> schrieb im Newsbeitrag
ylwitj4uni9.fsf@faxaelven.dkrz.de">news:ylwitj4uni9.fsf@faxaelven.dkrz.de...
> Dan Blair <vze2p88d@verizon.net> writes:
>
> > Mark Hadfield wrote:
> >
> > > From: ""Mark Hadfield"" <m.hadfield@niwa.cri.nz>
> > >
> > > > You can add the prefix and suffix via the "+" operator like
> > > > this...
> > > >
> > > >     name = 'MC'+string(index,format='(I3.3)')+'.dcm'
> > > >
> > > > or within the format specifier like this...
> > > >
> > > >     name = string(index,format='("MC",I3.3,".dcm"')'
> > >
> > > Of course you can also use printf-style format codes (new to
> > > IDL 5.4) like this
> > >
> > >     name = string(index,format='(%"MC%3.3d.dcm")')
> > >
> > > I suppose there must be somebody out there who actually *uses*
> > > this stuff?
> > >
> > > ---
> > > Mark Hadfield
>
> > A freind of mine wrote  a nice thing for just this application.
> > It's a function called
> > padnumstring.pro
> >
> > here it is
> > [...]
> > repeat begin
> >  if strlen(numstring) lt length then numstring='0'+numstring
> >  endrep until strlen(numstring) eq length
>
> Not to blame you or your friend, but Mark's solution using the
> format qualifier is far superior and faster, too. You shouldn't use
> a loop in IDL when you can avoid it as easily as here.
>
> Martin
>
>
> --
> [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
> [[ Dr. Martin Schultz   Max-Planck-Institut fuer Meteorologie    [[
> [[                      Bundesstr. 55, 20146 Hamburg             [[
> [[                      phone: +49 40 41173-308                  [[
> [[                      fax:   +49 40 41173-298                  [[
> [[ martin.schultz@dkrz.de                                        [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBOw+6Z7813a8W2dX3EQLo0ACfSfgzKze40vD2eOTUQex0nBGpdaUAoM7C
K4Ybuk+XTt3dg2zkfhY6eWau
=BXmC
-----END PGP SIGNATURE-----