String question
by Very Interactive Person · in Torque Game Engine · 07/19/2003 (9:03 am) · 9 replies
How would i convert for example this string:
"fps/data/missions/planet1.mis"
to
"planet1"
I tried some stuff, but I seem to be missing some essential string functions (probably they are there, but I don't know what their called ;) )
"fps/data/missions/planet1.mis"
to
"planet1"
I tried some stuff, but I seem to be missing some essential string functions (probably they are there, but I don't know what their called ;) )
#2
But its not exactly what i'm looking for.
That function would return "fps/data/missions/planet1" for the above mentioned string... and it wouldn't work if there's some junk chars at the beginning of the string. Right?
Let me explain a bit better. I want to do a substring, but I need to find the last occurencce of "/" and the last occurence of "." Then I do a substring starting at "/" and ending at the "." position. So, I checked the docs, and I find functions to find the first occurence of chars, but not the last! So how would I do this in Torque scripts?
07/20/2003 (12:21 am)
Thanks Melv,But its not exactly what i'm looking for.
That function would return "fps/data/missions/planet1" for the above mentioned string... and it wouldn't work if there's some junk chars at the beginning of the string. Right?
Let me explain a bit better. I want to do a substring, but I need to find the last occurencce of "/" and the last occurence of "." Then I do a substring starting at "/" and ending at the "." position. So, I checked the docs, and I find functions to find the first occurence of chars, but not the last! So how would I do this in Torque scripts?
#3
I just typed the following into Torque:-
echo( filebase("strategem/client/ui/skins/playRealmGui/viewTome.png") );
and it returns "viewTome".
Isn't this what you wanted?
filePath returns the string you mention e.g. "strategem/client/ui/skins/playRealmGui".
Torque uses this syntax:\.
- Melv.
07/20/2003 (1:51 am)
Ward,I just typed the following into Torque:-
echo( filebase("strategem/client/ui/skins/playRealmGui/viewTome.png") );
and it returns "viewTome".
Isn't this what you wanted?
filePath returns the string you mention e.g. "strategem/client/ui/skins/playRealmGui".
Torque uses this syntax:
- Melv.
#4
Anyway, thanks, this should help me forward.
07/20/2003 (3:17 am)
Hmmz... then the documentation is wrong. This is what I found in the docs:Quote:
fileBase(filename)
-Used to return the base name of the file specified by filename
-Returns a string
fileBase("/fps/client/scripts/script.cs"); // will return "fps/client/scripts/script" as a string
Anyway, thanks, this should help me forward.
#5
I've just looked at the code for filebase (which I won't post here because it's the public area) and it does what I said.
Just try it bud. :)
- Melv.
07/20/2003 (4:01 am)
Ward,I've just looked at the code for filebase (which I won't post here because it's the public area) and it does what I said.
Just try it bud. :)
- Melv.
#6
07/20/2003 (4:16 am)
Sure, I believe you, I'll try it when I get home. Just pointed out the docs are wrong then and someone might want to update them.
#7
Which docs are you referring to? Perhaps I should drop them a message to update them.
If I ever want to know if a function is available, I normally search for references to the C-Runtime function in the codebase with a 'd' prefix e.g. 'Strrchr' becomes the abstracted 'dStrrchr'. Crude but effective. :)
- Melv.
07/20/2003 (4:25 am)
Ward,Which docs are you referring to? Perhaps I should drop them a message to update them.
If I ever want to know if a function is available, I normally search for references to the C-Runtime function in the codebase with a 'd' prefix e.g. 'Strrchr' becomes the abstracted 'dStrrchr'. Crude but effective. :)
- Melv.
#8
07/20/2003 (4:28 am)
On the GG site--> Torque game engine --> documentation --> scripting reference
#9
07/20/2003 (12:26 pm)
I'll see about correcting that when I get in tomorrow.
Associate Melv May
There's loads of different file functions you can use... (I've highlighted the one you want for your problem)
You can find these and more in "consoleFunctions.cc".
Hope this helps,
- Melv.