diff --git a/API_MachMgr.cpp b/API_MachMgr.cpp index 7d8c172..840327e 100644 --- a/API_MachMgr.cpp +++ b/API_MachMgr.cpp @@ -970,7 +970,7 @@ __stdcall EgtTdbImport( const wchar_t* wsFile, const wchar_t* wsToolsToImport, c sImported += sName ; } wsImported = _wcsdup( stringtoW( sImported)) ; - return (( wsToolsNames == nullptr) ? FALSE : TRUE) ; + return (( wsImported == nullptr) ? FALSE : TRUE) ; } //----------------------------------------------------------------------------- @@ -1250,6 +1250,79 @@ __stdcall EgtMdbGetMachiningDir( wchar_t*& wsMchDir) return (( wsMchDir == nullptr) ? FALSE : TRUE) ; } +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtMdbExport( const wchar_t* wsMachiningsNames, const wchar_t* wsOutFile) +{ + STRVECTOR vsMachiningsNames ; + if ( ! Tokenize( string( wstrztoA( wsMachiningsNames)), "\n", vsMachiningsNames)) + return FALSE ; + return( ExeMdbExport( vsMachiningsNames, string( wstrztoA( wsOutFile))) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtMdbToBeImported( const wchar_t* wsFile, wchar_t*& wsMachiningsNames, int*& vTypes, int* pnCount) +{ + if ( &wsMachiningsNames == nullptr || &vTypes == nullptr || pnCount == nullptr) + return FALSE ; + STRVECTOR vsMachiningsNames ; + INTVECTOR vMachiningsTypes ; + if ( ! ExeMdbToBeImported( string( wstrztoA( wsFile)), vsMachiningsNames, vMachiningsTypes)) + return FALSE ; + // restituzione vettore nomi + string sMachiningsNames ; + for ( const auto& sName : vsMachiningsNames) { + if ( ! sMachiningsNames.empty()) + sMachiningsNames += "\n" ; + sMachiningsNames += sName ; + } + wsMachiningsNames = _wcsdup( stringtoW( sMachiningsNames)) ; + if ( wsMachiningsNames == nullptr) + return FALSE ; + // restituzione vettore tipi + int nDim = int( vMachiningsTypes.size()) ; + if ( nDim == 0) { + vTypes = nullptr ; + } + else { + vTypes = (int*) malloc( nDim * sizeof( int)) ; + if ( vTypes == nullptr) { + free( wsMachiningsNames) ; + return FALSE ; + } + for ( int i = 0 ; i < nDim ; ++ i) + vTypes[i] = vMachiningsTypes[i] ; + } + *pnCount = nDim ; + return TRUE ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtMdbImport( const wchar_t* wsFile, const wchar_t* wsMachiningsToImport, const wchar_t* wsMachiningsNames, wchar_t*& wsImported) +{ + if ( &wsImported == nullptr) + return FALSE ; + STRVECTOR vsMachiningsToImport ; + if ( ! Tokenize( string( wstrztoA( wsMachiningsToImport)), "\n", vsMachiningsToImport)) + return FALSE ; + STRVECTOR vsMachiningsNames ; + if ( ! Tokenize( string( wstrztoA( wsMachiningsNames)), "\n", vsMachiningsNames)) + return FALSE ; + STRVECTOR vsImported ; + if ( ! ExeMdbImport( string( wstrztoA( wsFile)), vsMachiningsToImport, vsMachiningsNames, vsImported)) + return FALSE ; + string sImported ; + for ( const auto& sName : vsImported) { + if ( ! sImported.empty()) + sImported += "\n" ; + sImported += sName ; + } + wsImported = _wcsdup( stringtoW( sImported)) ; + return (( wsImported == nullptr) ? FALSE : TRUE) ; +} + //----------------------------------------------------------------------------- // Operations //----------------------------------------------------------------------------- diff --git a/EgtInterface.rc b/EgtInterface.rc index fcdb79e..55ef503 100644 Binary files a/EgtInterface.rc and b/EgtInterface.rc differ