// not UNIX

#include "stdafx.h"
#include "Strawberry.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#endif

int SetProperty(DWORD Server, DWORD Property, DWORD Arg, DWORD p_line)
{
  OLECHAR* szMember;
  COleDispatchDriver *Disp;
  LPSTR property=(LPSTR)StringStore+Property;
  DISPID dispid;
  HRESULT hResult;
  LPDISPATCH lpDisp;
  
  DWORD k;

  #if TR
  MitiText("Set property\r\n");
  #endif
//Angele, setni tuk edno properti
//StringStore+ObjectStore[Buda2[Arguments]+6] //property
//ObjectStore[Buda2[Arguments]+7] //server (as object)
//Buda2[Arg] //value to be set
//Buda1[Arg] //prolog type to be set, for the moment variant

  if (ObjectStore[Server+7]==M1)
      {MitiText(property); MitiText(" - no such server.\r\n"); return(0);}
  Disp=(COleDispatchDriver*)ObjectStore[Server+7]; // disp interface of the server
  ChangeCharset(ch_set, 64, (BYTE *)property, (BYTE *)string3, &k, default_char);
  szMember=(OLECHAR*)string3;
  
  lpDisp=Disp->m_lpDispatch;
  hResult=lpDisp->GetIDsOfNames(IID_NULL,&szMember,1, LOCALE_SYSTEM_DEFAULT, &dispid);
  if(!SUCCEEDED(hResult))
      {MitiText(property); MitiText(" - no such property.\r\n"); return(0);}
	try
	{
		switch(Buda1[Arg])
		{  
		case TT_LINK: // var
			{
			VARIANT Variant;
			Variant.vt=VT_EMPTY;
			Disp->InvokeHelper(dispid, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, (const BYTE*)VTS_VARIANT, &Variant ); 
			break;
			}
		case TT_STR: // string
			Disp->InvokeHelper(dispid, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, (const BYTE*)VTS_BSTR, (LPCSTR)(make_long(StringStore+Buda2[Arg]))); 
			break;
		case TT_INT: // integer
			Disp->InvokeHelper(dispid, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, (const BYTE*)VTS_I4, Buda2[Arg]); 
			break;
		case TT_FLOAT: // float
			Disp->InvokeHelper(dispid, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, (const BYTE*)VTS_R4, *(float*)&Buda2[Arg]); 
			break;
		case TT_OBJ: //object
      if (SUBTYPE(ObjectStore[Buda2[Arg]],CLASS_SYSTEM_ActiveX) || SUBTYPE(ObjectStore[Buda2[Arg]],C_S_WIN_Embedded))
			{
				VARIANT Variant;
				COleDispatchDriver *DispTml=(COleDispatchDriver*)( ObjectStore[Buda2[Arg]+7] ); 
				IDispatch* pDisp=DispTml->m_lpDispatch;
				Variant.vt=VT_DISPATCH;
				Variant.pdispVal=pDisp;
				Disp->InvokeHelper(dispid, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, (const BYTE*)VTS_VARIANT, &Variant ); 
				break;
			}
			else
			{
				error_func3(Arg-1,p_line,1,CLASS_SYSTEM_ActiveX,C_S_WIN_Embedded);
        MitiText("You cannot use other object in order to set property\r\nbut you can use numbers, stings and even terms for this.\r\n");
				return(0);
			}
		default:
			if (Buda1[Arg]==Definition[DF_TRUE]) // true
				Disp->InvokeHelper(dispid, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, (const BYTE*)VTS_BOOL, true); 
			else if (Buda1[Arg]==Definition[DF_FALSE]) // false
				Disp->InvokeHelper(dispid, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, (const BYTE*)VTS_BOOL, false);
			else
			{
        len=0;
        write_p( TT_VAR, 6, Arg);
				Disp->InvokeHelper(dispid, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, (const BYTE*)VTS_BSTR, (LPCSTR)(make_long((BYTE *)string2))); 
				break;
			}
		}
	}
	catch(COleException *e)
	{
		sprintf(string2, "OLE ERROR: Cannot invoking - %s \r\n", property);
		MitiText(string2, &cf_red);
		e->GetErrorMessage(string3,255);
		MitiText(make_utf8(string3));
		e->Delete();
		return(0);
	}
	catch(COleDispatchException *e)
	{
		sprintf(string2, "OLE Dispatch Error: Cannot invoking - %s \r\n", property);
		MitiText(string2, &cf_red); 
		MitiText(make_utf8(e->m_strSource));   MitiText("\r\n");
		MitiText(make_utf8(e->m_strDescription));  MitiText("\r\n");
		e->Delete();
		return(0);
	}
 	catch(...)
	{
		sprintf(string2, "SEH Error: Cannot invoking - %s \r\n", property);
		MitiText(string2, &cf_red); 
		return(0);
	}
	return(1);
}

