当前位置: 首页>>代码示例>>C++>>正文


C++ COleSafeArray::PutElement方法代码示例

本文整理汇总了C++中COleSafeArray::PutElement方法的典型用法代码示例。如果您正苦于以下问题:C++ COleSafeArray::PutElement方法的具体用法?C++ COleSafeArray::PutElement怎么用?C++ COleSafeArray::PutElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在COleSafeArray的用法示例。


在下文中一共展示了COleSafeArray::PutElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetGlobalOptionList

VARIANT CMUSHclientApp::GetGlobalOptionList() 
{
  COleSafeArray sa;   // for list
  long i, count = 0;

  // count them
  for (i = 0; GlobalOptionsTable [i].pName; i++)
    count++;

  for (i = 0; AlphaGlobalOptionsTable [i].pName; i++)
    count++;

  sa.CreateOneDim (VT_VARIANT, count);
  count = 0;

  // put the numeric option names into the array
  for (i = 0; GlobalOptionsTable [i].pName; i++)
    {
    // the array must be a bloody array of variants, or VBscript kicks up
    COleVariant v ((LPCTSTR) GlobalOptionsTable [i].pName);
    sa.PutElement (&count, &v);
    count++;
    }      // end of looping through each option

  // put the alpha option names into the array
  for (i = 0; AlphaGlobalOptionsTable [i].pName; i++)
    {
    // the array must be a bloody array of variants, or VBscript kicks up
    COleVariant v ((LPCTSTR) AlphaGlobalOptionsTable [i].pName);
    sa.PutElement (&count, &v);
    count++;
    }      // end of looping through each option

	return sa.Detach ();
}
开发者ID:WillFa,项目名称:mushclient,代码行数:35,代码来源:globalregistryoptions.cpp

示例2: GetWorldIdList

VARIANT CMUSHclientDoc::GetWorldIdList() 
{
  COleSafeArray sa;   // for list

  CMUSHclientDoc * pDoc;
  long iCount = 0;
  POSITION pos;

  // count number of worlds
  for (pos = App.m_pWorldDocTemplate->GetFirstDocPosition(); pos != NULL; iCount++)
    pDoc = (CMUSHclientDoc *) App.m_pWorldDocTemplate->GetNextDoc(pos);

  if (iCount) // cannot create empty array dimension
    {
    sa.CreateOneDim (VT_VARIANT, iCount);
  
    // put the worlds into the array
    for (iCount = 0, pos = App.m_pWorldDocTemplate->GetFirstDocPosition(); pos != NULL; iCount++)
      {
      pDoc = (CMUSHclientDoc *) App.m_pWorldDocTemplate->GetNextDoc(pos);

      // the array must be a bloody array of variants, or VBscript kicks up
      COleVariant v (pDoc->m_strWorldID);
      sa.PutElement (&iCount, &v);
      }      // end of looping through each world
    } // end of having at least one

	return sa.Detach ();
}   // end of CMUSHclientDoc::GetWorldIdList
开发者ID:RKelson93,项目名称:mushclient,代码行数:29,代码来源:methods_worlds.cpp

示例3: GetForcesAndTorques

// returns a new 7-element array of doubles containing Force and Torque measurements
int FTWrapper::GetForcesAndTorques(double output[7])
{
	if (status == ALL_READY) {
		// this array is used to create the COleSafeArray below
		// it is used to indicate that there are 7 elements in the first diemnsion
		DWORD numElements[] = {7};
		COleSafeArray voltages;
		// VT_R8 represents an 8-byte real, i.e. a double in C++
		// there is 1 dimension with a size of 'numElements[0]'
		voltages.Create(VT_R8, 1, numElements);

		double ft_voltages[7];
		int mDAQstatus = mDAQSys->ScanGauges(ft_voltages, false);
		long i;
		for(i=0;i<7;i++) {
			// COleSafeArrays use pass-by-reference methods to read or write
			voltages.PutElement(&i,&(ft_voltages[i]));
		}
		// this method uses the calibration matrix (and possibly temperature compensation)
		// to convert the 6 gauge readings into forces and torques
		COleSafeArray forces = GetActiveCalibration().ConvertToFT(voltages,"lb","in-lb");
		for (i=0; i<6; i++) {
			// COleSafeArrays use pass-by-reference methods to read or write
			forces.GetElement(&i,&(output[i]));
		}
		// copy the thermistor voltage over to the output for display
		output[6] = ft_voltages[6];
		return mDAQstatus;
	}
	else {
		return -2;
	}
}
开发者ID:senlin-hust,项目名称:RB-Robot-test-app,代码行数:34,代码来源:FTWrapper.cpp

