User Tag List

Results 1 to 4 of 4

Thread: Working with strings in expressions

  1. #1
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)

    Join Date
    Feb 2016
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Working with strings in expressions

    Hello.

    I tried to create my own extension. It worked fine with passing and returning numbers in expressions. But how to do this with strings? I thought p1 was the memory address pointing to the string. But my code outputs nothing (empty string). What do I do wrong?

    Code:
    short expressionsInfos[]=
    		{
    		IDMN_EXPRESSION, M_EXPRESSION, EXP_EXPRESSION, EXPFLAG_STRING, 1, EXPPARAM_STRING, 0,
    		
    		//Note in the following.  If you are returning a string, you set the EXPFLAG_STRING.	
    		IDMN_EXPRESSION2, M_EXPRESSION2, EXP_EXPRESSION2, EXPFLAG_STRING, 1, EXPPARAM_STRING, 0,
    		
    		//Note in the following.  If you are returning a float, you set the EXPFLAG_DOUBLE
    		IDMN_EXPRESSION3, M_EXPRESSION3, EXP_EXPRESSION3, EXPFLAG_DOUBLE, 1, EXPPARAM_LONG, 0,
    		};
    
    
    
    long WINAPI DLLExport Expression2(LPRDATA rdPtr,long param1)
    {
    
    	long p1 = CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_STRING);
    	
    	std::string str(*(std::string*)p1);
    
    	str = "changed text";
    
    	long addr = (long)&str;
    
    	rdPtr->rHo.hoFlags |= HOF_STRING;
    
    	return addr;
    
    }

  2. #2
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Fusion doesn't use std::string internally. You need to cast to char const * and construct a std::string from that. For example:

    Code:
    std::string str = reinterpret_cast<char const *>(p1);
    By the way, I highly recommend you do not use the original extension SDK and instead use the official EDIF SDK or my modified fork of EDIF - EDIF makes the extension development process much simpler and less error-prone.
    Working as fast as I can on Fusion 3

  3. #3
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)

    Join Date
    Feb 2016
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm using EDIF now. Tried to select a window by its unicoded window title, but it always returns 0: (tested the same with char*, it all worked, but it doesnt handle unicode)

    In Expressions.cpp
    Code:
    int Extension::HelloWorld(const wchar_t * str_in)
    {
     
        HWND win = FindWindowW(0, str_in);
     
        if (win != 0) {
     
            ShowWindow(win, SW_RESTORE);
            ShowWindow(win, SW_SHOW);
            SetForegroundWindow(win);
            SetCapture(win);
            SetFocus(win);
            SetActiveWindow(win);
     
            return 1;
        }
     
        return 0;
    }
    Extension.h:
    Code:
    int HelloWorld(const wchar_t * str_in);
    Ext.json:
    Code:
    {
                "Title": "HelloWorld$(",
              "Returns": "Integer",
                    "Parameters":
            [
    			["Text", "Your text"]
            ]
            }

  4. #4
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)

    Join Date
    Feb 2016
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Needed to change runtime to unicode runtime in projects' configuration. That fixed it.

Similar Threads

  1. Using expressions in strings?
    By YAS in forum Multimedia Fusion 2 - Technical Support
    Replies: 14
    Last Post: 14th January 2016, 09:07 AM
  2. Strings & their Expressions?
    By sheppard1 in forum Fusion 2.5
    Replies: 1
    Last Post: 25th July 2014, 05:54 PM
  3. How to use quotes in expressions without them ending strings?
    By Pecon7 in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 30th October 2011, 12:09 AM
  4. FastFunction not returning strings in expressions
    By jdv in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 9th April 2009, 02:42 PM
  5. strings and expressions
    By taciturn in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 22nd September 2008, 02:37 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
  •