@thabit79BL3 wrote:
... I need an operation (if there is one) that replaces (or adds 1) in evry STRING last char.
....
If STRING is a variable that contains something like "FC1" from the User, but the "root" of that might not always be "FC", and assuming the "last char." may be [or may become] more than one character [once it gets up to 10 and beyond], but always represents an integer that can be incremented, try an approach like this [I leave it to you to incorporate into your other code]:
Command: (setq string "FC1"); assuming it comes from the User this way
"FC1"
Command: (setq root (vl-string-right-trim "0123456789" string)); lop off numerical end
"FC"
Command: (setq inc (atoi (substr string (1+ (strlen root))))); numerical end converted to number
1
Command: (setq newTag (strcat root (itoa (setq inc (1+ inc))))); increment and add as suffix to root
"FC2"
Command: (setq newTag (strcat root (itoa (setq inc (1+ inc))))); and again, etc.
"FC3"
Another example with different starting conditions:
Command: (setq string "ABC123")
"ABC123"
Command: (setq root (vl-string-right-trim "0123456789" string))
"ABC"
Command: (setq inc (atoi (substr string (1+ (strlen root)))))
123
Command: (setq newTag (strcat root (itoa (setq inc (1+ inc)))))
"ABC124"
Command: (setq newTag (strcat root (itoa (setq inc (1+ inc)))))
"ABC125"
Kent Cooper, AIA