示例4: WindowList

// return list of windows we have made
VARIANT CMUSHclientDoc::WindowList() 
{
  COleSafeArray sa;   // for array list

  long iCount = 0;
  
  // put the arrays into the array
  if (!m_MiniWindows.empty ())    // cannot create empty dimension
    {
    sa.CreateOneDim (VT_VARIANT, m_MiniWindows.size ());

    for (MiniWindowMapIterator it = m_MiniWindows.begin (); 
         it != m_MiniWindows.end ();
         it++)
           {
            // the array must be a bloody array of variants, or VBscript kicks up
            COleVariant v (it->first.c_str ());
            sa.PutElement (&iCount, &v);
            iCount++;
           }

    } // end of having at least one

	return sa.Detach ();
}    // end of CMUSHclientDoc::WindowList
开发者ID:salmonrose,项目名称:mushclient,代码行数:26,代码来源:methods_miniwindows.cpp

示例5: GetPluginList

VARIANT CMUSHclientDoc::GetPluginList() 
{
  COleSafeArray sa;   // for variable list

  CString strVariableName;

  long iCount = 0;
  
  // put the plugins into the array
  if (!m_PluginList.empty ())    // cannot create empty dimension
    {
    sa.CreateOneDim (VT_VARIANT, m_PluginList.size ());

    for (PluginListIterator pit = m_PluginList.begin (); 
         pit != m_PluginList.end (); 
         ++pit)
      {
      CPlugin * p = *pit;

      // the array must be a bloody array of variants, or VBscript kicks up
      COleVariant v (p->m_strID);
      sa.PutElement (&iCount, &v);
      iCount++;
      }      // end of looping through each plugin
    } // end of having at least one

	return sa.Detach ();
}   // end of CMUSHclientDoc::GetPluginList
开发者ID:salmonrose,项目名称:mushclient,代码行数:28,代码来源:methods_plugins.cpp

示例6: Bias

// specifies whether force/torque and voltages will be biased or not
void FTWrapper::Bias(bool newbias)
{
	bias = newbias;
	if (status & DAQ_READY) {
		if (bias == true) {
			// this array is used to create the COleSafeArray below
			// it is used to indicate that there are 7 elements in the first diemnsion
			DWORD numElements[] = {7};
			COleSafeArray voltages;
			// VT_R8 represents an 8-byte real, i.e. a double in C++
			// there is 1 dimension with a size of 'numElements[0]'
			voltages.Create(VT_R8, 1, numElements);

			mDAQSys->ScanGauges(biasVoltage, true);
//			if (mDAQstatus) {
				// bad bias!
//			}
			for(long i=0;i<7;i++) {
				// COleSafeArrays use pass-by-reference methods to read or write
				voltages.PutElement(&i,&(biasVoltage[i]));
			}
			// check the bits that indicate that the calibration file has been loaded and the DAQ is ready
			if (status == ALL_READY) {
				GetActiveCalibration().Bias(voltages);
			}
		}
		else {
			// check the bit that indicates that the calibration file has been loaded
			if (status & CALFILE_LOADED) {
				GetActiveCalibration().ClearBias();
			}
		}
	}
}
开发者ID:senlin-hust,项目名称:RB-Robot-test-app,代码行数:35,代码来源:FTWrapper.cpp

示例7: GetTriggerList