int GetProperty(DWORD Server, DWORD Property, DWORD Return)
{
  // Angele, getni tuk edno properti
  
  OLECHAR* szMember;
  COleDispatchDriver *Disp;
  LPSTR property;
  DISPID dispid;
  HRESULT hResult;
  LPDISPATCH lpDisp;
  VARIANT varRet;

  DWORD k;

  if (Property&HALF)
    property=(LPSTR)StringStore+(Property&HALFM);
  else if (Buda1[Property]==TT_STR)
    property=(LPSTR)StringStore+Buda2[Property];
  else
  {
    len=0;
    write_p( TT_VAR, 6, Property);
    property=string2;  // !!! you can overlap
  }
#if TR
  MitiText("property: "); MitiText(property); MitiText("\r\n");
#endif
  if (ObjectStore[Server+7]==M1)
      {MitiText(property); MitiText(" - no such server.\r\n"); return(0);}
  Disp=(COleDispatchDriver*)ObjectStore[Server+7]; // disp interface of the server
  ChangeCharset(ch_set, 64, (BYTE *)property, (BYTE *)string3, &k, default_char);
  szMember=(OLECHAR*)string3;
  lpDisp=Disp->m_lpDispatch;
  hResult=lpDisp->GetIDsOfNames(IID_NULL,&szMember,1, LOCALE_SYSTEM_DEFAULT, &dispid);

  if(!SUCCEEDED(hResult))
  {MitiText(property); MitiText(" - no such property.\r\n"); return(0);}
  
  try
	{
		Disp->InvokeHelper(dispid, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&varRet, NULL);
	}
	catch(COleException *e)
	{
		sprintf(string2, "OLE ERROR: Cannot invoking - %s \r\n", property);
		MitiText(string2, &cf_red);
		e->GetErrorMessage(string3,255);
		MitiText(make_utf8(string3));
		e->Delete();
		return(0);
	}
	catch(COleDispatchException *e)
	{
		sprintf(string2, "OLE Dispatch Error: Cannot invoking - %s \r\n", property);
		MitiText(string2, &cf_red); 
		MitiText(make_utf8(e->m_strSource));   MitiText("\r\n");
		MitiText(make_utf8(e->m_strDescription));  MitiText("\r\n");
		e->Delete();
		return(0);
	}
	catch(...)
	{
		sprintf(string2, "SEH Error: Cannot invoking - %s \r\n", property);
		MitiText(string2, &cf_red); 
		return(0);
	}

  if (Return!=M1) // if we need this value
    GetVariant(Return, &varRet);
  return(1);
}

