Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 06-28-2018, 04:20 AM   #1
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default Can C++ extensions call SetExtState? Scripts hangs when I try it.

I am trying to write a C++ API function that would return a string in an ExtState.

Everything builds OK, but when I call the function from a Lua script, the script and IDE hangs indefinitely.

For example, if I call this function from a script using MyFunction("testing"), the console message pops up (demonstrating that the string is passed to the API function) and then the script hangs:
Code:
void MyFunction(const char* myString)
{
    ShowConsoleMsg(myString);
    SetExtState(myString, myString, myString, 1);
}
If I do it the other way around, execution doesn't even reach the ShowConsoleMsg:
Code:
void MyFunction(const char* myString)
{
    SetExtState(myString, myString, myString, 1);
    ShowConsoleMsg(myString);
}
If I close the IDE and try to run the script from the action list, I get the popup message that the script is already running, asking whether I would like to terminate the script or open a new instance.
juliansader is offline   Reply With Quote
Old 06-28-2018, 06:31 AM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

SetExtState works here when using directly from C++ code.

Maybe there's some issue with the string you are passing into it? (Is it properly zero-terminated?) Maybe it doesn't like that the same string is passed 3 times into it? What happens if you call it properly with a different string for each parameter?
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 06-28-2018, 08:13 AM   #3
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

You're working in SWS extensions right ?

If so, SetExtState() and GetExtState() are currently not initialized in sws_extensions.cpp.
You'd need to manually add them using the IMPAPI macro.

I fell for the same trap when starting out (thanks Xenakios):
https://forum.cockos.com/showthread.php?t=176204
nofish is offline   Reply With Quote
Old 06-28-2018, 08:45 AM   #4
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by nofish View Post
You're working in SWS extensions right ?

If so, SetExtState() and GetExtState() are currently not initialized in sws_extensions.cpp.
You'd need to manually add them using the IMPAPI macro.

I fell for the same trap when starting out (thanks Xenakios):
https://forum.cockos.com/showthread.php?t=176204
This fixed it, thanks!
juliansader is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:21 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.