VARIANT CMUSHclientDoc::GetTriggerList() 
{
  COleSafeArray sa;   // for wildcard list

  CString strTriggerName;
  CTrigger * trigger_item;
  long iCount = 0;
  POSITION pos;

  iCount = GetTriggerMap ().GetCount ();

  if (iCount) // cannot create empty array dimension
    {
    sa.CreateOneDim (VT_VARIANT, iCount);
  
    for (iCount = 0, pos = GetTriggerMap ().GetStartPosition(); pos; iCount++)
      {
      GetTriggerMap ().GetNextAssoc (pos, strTriggerName, trigger_item);

      // the array must be a bloody array of variants, or VBscript kicks up
      COleVariant v (strTriggerName);
      sa.PutElement (&iCount, &v);
      }      // end of looping through each trigger
    } // end of having at least one

	return sa.Detach ();
}    // end of CMUSHclientDoc::GetTriggerList
开发者ID:RKelson93,项目名称:mushclient,代码行数:27,代码来源:methods_triggers.cpp

示例8: mesage_AddFieldBinary

int mesage_AddFieldBinary(lua_State* L) {
	CMessage* msg = cmessage_arg(L, "mesage_AddFieldBinary");
	CString fldName = luaL_checkstring(L, 2);
	CString path = luaL_checkstring(L, 3); 
	int err;
	char *description;

	int charsLen = ::MultiByteToWideChar(CP_UTF8, 0, path, lstrlen(path), NULL, 0);
	std::wstring characters(charsLen, '\0');
	::MultiByteToWideChar(CP_UTF8, 0, path, lstrlen(path), &characters[0], charsLen);

	int pf;
	char *b = NULL;
	err = _wsopen_s(&pf, characters.c_str(), _O_BINARY | _O_RDONLY, _SH_DENYWR, _S_IREAD);
	if (err) {
		description = "Open File error";
		goto err;
	}

	DWORD l = _filelength(pf);

	b = new char[l];


	if (l != _read(pf, b, l)) {
		err = -1;
		description = "Read File error";
		goto err;
	}
	err = _close(pf);
	if (err) {
		description = "Close File error";
		goto err;
	}
	{
		COleSafeArray arr;
		arr.Create(VT_UI1, 1, &l);

		for (DWORD i = 0; i < l; i++) {

			arr.PutElement((long*)&i, &b[i]);
		}

		msg->AddDatum(fldName, arr);
	}

err:
	if (b)
		delete []b;
	lua_pushinteger(L, err);
	if (err)
		lua_pushstring(L, description);
	else
		lua_pushinteger(L, l);
	return 2;
}
开发者ID:mwoz,项目名称:Hildim.Source,代码行数:56,代码来源:mblua.cpp

示例9: ToOleVariant

COleVariant CLispEng::ToOleVariant(CP p) {
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

#ifdef X_DEBUG
	static ofstream os("c:\\out\\lisp.log");
	Print(os, p);
	os << endl;
#endif
	COleVariant r;
	switch (Type(p)) {
	case TS_CONS:
		if (!p)
			r.vt = VT_NULL;
		else
			E_Error();
		break;
	case TS_FIXNUM:
		return COleVariant((long)AsNumber(p));
	case TS_BIGNUM:
		{
			__int64 n;
			if (!ToBigInteger(p).AsInt64(n))
				E_Error();
			return COleVariant((long)n); // only lower 32 bits
		}
	case TS_SYMBOL:
		if (p == V_T)
			return COleVariant(true);
		E_Error();
	case TS_ARRAY:
		if (StringP(p))
			return COleVariant(AsString(p));
		else if (VectorP(p))
		{
			CArrayValue *av = ToVector(p);
			COleSafeArray sa;
			size_t len = av->GetVectorLength();
			sa.CreateOneDim(VT_VARIANT, (DWORD)len);
			for (long i=0; i<(long)len; ++i) {
				COleVariant v = ToOleVariant(av->GetElement(i));
				sa.PutElement(&i, &v);
			}
			return sa;
		}
		E_Error();
	default:
		E_Error();
	}
	return r;
}
开发者ID:ufasoft,项目名称:lisp,代码行数:50,代码来源:ffi.cpp

示例10: __declspec

