Incrementing character string ASCII value
Posted: Thu May 08, 2014 10:27 pm
Hi,
I am taking an existing file name, ABC01, and if present already, wanting to create a new name ABC02 to stop overwriting.
The file name is used in the FAT component.
Hence, I assumed that I would chop off the last character, increment it by 1, ASCII for '1' = 49 to get '2' fron ASCII 50 and then add it back to get the new name.
Char = Right$ (File_Name,1)
Char[0] = Char[0] + 1
Len = Length$ (File_Name)
File_Name = Left$ (File_Name, (Len - 1))
File_Name = File_Name + Char
File_Name_String = File_Name + ".csv"
what I get is test01.csv goes to test0ß.csv and then test0Ó.csv
What am I doing wrong? Is there a simpler way to do this?
Thanks,
Mark
I am taking an existing file name, ABC01, and if present already, wanting to create a new name ABC02 to stop overwriting.
The file name is used in the FAT component.
Hence, I assumed that I would chop off the last character, increment it by 1, ASCII for '1' = 49 to get '2' fron ASCII 50 and then add it back to get the new name.
Char = Right$ (File_Name,1)
Char[0] = Char[0] + 1
Len = Length$ (File_Name)
File_Name = Left$ (File_Name, (Len - 1))
File_Name = File_Name + Char
File_Name_String = File_Name + ".csv"
what I get is test01.csv goes to test0ß.csv and then test0Ó.csv
What am I doing wrong? Is there a simpler way to do this?
Thanks,
Mark