int CallMethod(DWORD Server, DWORD ArgList, DWORD Return)
{
  // Angele, vikni tuk edin method

  OLECHAR* szMember;
  COleDispatchDriver *Disp;
  LPSTR method;
  DISPID dispid;
  HRESULT hResult;
  LPDISPATCH lpDisp;
  int nParam= -1, nParam2=0, Mem_br=0;
  DWORD Mem[BUFFERS/4];
  VARIANT varRet;
  
  DWORD i, k, t;

  DWORD *Temp=(LPDWORD)ObjectStore[Buda2[ArgList]+4];

  if (Temp[1]&TP_STR)
    method=(LPSTR)StringStore+Temp[2];
  else if (Temp[1]&TP_TERM)
  {
    len=0;
    if (Temp[1]&HALF)
      write_p( TT_VAR, 6, Temp[3]);
    else
      write_p( Temp[3], 14, Temp[2]);
    method=(LPSTR)string2;
  }
  else
    {MitiText("The type of the method name is bad.\r\n"); return(0);}
  if (ObjectStore[Server+7]==M1)
      {MitiText(method); MitiText(" - no such server.\r\n"); return(0);}
  Disp=(COleDispatchDriver*)ObjectStore[Server+7]; // disp interface of the server
  ChangeCharset(ch_set, 64, (BYTE *)method, (BYTE *)string3, &k, default_char);
  szMember=(OLECHAR*)string3;

  lpDisp=Disp->m_lpDispatch;
  hResult=lpDisp->GetIDsOfNames(IID_NULL,&szMember,1, LOCALE_SYSTEM_DEFAULT, &dispid);
  
  if(!SUCCEEDED(hResult))
    {MitiText(method); MitiText(" - no such method.\r\n"); return(0);}
#if TR
      MitiText("method: "); MitiText(method); MitiText("\r\n");
#endif
  for (i=4, nParam=0; i<ObjectStore[Buda2[ArgList]+2]; i+=4, nParam++)
  {  
#if TR
    if (Temp[i]!=M1)
    {
      sprintf(string2, " The name of the next is \"%s\"\r\n", StringStore+Temp[i]);
      MitiText(string2);
    }
    sprintf(string2, "  arg %d:", i/4);
    MitiText(string2); 
    if (Temp[i+1]&TP_VAR)
      sprintf(string2, " var %d", Temp[i+2]);
    else if (Temp[i+1]&TP_TERM)
      sprintf(string2, " term %d", Temp[i+3]);
    else if (Temp[i+1]&TP_STR)
      sprintf(string2, " str \"%s\"", StringStore+Temp[i+2]);
    else if (Temp[i+1]&TP_INT)
      sprintf(string2, " int %d", Temp[i+2]);
    else if (Temp[i+1]&TP_FLOAT)
      sprintf(string2, " float %f", ((float *)Temp)[i+2]);
    else if (Temp[i+1]&TP_OBJ)
      sprintf(string2, " obj 0j%d", Temp[i+2]);
    MitiText(string2);
    if (Temp[i+1]&HALF) // io
    { 
      sprintf(string2, ", Ret %d", Temp[i+3]);
      MitiText(string2); 
    }
    MitiText("      MS type is ");
    if (Temp[i+1]&HALF)
      MitiText("input\\output ");
    switch (Temp[i+1]&MASKA_TP)
    {
      case 2:
      MitiText("int2");
      break;
      case 3:
      MitiText("int4");
      break;
      case 4:
      MitiText("float4");
      break;
      case 5:
      MitiText("float8");
      break;
      case 8:
      MitiText("str");
      break;
      case 9:
      MitiText("disp_interface");
      break;
      case 12:
      MitiText("variant");
      break;
      default: 
      MitiText("unknown");
    }
    MitiText("\r\n");
#endif
    switch (Temp[i+1]&MASKA_TP)
    {
      case 2: // "int2"
      if (Temp[i+1]&HALF) // io
      {
        a[nParam]=VTS_PI2[0];
        b[nParam2++]=(int)(Mem+Mem_br);
        *(short*)(Mem+Mem_br++)=(short)Temp[i+2];
      }
      else
      {
        a[nParam]=VTS_I2[0];
        b[nParam2++]=Temp[i+2];
      }
      break;
      case 3: // "int4"
      if (Temp[i+1]&HALF) // io
      {
        a[nParam]=VTS_PI4[0];
        b[nParam2++]=(int)(Buda2+Temp[i+3]);
      }
      else
      {
        a[nParam]=VTS_I4[0];
        b[nParam2++]=Temp[i+2];
      }
      break;
      case 4: // "float4"
      if (Temp[i+1]&HALF) // io
      {
        a[nParam]=VTS_PR4[0];
        b[nParam2++]=(int)(Buda2+Temp[i+3]);
      }
      else
      {
        a[nParam]=VTS_R4[0];   // vypros za Plamen
        *(double*)(b+nParam2)=*(float*)&Temp[i+2]; // ??? maybe fload as double or error ???
        nParam2+=2;
      }
      break;
      case 5: // "float8"
      if (Temp[i+1]&HALF) // io
      {
        a[nParam]=VTS_PR8[0];
        b[nParam2++]=(int)(Mem+Mem_br);
        *(double*)(Mem+Mem_br)=*(float*)&Temp[i+2];
        Mem_br+=2;
      }
      else
      {
        a[nParam]=VTS_R8[0];
        *(double*)(b+nParam2)=*(float*)&Temp[i+2];
        nParam2+=2;
      }
      break;
      case 8: // "str"
      Mem[Mem_br]=(int)(new CString(make_long(StringStore+Temp[i+2])));
      if (Temp[i+1]&HALF) // io
      {
        a[nParam]=VTS_PBSTR[0];
        b[nParam2++]=(int)(Mem+Mem_br++);
      }
      else
      {
        a[nParam]=VTS_BSTR[0];
        b[nParam2++]=Mem[Mem_br++];
      }
      break;
      case 9: // "disp_interface"
      if (Temp[i+1]&HALF) // io
      {
        a[nParam]=VTS_PDISPATCH[0];
        b[nParam2++]=(int)(Mem+Mem_br);
        Mem[Mem_br++]=(int)((COleDispatchDriver*)ObjectStore[Temp[i+2]+2])->m_lpDispatch;
      }
      else
      {
        a[nParam]=VTS_DISPATCH[0];
        b[nParam2++]=(int)((COleDispatchDriver*)ObjectStore[Temp[i+2]+2])->m_lpDispatch; 
      }
      break;
      case 12: // "variant"
      {
      VARIANT* pVariant= (VARIANT*)(Mem+Mem_br);
      b[nParam2++]= (int)pVariant; 
      Mem_br+=(sizeof(VARIANT)+3)/4;
      a[nParam]=(Temp[i+1]&HALF)?VTS_PVARIANT[0]:VTS_VARIANT[0]; //io
      if (Temp[i+1]&TP_VAR)
        pVariant->vt=VT_EMPTY;
      else if (Temp[i+1]&TP_STR)
      {
        pVariant->vt=VT_BSTR;
        CString str(make_long(StringStore+Temp[i+2]));
        pVariant->bstrVal=str.AllocSysString();
      }  
      else if (Temp[i+1]&TP_INT)
      {
        pVariant->vt=VT_I4;
        pVariant->intVal=(long)Temp[i+2];
      }  
      else if (Temp[i+1]&TP_FLOAT)
      {
        pVariant->vt=VT_R4;
        pVariant->fltVal=*(float*)&Temp[i+2];
      }  
      else if (Temp[i+1]&TP_OBJ)
      {
        if (SUBTYPE(ObjectStore[Temp[i+2]],CLASS_SYSTEM_ActiveX) || SUBTYPE(ObjectStore[Temp[i+2]],C_S_WIN_Embedded))
				{
					COleDispatchDriver *DispTml=(COleDispatchDriver*)( ObjectStore[Temp[i+2]+7] ); 
					IDispatch* pDisp=DispTml->m_lpDispatch;
          pVariant->vt=VT_DISPATCH;
					pVariant->pdispVal=pDisp;
				}
				else
					return(0);  
      }  
      else if (Temp[i+1]&TP_TERM)
      {  
        DWORD term;
        if (Temp[i+1]&HALF)
          term=Buda1[Temp[i+3]];
        else
          term=Temp[i+3];
        if (term==Definition[DF_TRUE])
        {
          pVariant->vt=VT_BOOL;
          pVariant->boolVal=1;
        }  
        else if (term==Definition[DF_FALSE])
        {
          pVariant->vt=VT_BOOL;
          pVariant->boolVal=0;
        }  
        else
        {
          pVariant->vt=VT_BSTR;
          len=0;
          if (Temp[i+1]&HALF)
            write_p( TT_VAR, 6, Temp[i+3]);
          else
            write_p( term, 14, Temp[i+2]);
          //MitiText("Miti:\r\n"); MitiText(string2);
          CString str(make_long((BYTE *)string2));
          pVariant->bstrVal=str.AllocSysString();
        }  
      }
      else
        return(0);  
      }
    }
  }
  a[nParam]=0;
try
{    
switch(nParam2)
{
 case 0:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,&varRet,NULL);
  break; 
 case 1:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,&varRet,a,b[0]);
  break;
 case 2:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,&varRet,a,b[0],b[1]);
  break;
 case 3:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2]);
  break;
 case 4:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3]);
  break;
 case 5:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4]);
  break;
 case 6:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5]);
  break;
 case 7:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6]);
  break;
 case 8:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7]);
  break;
 case 9:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8]);
  break;
 case 10:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9]);
  break;
 case 11:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10]);
  break;
 case 12:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11]);
  break;
 case 13:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12]);
  break;
 case 14:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13]);
  break;
 case 15:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14]);
  break;
 case 16:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15]);
  break;
 case 17:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16]);
  break;
 case 18:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17]);
  break;
 case 19:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18]);
  break;
 case 20:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19]);
  break;
 case 21:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20]);
  break;
 case 22:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21]);
  break;
 case 23:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22]);
  break;
 case 24:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23]);
  break;
 case 25:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24]);
  break;
 case 26:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25]);
  break;
 case 27:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26]);
  break;
 case 28:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27]);
  break;
 case 29:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28]);
  break;
 case 30:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29]);
  break;
 case 31:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30]);
  break;
 case 32:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31]);
  break;
 case 33:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32]);
  break;
 case 34:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33]);
  break;
 case 35:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34]);
  break;
 case 36:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35]);
  break;
 case 37:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36]);
  break;
 case 38:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37]);
  break;
 case 39:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37],b[38]);
  break;
 case 40:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37],b[38],b[39]);
  break;
 case 41:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37],b[38],b[39],b[40]);
  break;
 case 42:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37],b[38],b[39],b[40],b[41]);
  break;
 case 43:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37],b[38],b[39],b[40],b[41],b[42]);
  break;
 case 44:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37],b[38],b[39],b[40],b[41],b[42],b[43]);
  break;
 case 45:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37],b[38],b[39],b[40],b[41],b[42],b[43],b[44]);
  break;
 case 46:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37],b[38],b[39],b[40],b[41],b[42],b[43],b[44],b[45]);
  break;
 case 47:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37],b[38],b[39],b[40],b[41],b[42],b[43],b[44],b[45],b[46]);
  break;
 case 48:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37],b[38],b[39],b[40],b[41],b[42],b[43],b[44],b[45],b[46],b[47]);
  break;
 case 49:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37],b[38],b[39],b[40],b[41],b[42],b[43],b[44],b[45],b[46],b[47],b[48]);
  break;
 case 50:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37],b[38],b[39],b[40],b[41],b[42],b[43],b[44],b[45],b[46],b[47],b[48],b[49]);
  break;
 case 51:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37],b[38],b[39],b[40],b[41],b[42],b[43],b[44],b[45],b[46],b[47],b[48],b[49],b[50]);
  break;
 case 52:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37],b[38],b[39],b[40],b[41],b[42],b[43],b[44],b[45],b[46],b[47],b[48],b[49],b[50],b[51]);
  break;
 case 53:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37],b[38],b[39],b[40],b[41],b[42],b[43],b[44],b[45],b[46],b[47],b[48],b[49],b[50],b[51],b[52]);
  break;
 case 54:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37],b[38],b[39],b[40],b[41],b[42],b[43],b[44],b[45],b[46],b[47],b[48],b[49],b[50],b[51],b[52],b[53]);
  break;
 case 55:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37],b[38],b[39],b[40],b[41],b[42],b[43],b[44],b[45],b[46],b[47],b[48],b[49],b[50],b[51],b[52],b[53],b[54]);
  break;
 case 56:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37],b[38],b[39],b[40],b[41],b[42],b[43],b[44],b[45],b[46],b[47],b[48],b[49],b[50],b[51],b[52],b[53],b[54],b[55]);
  break;
 case 57:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37],b[38],b[39],b[40],b[41],b[42],b[43],b[44],b[45],b[46],b[47],b[48],b[49],b[50],b[51],b[52],b[53],b[54],b[55],b[56]);
  break;
 case 58:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37],b[38],b[39],b[40],b[41],b[42],b[43],b[44],b[45],b[46],b[47],b[48],b[49],b[50],b[51],b[52],b[53],b[54],b[55],b[56],b[57]);
  break;
 case 59:
  Disp->InvokeHelper(dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET,VT_VARIANT,(void*)&varRet,a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15],b[16],b[17],b[18],b[19],b[20],b[21],b[22],b[23],b[24],b[25],b[26],b[27],b[28],b[29],b[30],b[31],b[32],b[33],b[34],b[35],b[36],b[37],b[38],b[39],b[40],b[41],b[42],b[43],b[44],b[45],b[46],b[47],b[48],b[49],b[50],b[51],b[52],b[53],b[54],b[55],b[56],b[57],b[58]);
  break;
} // end switch
} // end try

  catch(COleException *e)
  {
    sprintf(string2, "OLE ERROR: Cannot invoking - %s \r\n", method);
    MitiText(string2, &cf_red);
    e->GetErrorMessage(string3,255);
    MitiText(make_utf8(string3));
    e->Delete();
    return(0);
  }
  catch(COleDispatchException *e)
  {
    sprintf(string2, "OLE Dispatch Error: Cannot invoking - %s \r\n", method);
    MitiText(string2, &cf_red); 
    MitiText(make_utf8(e->m_strSource));   MitiText("\r\n");
    MitiText(make_utf8(e->m_strDescription));  MitiText("\r\n");
		e->Delete();
		return(0);
  }
	catch(...)
	{
		sprintf(string2, "SEH Error: Cannot invoking - %s \r\n", method);
		MitiText(string2, &cf_red); 
    return(0);
  }
  int Mem_br2=0;
  for (i=4; Mem_br2<Mem_br; i+=4)
  {  
    switch (Temp[i+1]&MASKA_TP)
    {
     case 2: // "int2"
      if (Temp[i+1]&HALF) // io
        Buda2[Temp[i+3]]=*(short*)(Mem+Mem_br2++);
      break;
     case 3: // "int4"
      break;
     case 4: // "float4"
      break;
     case 5: // "float8"
      if (Temp[i+1]&HALF) // io
      {
        float fl=(float)*(double*)(Mem+Mem_br2);
        Buda2[Temp[i+3]]=*(int*)&fl;
        Mem_br2+=2;
      }
      break;
     case 8: // "str"
      {
        CString* pStr=(CString*)Mem[Mem_br2];
        if ((Temp[i+1]&HALF) && strcmp((LPSTR)(StringStore+Buda2[Temp[i+3]]), make_short(*pStr))!=0)
        {
          if ((t=my_strlen(*pStr))>1 || (t==1 && (*pStr[0]>127 || *pStr[0]<0)))
          {
            Buda2[Temp[i+3]]=sv_StStore;
            t=ChangeCharset(M64_ch, ch_set, (BYTE *)(LPCTSTR)(*pStr), StringStore+sv_StStore, &k, default_char);
            sv_StStore+=t+1;
            if (sv_StStore>=STRING_STORE && correct_STR_ST() )
            {
              MessageBoxA(NUL, "The string store is full.", "No Space", MB_OK | MB_ICONSTOP);
              return(3);
            }
          }
          else
              Buda2[Temp[i+3]]=2*(*pStr)[0];
        }
        delete pStr;
        Mem_br2++;
      }
      break;
     case 9: // "disp_interface"
      if (Temp[i+1]&HALF) // io
        ((COleDispatchDriver*)ObjectStore[Temp[i+2]+2])->AttachDispatch((LPDISPATCH)Mem[Mem_br2++]);
      break;
     case 12: // "variant"
      VARIANT* pVariant= (VARIANT*)(Mem+Mem_br);
      if (Temp[i+1]&HALF) // io
        GetVariant(Temp[i+3], pVariant);
      if (pVariant->vt==VT_BSTR)
        SysFreeString(pVariant->bstrVal);//???
      Mem_br2+=(sizeof(VARIANT)+3)/4;
    }
  }
  if (Return!=M1) // if we need this value
    GetVariant(Return, &varRet);
  return(1);
}