void __declspec(dllexport) __stdcall SetStringArray(SequenceContext *seqContext, short *errorOccurred, long *errorCode, char errorMsg[1024])
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());

    CString         tempBuffer;
    BSTR            tempBstr;
    PropertyObjectPtr   seqContextPOPtr;

    TRY
        // Set sequence context as a property object
    seqContextPOPtr = seqContext->AsPropertyObject();
   
        // Create a Safe Array of 3 elements of type BSTR
    COleSafeArray safeArray;
    DWORD   rgElements[1] = {3};
    safeArray.Create( VT_BSTR, 1, rgElements );
    
        // Put a string in each element of the safe array
    for (long i=0; i<3; i++)
        {
        tempBuffer.Format("String%d", i);
        tempBstr = tempBuffer.AllocSysString();
        safeArray.PutElement(&i, tempBstr);
        SysFreeString(tempBstr);
        }

        // Set the safe array to the TestStand local variable
    seqContextPOPtr->SetValVariant("Locals.StringArray", 0, safeArray);    
    
    CATCH(COleDispatchException, e) 
        *errorOccurred = TRUE;
        _mbsnbcpy_s((unsigned char *)errorMsg, 1024, (unsigned char *)LPCTSTR(e->m_strDescription), 1024 - 1);
        *(errorMsg + (1024 - 1)) = '\0';
        *errorCode = e->m_scError;

    AND_CATCH(CMemoryException, e)
        *errorOccurred = TRUE;
        e->GetErrorMessage(errorMsg, 1024);
        *(errorMsg + (1024 - 1)) = '\0';
        *errorCode = TS_Err_OutOfMemory;

    END_CATCH 
}
开发者ID:afeique,项目名称:ni-training-july-2016,代码行数:43,代码来源:AccessingArrays.cpp

示例11: GetAlphaOptionList

VARIANT CMUSHclientDoc::GetAlphaOptionList() 
{
  COleSafeArray sa;   // for list
  long i;

  // count them
  for (i = 0; AlphaOptionsTable [i].pName; i++)
    ;

  sa.CreateOneDim (VT_VARIANT, i);

  // put the alpha option names into the array
  for (i = 0; AlphaOptionsTable [i].pName; i++)
    {
    // the array must be a bloody array of variants, or VBscript kicks up
    COleVariant v (AlphaOptionsTable [i].pName);
    sa.PutElement (&i, &v);
    }      // end of looping through each option

	return sa.Detach ();
}
开发者ID:clodeku,项目名称:mushclient,代码行数:21,代码来源:scriptingoptions.cpp

示例12: SetBiasVoltages

void FTWrapper::SetBiasVoltages(double biases[])
{
	long i;

	COleSafeArray safeBias; /*we do the SafeArray dance to pass
							the data through COM*/	
	DWORD numElements[] = {7};
	safeBias.Create(VT_R8, 1, numElements);

	bias = true;

	/*set the stored bias and set up the safearray to pass to COM*/
	for (i = 0; i < 7; i++)
	{
		biasVoltage[i] = biases[i];
		safeBias.PutElement(&i, &biases[i]);
	}
	
	if (status == ALL_READY) 
		GetActiveCalibration().Bias(safeBias);	
	
}
开发者ID:senlin-hust,项目名称:RB-Robot-test-app,代码行数:22,代码来源:FTWrapper.cpp

示例13: ExecuteAliasScript

