Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
Lapsa's very own thread
by rki. 06/19/24 11:27
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, TipmyPip), 844 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mino, squik, AemStones, LucasJoshua, Baklazhan
19061 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Compare part of a char*. #370743
05/15/11 12:51
05/15/11 12:51
Joined: Apr 2011
Posts: 75
Malta
E
Ercoles Offline OP
Junior Member
Ercoles  Offline OP
Junior Member
E

Joined: Apr 2011
Posts: 75
Malta
I have a CHAR* gotten from file_dialog command I need to check the string in this CHAR* to see if it ends with ".ssv" or not, any suggestions?

Re: Compare part of a char*. [Re: Ercoles] #370757
05/15/11 14:06
05/15/11 14:06
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
You can use Lite Foundations string class for this:
Code:
LFStringRef lfString = LFStringWithCString(yourCString);
if(LFStringHasSuffix(lfString, LFSTR(".ssv"))
{
   // Here comes your code...
}



(Beside that, you can also compare any other range with Lite Foundations string class)



Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Compare part of a char*. [Re: WretchedSid] #370761
05/15/11 14:29
05/15/11 14:29
Joined: Apr 2011
Posts: 75
Malta
E
Ercoles Offline OP
Junior Member
Ercoles  Offline OP
Junior Member
E

Joined: Apr 2011
Posts: 75
Malta
What include file or external packet do i need to install to use this command?

Re: Compare part of a char*. [Re: Ercoles] #370763
05/15/11 14:32
05/15/11 14:32
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Just download Lite Foundation and put it into your projects folder. You just need to include "LiteFoundation.h" and call LFRuntimeInit() at startup.
Download link: http://cl.ly/6ghG

The example files show you how to include it correctly (Arrays.c, Strings.c, Sets.c or Scanner.c)


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Compare part of a char*. [Re: WretchedSid] #370765
05/15/11 14:38
05/15/11 14:38
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck

Re: Compare part of a char*. [Re: Slin] #370768
05/15/11 14:41
05/15/11 14:41
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Not really, because the searched suffix can also be in the middle of the string and the Gstudio function would happily return true wink


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Compare part of a char*. [Re: WretchedSid] #370770
05/15/11 14:49
05/15/11 14:49
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
It is still easier to use str_stri...
Code:
if(str_stri(yourstring, ".ssv"))
{
//do something
}


Nothing else needed.

Re: Compare part of a char*. [Re: Slin] #370772
05/15/11 14:57
05/15/11 14:57
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Sure its easier but again, its more likely to break plus Lite Foundations string class is a bit faster because it starts the search at the very end and not at the very beginning like Gstudios function (thats not really noticeable but worth noting imo).

Another thing is: When he gets used to LF now, he can later adopt it more easily and LFs string class together with the other classes is way more powerful than Gstudios implementations.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1