User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 18

Thread: Strings (basic_string) in Extensions?

  1. #1
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2006
    Location
    Britain, South Coast
    Posts
    1,030
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Strings (basic_string) in Extensions?

    Excuse my newbie denseness, but how do I use the basic_string class in rSDK? I'm keen to use it to make string manipulation a lot easier, but I'm lost.

    Any helps would be appreciated!

  2. #2
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2006
    Location
    Britain, South Coast
    Posts
    1,030
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Strings (basic_string) in Extensions?

    Got it. Make sure you #include <string> and either use namespace "std" or prepend 'std' before any string functions, like:

    std::string szMyString;

    Now... how would I store a vector in RunData? I'm not sure what kind of datatype to provide it...

  3. #3
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Strings (basic_string) in Extensions?

    The best way is to store a pointer to the vector in rundata, and new it in CreateRunObject in Runtime.cpp and delete it in DestroyRunObject.

    Check out the source to ValueAdd, it uses both vectors and strings, could help.
    EDIT: What am I talking about? It uses a map not a vector. Similar idea though. A vector of strings would be: std::vector<std::string>. I recommend using typedef to save yourself the headache of typing that repeatedly.

  4. #4
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: Strings (basic_string) in Extensions?

    Check out this thread:
    http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=201326#Post2013 26

    Apparently this must be done because MMF2 only calls the CreateRunObject and DestroyRunObject functions, and it doesn't call any constructors otherwise.

    Also, I have a couple nifty macros for you for getting parameters to std::string
    Code:
    #ifdef _STRING_
    	#define StrParam() string((char *)Param(TYPE_STRING))
    	#define EStrParam() string((char *)ExParam(TYPE_STRING))
    #endif //_STRING_
    Just put this at the top of your Main.cpp file

    You can prepend it with std:: if you didn't do using namespace std;

    Then all you have to do to get a string parameter for a condition or action is MyString = StrParam(); and for an expression, MyString = EStrParam();
    Working as fast as I can on Fusion 3

  5. #5
    Firecodemonkey

    Join Date
    Aug 2006
    Location
    London, UK
    Posts
    461
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Strings (basic_string) in Extensions?

    LB, you should prefix the string in your macro with std:: anyway, that way it will work without using namespace std;

  6. #6
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module

    Join Date
    Jun 2006
    Posts
    6,773
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Strings (basic_string) in Extensions?

    It's cleaner to create your own structure and store a pointer to that in rdPtr, creating in CreateRunObject and deleting it in DestroyRunObject. Any objects in that structure will have their constructors/destructors called (of course), and it also makes it easier to make your object global in the future.

  7. #7
    No Products Registered

    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Strings (basic_string) in Extensions?

    I stored mine in a vector by adding:
    #include <string>
    using namespace std;

    at the top of my header file.
    Then just store a pointer to it in RunData.
    I actually stored mine in my own class object so all I do it delete my class in DestroyRunObject and the destructor handles everything else (pretty much what jamie said)

  8. #8
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2006
    Location
    Britain, South Coast
    Posts
    1,030
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Strings (basic_string) in Extensions?

    Thanks guys!

    When you want to store raw binary data, what data type would you use?

  9. #9
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: Strings (basic_string) in Extensions?

    I don't know what the best thing to do is, but maybe vector<char> ?

  10. #10
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Strings (basic_string) in Extensions?

    char is the traditional "byte" type because C never defined a "byte" type.
    VC++ has the __int8 type, which makes more sense to use. unsigned __int8 is probably even better.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Value of all strings is zero?
    By RayRayTea in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 9th September 2011, 04:38 AM
  2. Extensions that Display Text/Strings
    By ProdigyX in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 22nd June 2011, 08:19 PM
  3. Scan Global Strings and Other strings
    By Ausomeman in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 19th May 2010, 05:01 PM
  4. Strings
    By whiptcream13 in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 31st August 2008, 10:14 AM
  5. Using Global Strings embedded in larger strings
    By Mudstick in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 12th May 2008, 02:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •