懂VC的话,自己看下吧。///////////////////////////////////////////////////////////////////////////////
// Eval()
///////////////////////////////////////////////////////////////////////////////
AUT_RESULT AutoIt_Script::F_Eval(VectorVariant &vParams, Variant &vResult)
{
bool bConst = false;
if (g_oVarTable.isDeclared(vParams[0].szValue()))
{
Variant *pvTemp;
g_oVarTable.GetRef(vParams[0].szValue(), &pvTemp, bConst);
vResult = *pvTemp;
return AUT_OK;
}
else
{
SetFuncErrorCode(1); // Silent error even though variable not valid
vResult = "";
return AUT_OK;
}
} // Eval()
//////////////////////////////////////////////////////////////////////////
// F_Assign("variable", "data")
//
// Assign( "varname", "value" [,flag])
//
// binary flag: 0=any, 1=local, 2=global, 4=no create
//
// Assigns the variable in the first parameter to the data in the second parameter.
// This is a compliment to Eval()
//////////////////////////////////////////////////////////////////////////
AUT_RESULT AutoIt_Script::F_Assign(VectorVariant &vParams, Variant &vResult)
{
Variant *pvTemp;
int nReqScope = VARTABLE_ANY;
bool bCreate = true;
bool bConst = false;
if (vParams.size() == 3)
{
if (vParams[2].nValue() & 1)
nReqScope = VARTABLE_FORCELOCAL;
if (vParams[2].nValue() & 2)
nReqScope = VARTABLE_FORCEGLOBAL;
if (vParams[2].nValue() & 4)
bCreate = false;
}
// Get a reference to the variable in the requested scope, if it doesn't exist, then create it.
g_oVarTable.GetRef(vParams[0].szValue(), &pvTemp, bConst, nReqScope);
if (pvTemp == NULL)
{
if (bCreate)
g_oVarTable.Assign(vParams[0].szValue(), vParams[1], false, nReqScope);
else
vResult = 0; // Default is 1
}
else
*pvTemp = vParams[1];
return AUT_OK;
} // F_Assign()
|