Returning a string in c++ UO as UO Parameter
Re: Returning a string in c++ UO as UO Parameter
Perhaps you can add all known python versions to the list?
-
- Posts: 19
- Joined: 01 February 2022, 10:14
Re: Returning a string in c++ UO as UO Parameter
I hoped that I could avoid this, but there seems to be no other way.
For the record, here are my changes to get_OptionList and get_RestrictedToList:
I think this solves this issue.
The clue was that one has to specify all possible string values in get_OptionList in order to display one of them in Pro-II.
Many thanks Jasper for your help!
For the record, here are my changes to get_OptionList and get_RestrictedToList:
Code: Select all
STDMETHOD(get_OptionList)(VARIANT* v)
{
// This function specifies all allowed version numbers.
// Pro-II displays only version numbers, which are allowed by this function.
// set type to string array
v->vt = VT_ARRAY | VT_BSTR;
// specify allowed versions
vector<BSTR> allowed_versions = { SysAllocString(L"x.y.z") };
for(unsigned int major = 0; major <=2; major++)
{
for (unsigned int minor = 0; minor <= 11; minor++)
{
for (unsigned int bugfix = 0; bugfix <= 11; bugfix++)
{
// build version STL string
string version_STLstring = to_string(major) + "." + to_string(minor) + "." + to_string(bugfix);
// convert STL string to BSTR and append to vector
CComBSTR temp(version_STLstring.c_str());
allowed_versions.push_back(temp.Detach());
}
}
}
// write allowed versions to output parameter
v->parray = SafeArrayCreateVector(VT_BSTR, 0, (unsigned int) allowed_versions.size()); // start indexing at 0
long i = 0;
for (vector<BSTR>::iterator it = allowed_versions.begin(); it != allowed_versions.end(); it++, i++ )
{
SafeArrayPutElement(v->parray, &i, *it);
}
return NOERROR;
}
STDMETHOD(get_RestrictedToList)(VARIANT_BOOL * vb)
{
*vb = VARIANT_TRUE;
return NOERROR;
}
The clue was that one has to specify all possible string values in get_OptionList in order to display one of them in Pro-II.
Many thanks Jasper for your help!
Re: Returning a string in c++ UO as UO Parameter
Glad to hear it works now.