LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

adding letters to the end of a filename

I currently have a while loop that checks to see if the file it's trying to create already exists - if it does, it adds an underscore and a number to the end of the filename. I'm using the loop iteration terminal as the number to add to the end of the filename - this way even if the file with the new extension exists it will continue to advance numbers until it reaches a filename that doesn't exist.
 
However, I would really prefer to add letters to the end of the file (a, b, c, d, e...etc.) instead of numbers (1, 2, 3, 4...etc.). Does anyone know to easily do this? Is there a way to convert an integer to a letter (like realating the integers 1-26 to a-z?). Thanks.
 
-Erik
0 Kudos
Message 1 of 6
(3,203 Views)
What happens after 26? Switch to greek letters?Smiley Wink

There's two quick ways you can do this by using ASCII codes:

Message Edited by smercurio_fc on 07-13-2007 05:56 PM

0 Kudos
Message 2 of 6
(3,198 Views)
If you don't mind a string of random chars (a-Z) at the end, here's a quick hack for that. Just pass how long you want the string of chars to be. Makes your filenames unique without much chance of collisions.

Message Edited by Bill@NGC on 07-13-2007 04:07 PM

0 Kudos
Message 3 of 6
(3,195 Views)
If all you need is a unique suffix, use a number based on a timestamp. This will be somewhat longer but will simplify the code because the numbers will always be unique.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 6
(3,182 Views)

Erik...your first post it is what I am trying develop.

Every time I click SAVE button I want to create filename with diferent names like (job1, job2, job3)

Can you help me please. What I need study to implement this?

 

Tks

 

0 Kudos
Message 5 of 6
(3,033 Views)

The Express Save File dialog will do that automatically for you muganga.

I did my own by having a while loop that concatenated a defined prefix (like job) with the index, checked if the file existed in the directory, then if not it used that name, otherwise kept incrementing i

 

________________________________________________________

Use the rating system, otherwise its useless; and please don't forget to tip your waiters!
using LV 2010 SP 1, Windows 7
________________________________________________________
0 Kudos
Message 6 of 6
(3,025 Views)