Commit 3e45fbcb authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Added Left() implementation.

parent 24eee97d
......@@ -632,10 +632,42 @@ static HRESULT Global_LenB(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARI
return E_NOTIMPL;
}
static HRESULT Global_Left(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
static HRESULT Global_Left(vbdisp_t *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
{
FIXME("\n");
return E_NOTIMPL;
BSTR str, ret, conv_str = NULL;
int len, str_len;
HRESULT hres;
TRACE("(%s %s)\n", debugstr_variant(args+1), debugstr_variant(args));
if(V_VT(args+1) == VT_BSTR) {
str = V_BSTR(args+1);
}else {
hres = to_string(args+1, &conv_str);
if(FAILED(hres))
return hres;
str = conv_str;
}
hres = to_int(args, &len);
if(FAILED(hres))
return hres;
if(len < 0) {
FIXME("len = %d\n", len);
return E_FAIL;
}
str_len = SysStringLen(str);
if(len > str_len)
len = str_len;
ret = SysAllocStringLen(str, len);
SysFreeString(conv_str);
if(!ret)
return E_OUTOFMEMORY;
return return_bstr(res, ret);
}
static HRESULT Global_LeftB(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
......
......@@ -205,6 +205,16 @@ TestStrReverse "", ""
TestStrReverse 123, "321"
if isEnglishLang then TestStrReverse true, "eurT"
Sub TestLeft(str, len, ex)
Call ok(Left(str, len) = ex, "Left(" & str & ", " & len & ") = " & Left(str, len))
End Sub
TestLeft "test", 2, "te"
TestLeft "test", 5, "test"
TestLeft "test", 0, ""
TestLeft 123, 2, "12"
if isEnglishLang then TestLeft true, 2, "Tr"
Sub TestRound(val, exval, vt)
Call ok(Round(val) = exval, "Round(" & val & ") = " & Round(val))
Call ok(getVT(Round(val)) = vt, "getVT(Round(" & val & ")) = " & getVT(Round(val)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment