User Tag List

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

Thread: Concactinating Strings

  1. #1
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Jaffob's Avatar
    Join Date
    May 2008
    Location
    USA
    Posts
    1,833
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Concactinating Strings

    This should be my last ExtDev question before an extension release.

    I have tried numerous ways to concactinate two strings, but they all eventually fail. They either don't compile, crash the app, or return something strange.

    In an expression, I need to retrieve a string parameter. I must concactinate a string to it then return it as the output of the expression.

    Thanks again.

  2. #2
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export ModuleUnicode Add-on
    Looki's Avatar
    Join Date
    Aug 2006
    Location
    Karlsruhe, Germany
    Posts
    3,741
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)

    Re: Concactinating Strings

    Are you able to return a string + using a string parameter at all? I had crashing issues with that before... I'm not really an advanced programmer so I don't think I can help you. I just know that ReturnString expects a const char*... but that shouldn't make it crash.

  3. #3
    No Products Registered

    Join Date
    Jul 2006
    Posts
    379
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Concactinating Strings

    Two possible errors:
    1. When returning a string, you must set the correct flags to make mmf understand it's a string.

    2. If you create a std::string and return it (or actually the address to the string, c_str()), the object will be destroyed and mmf will try to access freed memory.

  4. #4
    Clicker Multimedia Fusion 2 Developer

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

    Re: Concactinating Strings

    There is some function you can call to get MMF to allocate the memory for the string you are going to return, and MMF will free it once it's done with it. You should use that.

  5. #5
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Jaffob's Avatar
    Join Date
    May 2008
    Location
    USA
    Posts
    1,833
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Concactinating Strings

    What function should I use?

  6. #6
    No Products Registered

    Join Date
    Jul 2006
    Location
    Umeå, Sweden
    Posts
    1,090
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Concactinating Strings

    if you use rSDK, ReturnStringSafe(str); should work...

  7. #7
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Jaffob's Avatar
    Join Date
    May 2008
    Location
    USA
    Posts
    1,833
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Concactinating Strings

    My code:

    Code:
    EXPRESSION(
    	/* ID */			0,
    	/* Name */			"Name(",
    	/* Flags */			EXPFLAG_STRING,
    	/* Params */		(1,EXPPARAM_STRING,"Parameter")
    ) {
    	char * str1 = (char *)"1st String"
    	char * str2 = (char *)ExParam(TYPE_STRING);
    	const char * str3 = strcat(str1,str2);
    	ReturnStringSafe(str3);
    }
    I test this by creating a String Object and, on startup, setting it to my object's expression using a random parameter. The application crashes at the start of the frame.

  8. #8
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module

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

    Re: Concactinating Strings

    You can't do that. str1 is set to a constant, in write protected memory. It should crash on strcat.

    You could use strdup("1st String").

  9. #9
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Jaffob's Avatar
    Join Date
    May 2008
    Location
    USA
    Posts
    1,833
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Concactinating Strings

    Sorry, I don't understand what to do with the function you gave me. Where do I put it?

  10. #10
    No Products Registered

    Join Date
    May 2008
    Location
    California
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Concactinating Strings

    Quote Originally Posted by Jaffob
    char * str1 = (char *)"1st String"
    Missing a semi-colon
    (Probably not the solution)

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, 03:38 AM
  2. Scan Global Strings and Other strings
    By Ausomeman in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 19th May 2010, 04:01 PM
  3. Using Global Strings embedded in larger strings
    By Mudstick in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 12th May 2008, 01:23 PM
  4. Help me with strings! =)
    By gum in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 19th November 2006, 06:33 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
  •