Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

manipulating strings

Status
Not open for further replies.

geezer34

Technical User
Mar 17, 2004
11
GB
Hi guys,

This is going to be soo obvious when pointed out to me but as yet I've not cracked this....

Background I have an script that will cause an application to create a jpg image. What I need to do is to get a sequential number as the image name *but* it has to be in the format of xxxxx ie 00001 or 00099 etc.

Any ideas of the the best way of doing this?

I know I can use incr command to increment my number but am unsure how to get this into xxxxx format... Never used the format command before so am having issues getting things to work.

Ta
 
OK just had a brain wave

format $.5d $count (where count in updated by incr count)

I also note 'format $X.5d $count' seems to work. where x is an integer value.

Could somebody explain in english whats going on here please.

Thanks!



 
Actually, I have no idea why what you have would work at all. The format string should be preceded with a % to indicate that it is, indeed, a format string. What I do know is that format %05d $count will work. As in:
Code:
set a 3
set b [format %05d $a]

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top