// Send the received command to Audacity and build an array of response lines. // The response lines can be retrieved by calling DoSrvMore repeatedly. int DoSrv(char *pIn) { // Interpret string as unicode. // wxWidgets (now) uses unicode internally. // Scripts must send unicode strings (if going beyond 7-bit ASCII). // Important for filenames in commands. wxString Str1(pIn, wxConvUTF8); Str1.Replace( wxT("\r"), wxT("")); Str1.Replace( wxT("\n"), wxT("")); Str2 = wxEmptyString; (*pScriptServerFn)( &Str1 , &Str2); Str2 += wxT('\n'); size_t outputLength = Str2.Length(); aStr.Clear(); size_t iStart = 0; size_t i; for(i = 0; i < outputLength; ++i) { if( Str2[i] == wxT('\n') ) { aStr.Add( Str2.Mid( iStart, i-iStart) + wxT("\n") ); iStart = i+1; } } currentLine = 0; currentPosition = 0; return 1; }
// Send the received command to Audacity and build an array of response lines. // The response lines can be retrieved by calling DoSrvMore repeatedly. int DoSrv(char *pIn) { wxString Str1(pIn, wxConvISO8859_1); Str1.Replace( wxT("\r"), wxT("")); Str1.Replace( wxT("\n"), wxT("")); Str2 = wxEmptyString; (*pScriptServerFn)( &Str1 , &Str2); Str2 += wxT('\n'); size_t outputLength = Str2.Length(); aStr.Clear(); size_t iStart = 0; size_t i; for(i = 0; i < outputLength; ++i) { if( Str2[i] == wxT('\n') ) { aStr.Add( Str2.Mid( iStart, i-iStart) + wxT("\n") ); iStart = i+1; } } currentLine = 0; currentPosition = 0; return 1; }
void * ExecForLisp( char * pIn ){ wxString Str1( pIn ); wxString Str2; ExecCommand2( &Str1, &Str2 ); // wxString provides a const char * //const char * pStr = static_cast<const char*>(Str2); // We'll be passing it as a non-const unsigned char * // That 'unsafe' cast is actually safe. nyq_make_opaque_string is just copying the string. void * pResult = nyq_reformat_aud_do_response( Str2 ); return pResult; };
// Do serv sends the command back to the script server function, // and creates a list of response lines to be sent. int DoSrv( char * pIn ) { wxString Str1(pIn); Str1.Replace("\r",""); Str1.Replace("\n",""); (*pScriptServerFn)( &Str2, &Str1 ); int l = Str2.Length(); Str2+= '\n'; aStr.Clear(); iSent = -1; int iStart = 0; int i; for(i=0;i<=l;i++) { if( Str2[i] == '\n' ) { aStr.Add( Str2.Mid( iStart, i-iStart) ); iStart = i+1; } } // wxLogDebug("Added %i Strings", aStr.GetCount()); return 1; }