bool CMUSHclientDoc::ExecuteAliasScript (CAlias * alias_item,
                             const CString strCurrentLine)
  {

  if (CheckScriptingAvailable ("Alias", alias_item->dispid, alias_item->strProcedure))
     return false;

  if (alias_item->dispid != DISPID_UNKNOWN)        // if we have a dispatch id
    {

    CString strType = "alias";
    CString strReason =  TFormat ("processing alias \"%s\"", 
                                  (LPCTSTR) alias_item->strLabel);

    // get unlabelled alias's internal name
    const char * pLabel = alias_item->strLabel;
    if (pLabel [0] == 0)
       pLabel = GetAliasRevMap () [alias_item].c_str ();

    if (GetScriptEngine () && GetScriptEngine ()->IsLua ())
      {
      list<double> nparams;
      list<string> sparams;
      sparams.push_back (pLabel);
      sparams.push_back ((LPCTSTR) strCurrentLine);
      alias_item->bExecutingScript = true;     // cannot be deleted now
      GetScriptEngine ()->ExecuteLua (alias_item->dispid, 
                                     alias_item->strProcedure, 
                                     eDontChangeAction,
                                     strType, 
                                     strReason, 
                                     nparams,
                                     sparams, 
                                     alias_item->nInvocationCount,
                                     alias_item->regexp); 
      alias_item->bExecutingScript = false;     // can be deleted now
      return true;
      }   // end of Lua

    // prepare for the arguments, so far, 3 which are: 
    //  1. alias name, 
    //  2. expanded line 
    //  3. replacement string

    // WARNING - arguments should appear in REVERSE order to what the sub expects them!

    enum
      {
      eWildcards,
      eInputLine,
      eAliasName,
      eArgCount,     // this MUST be last
      };    

    COleSafeArray sa;   // for wildcard list
    COleVariant args [eArgCount];
    DISPPARAMS params = { args, NULL, eArgCount, 0 };

    args [eAliasName] = pLabel;
    args [eInputLine] = strCurrentLine;

    // --------------- set up wildcards array ---------------------------
    sa.Clear ();
    // nb - to be consistent with %1, %2 etc. we will make array 1-relative
    sa.CreateOneDim (VT_VARIANT, MAX_WILDCARDS, NULL, 1);
    long i;
    for (i = 1; i < MAX_WILDCARDS; i++)
      {
      COleVariant v (alias_item->wildcards [i].c_str ());
      sa.PutElement (&i, &v);
      }
    // i should be MAX_WILDCARDS (10) now ;)
    COleVariant v (alias_item->wildcards [0].c_str ()); // the whole matching line
    sa.PutElement (&i, &v);
    args [eWildcards] = sa;
    
    alias_item->bExecutingScript = true;     // cannot be deleted now
    ExecuteScript (alias_item->dispid,  
                   alias_item->strProcedure,
                   eDontChangeAction,     // don't change current action
                   strType, 
                   strReason,
                   params, 
                   alias_item->nInvocationCount); 
    alias_item->bExecutingScript = false;     // can be deleted now

    return true;
    }     // end of having a dispatch ID

  return false;
  } // end of CMUSHclientDoc::ExecuteAliasScript
开发者ID:WillFa,项目名称:mushclient,代码行数:91,代码来源:evaluate.cpp

示例14: ExportSendRedPacketToexel


//.........这里部分代码省略.........
	{

		UiFun::GetCellName(1 ,iCol + 1, colname);

		range   =   sheet.get_Range(COleVariant(colname),COleVariant(colname));

		//pmyHeaderCtrl-> GetItem(iCol,   &hdi);

		range.put_Value2(COleVariant(listheadr[iCol].name.c_str()));

		int   nWidth   = listheadr[iCol].size;  //m_listCtrl.GetColumnWidth(iCol)/6;

		//得到第iCol+1列  

		range.AttachDispatch(range.get_Item(_variant_t((long)(iCol+1)),vtMissing).pdispVal,true);  

		//设置列宽 

		range.put_ColumnWidth(_variant_t((long)nWidth));

	}

	range   =   sheet.get_Range(COleVariant( _T("A1 ")),   COleVariant(colname));

	range.put_RowHeight(_variant_t((long)50));//设置行的高度

	font = range.get_Font();

	font.put_Bold(covTrue);

	range.put_VerticalAlignment(COleVariant((short)-4108));//xlVAlignCenter   =   -4108



	COleSafeArray   saRet;

	DWORD   numElements[]={m_rows,m_cols};       //5x2   element   array

	saRet.Create(VT_BSTR,   2,   numElements);

	range   =   sheet.get_Range(COleVariant( _T("A2 ")),covOptional);

	range = range.get_Resize(COleVariant((short)m_rows),COleVariant((short)m_cols));

	long   index[2];

	range   =   sheet.get_Range(COleVariant( _T("A2 ")),covOptional);

	range   =   range.get_Resize(COleVariant((short)m_rows),COleVariant((short)m_cols));


	int iLine = 0;
	iRow   =   1;
	iCol   =   1;
	vector<uistruct::REDPACKETSEND_t>::const_iterator pitem = SendRedPacketList.begin();
	for(;pitem != SendRedPacketList.end();pitem++,iRow++)
	{
		map<int,string> item;
		GetExportCol(item,*pitem);
		for   (   iCol   =   1;   iCol   <=   m_cols;   iCol++)  

		{

			index[0]=iRow-1;

			index[1]=iCol-1;
			string strTemp =  item[iCol-1];
			CString   szTemp = strTemp.c_str();

			BSTR   bstr   =   szTemp.AllocSysString();

			saRet.PutElement(index,bstr);

			SysFreeString(bstr);

		}
	}


	range.put_Value2(COleVariant(saRet));


	saRet.Detach();

	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	book.SaveCopyAs(COleVariant(strFile));

	//       cellinterior.ReleaseDispatch();

	book.put_Saved(true);

	book.ReleaseDispatch();  

	books.ReleaseDispatch();  

	app.Quit();

	app.ReleaseDispatch();
}
开发者ID:SoyPay,项目名称:DacrsUI,代码行数:101,代码来源:SendRedPacketRecord.cpp

