Author Topic: Trimming Text  (Read 703 times)

Is there some sort of function to trim the text out of a string? For example, I want to use the string of an item icon, but I want to get rid of the png. Icon = base/client/ui/icons/ItemIcon.png How would I get rid of the.png part?

This is a useful resource: http://docs.garagegames.com/tge/official/content/documentation/Reference/Console%20Functions/TorqueScript_Console_Functions_7.html

Anyway, your code would look like this:
Code: [Select]
%file = "base/client/ui/icons/ItemIcon.png";
%icon = filePath(%file) @ "/" @ fileBase(%file);

try strReplace()

I'm rusty enough on torquescript to not remember the syntax, but i think the arguments are text to find, text to replace with, string to search in

Or use greek2me's option if the string is always a file path.

Yes, my code assumes that it's a file path.