void SetVariant(DWORD From, VARIANT* pVariant)
{
	switch(Buda1[From])
	{
	  case TT_LINK: // var
      pVariant->vt=VT_EMPTY;
			break;
	  case TT_STR: // string
	  {
      pVariant->vt=VT_BSTR;
      CString str(make_long(StringStore+Buda2[From]));
      pVariant->bstrVal=str.AllocSysString();
			break;
	  }
	  case TT_INT: // integer
      pVariant->vt=VT_I4;
      pVariant->intVal=(long)Buda2[From];
			break;
	  case TT_FLOAT: // float
      pVariant->vt=VT_R4;
      pVariant->fltVal=*(float*)&Buda2[From];
			break;
	  case TT_OBJ: //object
      if (SUBTYPE(ObjectStore[Buda2[From]],CLASS_SYSTEM_ActiveX) || SUBTYPE(ObjectStore[Buda2[From]],C_S_WIN_Embedded))
		  {
			  COleDispatchDriver *DispTml=(COleDispatchDriver*)( ObjectStore[Buda2[From]+7] ); 
			  IDispatch* pDisp=DispTml->m_lpDispatch;
        pVariant->vt=VT_DISPATCH;
			  pVariant->pdispVal=pDisp;
		  }
		  else
        pVariant->vt=VT_EMPTY;
			break;
	  default:
    {  
      if (Buda2[From]==Definition[DF_TRUE])
      {
        pVariant->vt=VT_BOOL;
        pVariant->boolVal=1;
      }  
      else if (Buda2[From]==Definition[DF_FALSE])
      {
        pVariant->vt=VT_BOOL;
        pVariant->boolVal=0;
      }  
      else
        pVariant->vt=VT_EMPTY;
    }
  }
}

