fileNAME = '1'; how increment this number text ??? [solved]

hi guys.


I have this 


fileNAME = '1';


fileNAME = '1';





How increment the number text ?


ex:


fileNAME = '1' ++;


Tanksx
Uhhh, may I ask why you're using a string if it's only going to be a number? It would be easier just to make it a number...


If you're intent on sticking with a string, all letters are represented by a number in memory, so you can use the String class' fromCharCode() to create a letter from a number, and charCodeAt(index) to get the character code of letter index from the string. 
If you want to  do that, turn it into a number so:


fileName =  Number("1");


fileName++;
If you want to  do that, turn it into a number so:


fileName =  Number("1");


fileName++;

That will work, but at that point why leave it as a string at all? It's not as efficient to get the numeric value of a string and then change it as just starting from a numeric value. Plus your code never puts it back into a string again  😛 (I assume he wanted it as a string before? Still not sure why numbers are the preferred type in this case to be honest) 
If you want to  do that, turn it into a number so:


fileName =  Number("1");


fileName++;


Uhhh, may I ask why you're using a string if it's only going to be a number? It would be easier just to make it a number...


If you're intent on sticking with a string, all letters are represented by a number in memory, so you can use the String class' fromCharCode() to create a letter from a number, and charCodeAt(index) to get the character code of letter index from the string. 



In need increment the string text,


Here full script

Code:
// Listing item menu
// Listi= test premiere list
Itemlist = 1; // test itemid 1 in DB
Listi=1; // List loop (while) Listi/ max item show in screen
Pid = 100; // Picture id (100-1 eatch loop)
Xitem = 0; // X coor for the item + picturesize+ marge
Yitem = 0; // Y coor for the item + picturesize+ marge
InpicX = 46; // Initial X of menue item list
InpicY = 186; // Initial Y of menue item list
MargeX = 7; // Marge bettwenn 2 picture X 
MargeY = 6; // Marge bettwenn 2 picture Y
ISIZEX = 82; // X size of picture
ISIZEY = 82; // X size of picture
fileNAME = '1';// identifie le nom fichier 1,2,3,4,5,6 .....
PIDNAME = 0 // identifie le nom de limage a id de limage 
// Test if have item
while(Listi<=36){
if (($gameParty.hasItem($dataItems[Itemlist])==true || $dataItems[Itemlist].itypeId !== 2) || $dataItems[Itemlist].itypeId !== 3){
$gameScreen.showPicture(Pid, fileNAME, 0, InpicX+Xitem, InpicY+Yitem, 100, 100, 255, 0);
$gameScreen.setPictureCallCommon(Pid, 21, 1);
// cré une variable PIDNAME [X] selon le pid ex: si clic sur image 200 , variable volatile PIDNAME= LE NOM DE FICHIER 
PIDNAME[Pid] = $gameScreen._pictures[Pid]._name;
  
  -------------fileNAME++ here i need to increamente --------------------------
    
if (Listi==12 || Listi==24  || Listi==36) {
	Xitem=0; Yitem+=ISIZEY+MargeY; Itemlist++; Listi++; Pid++;
}else{Xitem+=ISIZEX+MargeX; Itemlist++; Listi++; Pid++;}
}else {Itemlist++;}}
If you want to  do that, turn it into a number so:


fileName =  Number("1");


fileName++;

fileName++;


give me a error


fileName is not defined ??
ok tanks now is work.

Code:
fileNames = ("1");
fileNames = Number(fileNames); 
fileNames++; 
fileNames = String(fileNames);
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/filename-1-how-increment-this-number-text-solved.64976/