示例15: SpellCheck

VARIANT CMUSHclientDoc::SpellCheck(LPCTSTR Text) 
{

const char sFunction [] = "spellcheck_string";

	VARIANT vaResult;
	VariantInit(&vaResult);

  if (!App.m_bSpellCheckOK)
    return vaResult;

set<string> errors;

  if (App.m_SpellChecker_Lua)
    {

    lua_settop(App.m_SpellChecker_Lua, 0);   // clear stack

    lua_getglobal (App.m_SpellChecker_Lua, sFunction);  
    if (!lua_isfunction (App.m_SpellChecker_Lua, -1))
      return vaResult;  // cannot spell check string

    lua_pushstring (App.m_SpellChecker_Lua, Text);  // string to be checked

    int narg = lua_gettop(App.m_SpellChecker_Lua) - 1;  // all but the function
    int error = CallLuaWithTraceBack (App.m_SpellChecker_Lua, narg, 1);
  
    if (error)
      {
      LuaError (App.m_SpellChecker_Lua, "Run-time error", sFunction, "world.SpellCheck", "", this);
      return vaResult;  // cannot spell check string - syntax error
      }  

    if (lua_isnumber (App.m_SpellChecker_Lua, -1))
      {
      SetUpVariantLong (vaResult, lua_tonumber (App.m_SpellChecker_Lua, -1));        // no errors
  	  return vaResult;
      }

    // must be table or else return bad result
    if (!lua_istable (App.m_SpellChecker_Lua, -1))
      return vaResult;  // cannot spell check string - syntax error

    // convert returned table into a set
    for (int i = 1; ; i++)
      {
      lua_rawgeti (App.m_SpellChecker_Lua, 1, i);   // get i'th item
      if (lua_isnil (App.m_SpellChecker_Lua, -1))
        break;    // first nil key, leave loop
      // to avoid crashes, ignore table items that are not strings
      if (lua_isstring (App.m_SpellChecker_Lua, -1))
         errors.insert (lua_tostring (App.m_SpellChecker_Lua, -1));
      lua_pop (App.m_SpellChecker_Lua, 1); // remove value
      } // end of looping through table

    // maybe didn't find any errors?
    if (errors.empty ())
      {
      SetUpVariantLong (vaResult, 0);        // no errors
  	  return vaResult;
      }

    // now make array of the errors
    COleSafeArray sa;   // for wildcard list

    sa.CreateOneDim (VT_VARIANT, errors.size ());

    long iCount = 0;

    for (set<string>::const_iterator it = errors.begin (); 
         it != errors.end (); it++, iCount++)
      {
      // the array must be a bloody array of variants, or VBscript kicks up
      COleVariant v (it->c_str ());
      sa.PutElement (&iCount, &v);
      }      // end of looping through each error

	  return sa.Detach ();
    }   // end custom spell check


return vaResult;

} // end of SpellCheck
开发者ID:RKelson93,项目名称:mushclient,代码行数:84,代码来源:methods_spellchecker.cpp


注:本文中的COleSafeArray::PutElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。