Page 3 of 3

Re: Returning a string in c++ UO as UO Parameter

Posted: 14 April 2022, 18:05
by jasper
Perhaps you can add all known python versions to the list?

Re: Returning a string in c++ UO as UO Parameter

Posted: 19 April 2022, 08:37
by SLiebschner
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:

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;
	}
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!

Re: Returning a string in c++ UO as UO Parameter

Posted: 19 April 2022, 13:04
by jasper
Glad to hear it works now.