void GetVariant(DWORD Where, VARIANT* pVariant)
{
  DWORD i, k;
  
  switch(pVariant->vt)
  {
   case VT_BSTR: // string
    Buda1[Where]=TT_STR;
    i=ChangeCharset(64, ch_set, (BYTE *)(LPCTSTR)pVariant->bstrVal, StringStore+sv_StStore, &k, default_char);
    if (i)
    {
      Buda2[Where]=sv_StStore;
      if ((sv_StStore+=i+1)>=STRING_STORE && correct_STR_ST() )
      {
        MessageBoxA(NUL, "The string store is full.", "No Space", MB_OK | MB_ICONSTOP);
        return;
      }
    }
    else
      Buda2[Where]=0;
    break;
   case VT_I4: // integer
   case VT_INT:
    Buda1[Where]=TT_INT;
    Buda2[Where]=pVariant->intVal;
    break;
   case VT_UI4: // integer
    Buda1[Where]=TT_INT;
    Buda2[Where]=pVariant->ulVal;
    break;
   case VT_UINT: // integer
    Buda1[Where]=TT_INT;
    Buda2[Where]=pVariant->uintVal;
    break;
   case VT_UI2: // short
    Buda1[Where]=TT_INT;
    Buda2[Where]=pVariant->uiVal;
    break;
   case VT_I2: // short
    Buda1[Where]=TT_INT;
    Buda2[Where]=(int)pVariant->iVal;
    break;
   case VT_UI1: // byte
    Buda1[Where]=TT_INT;
    Buda2[Where]=pVariant->bVal;
    break;
   case VT_I1: // byte
    Buda1[Where]=TT_INT;
    Buda2[Where]=(int)pVariant->cVal;
    break;
   case VT_BOOL: // bool
    if (pVariant->boolVal)
      Buda1[Where]=Definition[DF_TRUE];
    else
      Buda1[Where]=Definition[DF_FALSE];
    break;
   case VT_R4: // float
    Buda1[Where]=TT_FLOAT;
    Buda2[Where]=*(int*)&pVariant->fltVal;
    break;
   case VT_R8: // double float
    {float fl=(float)pVariant->dblVal;
    Buda1[Where]=TT_FLOAT;
    Buda2[Where]=*(int*)&fl;
    break;}
   case VT_DISPATCH: // server
    ObjectStore[ObjectStore_br]=CLASS_SYSTEM_ActiveX; // Type
    ObjectStore[ObjectStore_br+1]=M1;  // object name
    {COleDispatchDriver *DispNew=new(COleDispatchDriver);
    DispNew->AttachDispatch(pVariant->pdispVal);
    ObjectStore[ObjectStore_br+7] = (DWORD) DispNew;
    ObjectStore[ObjectStore_br+8] = M2; // do not close
    Buda1[Where]=TT_OBJ;
    Buda2[Where]=ObjectStore_br;
    if ((ObjectStore_br+=9)>=OBJ_STORE && correct_OBJ_ST() )
    {
      MessageBoxA(NULL,"Object Store is Full!", "No Space", MB_OK | MB_ICONSTOP);
      return;
    }
    break;}
   case VT_EMPTY: // empty
    Buda1[Where]=Definition[DF_GRAYED];
    break;
   default:
    Buda1[Where]=Definition[DF_NOCALK];
  }
}
