Commit e95492bc authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

vbscript: Add UBound implementation.

parent f962bb00
...@@ -822,8 +822,40 @@ static HRESULT Global_LBound(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VA ...@@ -822,8 +822,40 @@ static HRESULT Global_LBound(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VA
static HRESULT Global_UBound(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res) static HRESULT Global_UBound(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
{ {
FIXME("\n"); SAFEARRAY *sa;
return E_NOTIMPL; HRESULT hres;
LONG ubound;
int dim;
assert(args_cnt == 1 || args_cnt == 2);
TRACE("%s %s\n", debugstr_variant(arg), args_cnt == 2 ? debugstr_variant(arg + 1) : "1");
switch(V_VT(arg)) {
case VT_VARIANT|VT_ARRAY:
sa = V_ARRAY(arg);
break;
case VT_VARIANT|VT_ARRAY|VT_BYREF:
sa = *V_ARRAYREF(arg);
break;
default:
FIXME("arg %s not supported\n", debugstr_variant(arg));
return E_NOTIMPL;
}
if(args_cnt == 2) {
hres = to_int(arg + 1, &dim);
if(FAILED(hres))
return hres;
}else {
dim = 1;
}
hres = SafeArrayGetUBound(sa, dim, &ubound);
if(FAILED(hres))
return hres;
return return_int(res, ubound);
} }
static HRESULT Global_RGB(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res) static HRESULT Global_RGB(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
...@@ -2256,7 +2288,7 @@ static const builtin_prop_t global_props[] = { ...@@ -2256,7 +2288,7 @@ static const builtin_prop_t global_props[] = {
{DISPID_GLOBAL_RND, Global_Rnd, 0, 1}, {DISPID_GLOBAL_RND, Global_Rnd, 0, 1},
{DISPID_GLOBAL_TIMER, Global_Timer, 0, 0}, {DISPID_GLOBAL_TIMER, Global_Timer, 0, 0},
{DISPID_GLOBAL_LBOUND, Global_LBound, 0, 1}, {DISPID_GLOBAL_LBOUND, Global_LBound, 0, 1},
{DISPID_GLOBAL_UBOUND, Global_UBound, 0, 1}, {DISPID_GLOBAL_UBOUND, Global_UBound, 0, 1, 2},
{DISPID_GLOBAL_RGB, Global_RGB, 0, 3}, {DISPID_GLOBAL_RGB, Global_RGB, 0, 3},
{DISPID_GLOBAL_LEN, Global_Len, 0, 1}, {DISPID_GLOBAL_LEN, Global_Len, 0, 1},
{DISPID_GLOBAL_LENB, Global_LenB, 0, 1}, {DISPID_GLOBAL_LENB, Global_LenB, 0, 1},
......
...@@ -227,6 +227,16 @@ new_array = x ...@@ -227,6 +227,16 @@ new_array = x
x(0) = "new value" x(0) = "new value"
Call ok(new_array(0) = "a1", "new_array(0) = " & new_array(0)) Call ok(new_array(0) = "a1", "new_array(0) = " & new_array(0))
Call ok(getVT(UBound(x)) = "VT_I4", "getVT(UBound(x)) = " & getVT(UBound(x)))
Call ok(UBound(x) = 2, "UBound(x) = " & UBound(x))
Call ok(getVT(UBound(x, 1)) = "VT_I4", "getVT(UBound(x, 1)) = " & getVT(UBound(x, 1)))
Call ok(UBound(x, 1) = 2, "UBound(x) = " & UBound(x, 1))
Dim arr2(2, 4)
Call ok(UBound(arr2) = 2, "UBound(x) = " & UBound(x))
Call ok(UBound(arr2, 1) = 2, "UBound(x) = " & UBound(x))
Call ok(UBound(arr2, 2) = 4, "UBound(x) = " & UBound(x))
Dim newObject Dim newObject
Set newObject = New ValClass Set newObject = New ValClass
newObject.myval = 1 newObject.myval = 1
......
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