2 * Copyright 2011 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "vbscript_defs.h"
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(vbscript);
32 #define VB_E_CANNOT_CREATE_OBJ 0x800a01ad
34 /* Defined as extern in urlmon.idl, but not exported by uuid.lib */
35 const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY =
36 {0x10200490,0xfa38,0x11d0,{0xac,0x0e,0x00,0xa0,0xc9,0xf,0xff,0xc0}};
38 static const WCHAR emptyW[] = {0};
39 static const WCHAR vbscriptW[] = {'V','B','S','c','r','i','p','t',0};
41 static IInternetHostSecurityManager *get_sec_mgr(script_ctx_t *ctx)
43 IInternetHostSecurityManager *secmgr;
53 hres = IActiveScriptSite_QueryInterface(ctx->site, &IID_IServiceProvider, (void**)&sp);
57 hres = IServiceProvider_QueryService(sp, &SID_SInternetHostSecurityManager, &IID_IInternetHostSecurityManager,
59 IServiceProvider_Release(sp);
63 return ctx->secmgr = secmgr;
66 static HRESULT return_string(VARIANT *res, const WCHAR *str)
73 ret = SysAllocString(str);
82 static HRESULT return_bstr(VARIANT *res, BSTR str)
93 static HRESULT return_short(VARIANT *res, short val)
103 static HRESULT return_int(VARIANT *res, int val)
105 if((short)val == val)
106 return return_short(res, val);
116 static inline HRESULT return_double(VARIANT *res, double val)
126 static inline HRESULT return_null(VARIANT *res)
133 static inline HRESULT return_date(VARIANT *res, double date)
142 static HRESULT to_int(VARIANT *v, int *ret)
152 double n = round(V_R8(v));
154 FIXME("%lf is out of int range\n", n);
161 *ret = V_BOOL(v) ? -1 : 0;
164 FIXME("not supported %s\n", debugstr_variant(v));
171 static HRESULT to_double(VARIANT *v, double *ret)
190 V_VT(&dst) = VT_EMPTY;
191 hres = VariantChangeType(&dst, v, VARIANT_LOCALBOOL, VT_R8);
198 FIXME("arg %s not supported\n", debugstr_variant(v));
205 static HRESULT to_string(VARIANT *v, BSTR *ret)
210 V_VT(&dst) = VT_EMPTY;
211 hres = VariantChangeType(&dst, v, VARIANT_LOCALBOOL, VT_BSTR);
219 static IUnknown *create_object(script_ctx_t *ctx, const WCHAR *progid)
221 IInternetHostSecurityManager *secmgr = NULL;
222 IObjectWithSite *obj_site;
223 struct CONFIRMSAFETY cs;
224 IClassFactoryEx *cfex;
233 hres = CLSIDFromProgID(progid, &guid);
237 TRACE("GUID %s\n", debugstr_guid(&guid));
239 if(ctx->safeopt & INTERFACE_USES_SECURITY_MANAGER) {
240 secmgr = get_sec_mgr(ctx);
245 hres = IInternetHostSecurityManager_ProcessUrlAction(secmgr, URLACTION_ACTIVEX_RUN,
246 (BYTE*)&policy, sizeof(policy), (BYTE*)&guid, sizeof(GUID), 0, 0);
247 if(FAILED(hres) || policy != URLPOLICY_ALLOW)
251 hres = CoGetClassObject(&guid, CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER, NULL, &IID_IClassFactory, (void**)&cf);
255 hres = IClassFactory_QueryInterface(cf, &IID_IClassFactoryEx, (void**)&cfex);
256 if(SUCCEEDED(hres)) {
257 FIXME("Use IClassFactoryEx\n");
258 IClassFactoryEx_Release(cfex);
261 hres = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void**)&obj);
269 hres = IInternetHostSecurityManager_QueryCustomPolicy(secmgr, &GUID_CUSTOM_CONFIRMOBJECTSAFETY,
270 &bpolicy, &policy_size, (BYTE*)&cs, sizeof(cs), 0);
271 if(SUCCEEDED(hres)) {
272 policy = policy_size >= sizeof(DWORD) ? *(DWORD*)bpolicy : URLPOLICY_DISALLOW;
273 CoTaskMemFree(bpolicy);
276 if(FAILED(hres) || policy != URLPOLICY_ALLOW) {
277 IUnknown_Release(obj);
282 hres = IUnknown_QueryInterface(obj, &IID_IObjectWithSite, (void**)&obj_site);
283 if(SUCCEEDED(hres)) {
286 ax_site = create_ax_site(ctx);
288 hres = IObjectWithSite_SetSite(obj_site, ax_site);
289 IUnknown_Release(ax_site);
291 IObjectWithSite_Release(obj_site);
292 if(!ax_site || FAILED(hres)) {
293 IUnknown_Release(obj);
301 static HRESULT show_msgbox(script_ctx_t *ctx, BSTR prompt, VARIANT *res)
303 SCRIPTUICHANDLING uic_handling = SCRIPTUICHANDLING_ALLOW;
304 IActiveScriptSiteUIControl *ui_control;
305 IActiveScriptSiteWindow *acts_window;
311 hres = IActiveScriptSite_QueryInterface(ctx->site, &IID_IActiveScriptSiteUIControl, (void**)&ui_control);
312 if(SUCCEEDED(hres)) {
313 hres = IActiveScriptSiteUIControl_GetUIBehavior(ui_control, SCRIPTUICITEM_MSGBOX, &uic_handling);
314 IActiveScriptSiteUIControl_Release(ui_control);
316 uic_handling = SCRIPTUICHANDLING_ALLOW;
319 switch(uic_handling) {
320 case SCRIPTUICHANDLING_ALLOW:
322 case SCRIPTUICHANDLING_NOUIDEFAULT:
323 return return_short(res, 0);
329 title = (ctx->safeopt & INTERFACE_USES_SECURITY_MANAGER) ? vbscriptW : emptyW;
331 hres = IActiveScriptSite_QueryInterface(ctx->site, &IID_IActiveScriptSiteWindow, (void**)&acts_window);
333 FIXME("No IActiveScriptSiteWindow\n");
337 hres = IActiveScriptSiteWindow_GetWindow(acts_window, &hwnd);
338 if(SUCCEEDED(hres)) {
339 hres = IActiveScriptSiteWindow_EnableModeless(acts_window, FALSE);
340 if(SUCCEEDED(hres)) {
341 ret = MessageBoxW(hwnd, prompt, title, MB_OK);
342 hres = IActiveScriptSiteWindow_EnableModeless(acts_window, TRUE);
346 IActiveScriptSiteWindow_Release(acts_window);
348 FIXME("failed: %08x\n", hres);
352 return return_short(res, ret);
355 static HRESULT Global_CCur(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
361 static HRESULT Global_CInt(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
367 static HRESULT Global_CLng(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
373 static HRESULT Global_CBool(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
379 static HRESULT Global_CByte(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
385 static HRESULT Global_CDate(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
391 static HRESULT Global_CDbl(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
397 static HRESULT Global_CSng(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
403 static HRESULT Global_CStr(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
409 static inline WCHAR hex_char(unsigned n)
411 return n < 10 ? '0'+n : 'A'+n-10;
414 static HRESULT Global_Hex(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
419 TRACE("%s\n", debugstr_variant(arg));
436 FIXME("unsupported type %s\n", debugstr_variant(arg));
445 *ptr-- = hex_char(n & 0xf);
453 return return_string(res, ptr);
456 static HRESULT Global_Oct(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
462 static HRESULT Global_VarType(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
468 static HRESULT Global_IsDate(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
474 static HRESULT Global_IsEmpty(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
476 TRACE("(%s)\n", debugstr_variant(arg));
478 assert(args_cnt == 1);
482 V_BOOL(res) = V_VT(arg) == VT_EMPTY ? VARIANT_TRUE : VARIANT_FALSE;
487 static HRESULT Global_IsNull(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
489 TRACE("(%s)\n", debugstr_variant(arg));
491 assert(args_cnt == 1);
495 V_BOOL(res) = V_VT(arg) == VT_NULL ? VARIANT_TRUE : VARIANT_FALSE;
500 static HRESULT Global_IsNumeric(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
506 static HRESULT Global_IsArray(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
512 static HRESULT Global_IsObject(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
514 TRACE("(%s)\n", debugstr_variant(arg));
516 assert(args_cnt == 1);
520 V_BOOL(res) = V_VT(arg) == VT_DISPATCH ? VARIANT_TRUE : VARIANT_FALSE;
525 static HRESULT Global_Ant(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
531 static HRESULT Global_Cos(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
537 static HRESULT Global_Sin(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
543 static HRESULT Global_Tan(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
549 static HRESULT Global_Exp(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
555 static HRESULT Global_Log(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
561 static HRESULT Global_Sqr(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
567 static HRESULT Global_Randomize(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
573 static HRESULT Global_Rnd(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
579 static HRESULT Global_Timer(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
585 static HRESULT Global_LBound(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
591 static HRESULT Global_UBound(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
597 static HRESULT Global_RGB(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
603 static HRESULT Global_Len(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
608 TRACE("%s\n", debugstr_variant(arg));
610 if(V_VT(arg) == VT_NULL)
611 return return_null(res);
613 if(V_VT(arg) != VT_BSTR) {
616 hres = to_string(arg, &str);
620 len = SysStringLen(str);
623 len = SysStringLen(V_BSTR(arg));
626 return return_int(res, len);
629 static HRESULT Global_LenB(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
635 static HRESULT Global_Left(vbdisp_t *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
637 BSTR str, ret, conv_str = NULL;
641 TRACE("(%s %s)\n", debugstr_variant(args+1), debugstr_variant(args));
643 if(V_VT(args+1) == VT_BSTR) {
644 str = V_BSTR(args+1);
646 hres = to_string(args+1, &conv_str);
652 hres = to_int(args, &len);
657 FIXME("len = %d\n", len);
661 str_len = SysStringLen(str);
665 ret = SysAllocStringLen(str, len);
666 SysFreeString(conv_str);
668 return E_OUTOFMEMORY;
670 return return_bstr(res, ret);
673 static HRESULT Global_LeftB(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
679 static HRESULT Global_Right(vbdisp_t *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
681 BSTR str, ret, conv_str = NULL;
685 TRACE("(%s %s)\n", debugstr_variant(args+1), debugstr_variant(args));
687 if(V_VT(args+1) == VT_BSTR) {
688 str = V_BSTR(args+1);
690 hres = to_string(args+1, &conv_str);
696 hres = to_int(args, &len);
701 FIXME("len = %d\n", len);
705 str_len = SysStringLen(str);
709 ret = SysAllocStringLen(str+str_len-len, len);
710 SysFreeString(conv_str);
712 return E_OUTOFMEMORY;
714 return return_bstr(res, ret);
717 static HRESULT Global_RightB(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
723 static HRESULT Global_Mid(vbdisp_t *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
725 int len = -1, start, str_len;
733 hres = to_int(args, &len);
738 FIXME("len = %d\n", len);
743 hres = to_int(args+args_cnt-2, &start);
747 if(V_VT(args+args_cnt-1) != VT_BSTR) {
748 FIXME("args[0] = %s\n", debugstr_variant(args+args_cnt-1));
752 str = V_BSTR(args+args_cnt-1);
759 str_len = SysStringLen(str);
766 else if(len > str_len-start)
771 V_BSTR(res) = SysAllocStringLen(str+start, len);
773 return E_OUTOFMEMORY;
779 static HRESULT Global_MidB(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
785 static HRESULT Global_StrComp(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
791 static HRESULT Global_LCase(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
796 TRACE("%s\n", debugstr_variant(arg));
798 if(V_VT(arg) == VT_NULL) {
804 hres = to_string(arg, &str);
811 for(ptr = str; *ptr; ptr++)
812 *ptr = tolowerW(*ptr);
822 static HRESULT Global_UCase(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
827 TRACE("%s\n", debugstr_variant(arg));
829 if(V_VT(arg) == VT_NULL) {
835 hres = to_string(arg, &str);
842 for(ptr = str; *ptr; ptr++)
843 *ptr = toupperW(*ptr);
853 static HRESULT Global_LTrim(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
855 BSTR str, conv_str = NULL;
859 TRACE("%s\n", debugstr_variant(arg));
861 if(V_VT(arg) == VT_BSTR) {
864 hres = to_string(arg, &conv_str);
870 for(ptr = str; *ptr && isspaceW(*ptr); ptr++);
872 str = SysAllocString(ptr);
873 SysFreeString(conv_str);
875 return E_OUTOFMEMORY;
877 return return_bstr(res, str);
880 static HRESULT Global_RTrim(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
882 BSTR str, conv_str = NULL;
886 TRACE("%s\n", debugstr_variant(arg));
888 if(V_VT(arg) == VT_BSTR) {
891 hres = to_string(arg, &conv_str);
897 for(ptr = str+SysStringLen(str); ptr-1 > str && isspaceW(*(ptr-1)); ptr--);
899 str = SysAllocStringLen(str, ptr-str);
900 SysFreeString(conv_str);
902 return E_OUTOFMEMORY;
904 return return_bstr(res, str);
907 static HRESULT Global_Trim(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
909 BSTR str, conv_str = NULL;
910 WCHAR *begin_ptr, *end_ptr;
913 TRACE("%s\n", debugstr_variant(arg));
915 if(V_VT(arg) == VT_BSTR) {
918 hres = to_string(arg, &conv_str);
924 for(begin_ptr = str; *begin_ptr && isspaceW(*begin_ptr); begin_ptr++);
925 for(end_ptr = str+SysStringLen(str); end_ptr-1 > begin_ptr && isspaceW(*(end_ptr-1)); end_ptr--);
927 str = SysAllocStringLen(begin_ptr, end_ptr-begin_ptr);
928 SysFreeString(conv_str);
930 return E_OUTOFMEMORY;
932 return return_bstr(res, str);
935 static HRESULT Global_Space(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
941 TRACE("%s\n", debugstr_variant(arg));
943 hres = to_int(arg, &n);
948 FIXME("n = %d\n", n);
955 str = SysAllocStringLen(NULL, n);
957 return E_OUTOFMEMORY;
967 static HRESULT Global_String(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
973 static HRESULT Global_InStr(vbdisp_t *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
975 VARIANT *startv, *str1v, *str2v;
994 FIXME("unsupported compare argument %s\n", debugstr_variant(args));
1001 hres = to_int(startv, &start);
1005 FIXME("start %d\n", start);
1012 if(V_VT(str1v) == VT_NULL || V_VT(str2v) == VT_NULL)
1013 return return_null(res);
1015 if(V_VT(str1v) != VT_BSTR) {
1016 FIXME("Unsupported str1 type %s\n", debugstr_variant(str1v));
1019 str1 = V_BSTR(str1v);
1021 if(V_VT(str2v) != VT_BSTR) {
1022 FIXME("Unsupported str2 type %s\n", debugstr_variant(str2v));
1025 str2 = V_BSTR(str2v);
1027 if(start < SysStringLen(str1)) {
1030 ptr = strstrW(str1+start, str2);
1031 ret = ptr ? ptr-str1+1 : 0;
1036 return return_int(res, ret);
1039 static HRESULT Global_InStrB(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1045 static HRESULT Global_AscB(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1051 static HRESULT Global_ChrB(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1057 static HRESULT Global_Asc(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1063 static HRESULT Global_Chr(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1069 static HRESULT Global_AscW(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1075 static HRESULT Global_ChrW(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1081 static HRESULT Global_Abs(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1087 static HRESULT Global_Fix(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1093 static HRESULT Global_Int(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1099 static HRESULT Global_Sgn(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1105 static HRESULT Global_Now(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1113 SystemTimeToVariantTime(<, &date);
1114 return return_date(res, date);
1117 static HRESULT Global_Date(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1123 static HRESULT Global_Time(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1129 static HRESULT Global_Day(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1135 static HRESULT Global_Month(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1141 static HRESULT Global_Weekday(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1147 static HRESULT Global_Year(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1153 static HRESULT Global_Hour(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1159 static HRESULT Global_Minute(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1165 static HRESULT Global_Second(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1171 static HRESULT Global_DateValue(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1177 static HRESULT Global_TimeValue(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1183 static HRESULT Global_DateSerial(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1189 static HRESULT Global_TimeSerial(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1195 static HRESULT Global_InputBox(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1201 static HRESULT Global_MsgBox(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1209 FIXME("unsupported arg_cnt %d\n", args_cnt);
1213 hres = to_string(arg, &prompt);
1217 hres = show_msgbox(This->desc->ctx, prompt, res);
1218 SysFreeString(prompt);
1222 static HRESULT Global_CreateObject(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1227 TRACE("(%s)\n", debugstr_variant(arg));
1229 if(V_VT(arg) != VT_BSTR) {
1230 FIXME("non-bstr arg\n");
1231 return E_INVALIDARG;
1234 obj = create_object(This->desc->ctx, V_BSTR(arg));
1236 return VB_E_CANNOT_CREATE_OBJ;
1239 hres = IUnknown_QueryInterface(obj, &IID_IDispatch, (void**)&V_DISPATCH(res));
1243 V_VT(res) = VT_DISPATCH;
1246 IUnknown_Release(obj);
1250 static HRESULT Global_GetObject(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1256 static HRESULT Global_DateAdd(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1262 static HRESULT Global_DateDiff(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1268 static HRESULT Global_DatePart(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1274 static HRESULT Global_TypeName(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1280 static HRESULT Global_Array(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1286 static HRESULT Global_Erase(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1292 static HRESULT Global_Filter(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1298 static HRESULT Global_Join(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1304 static HRESULT Global_Split(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1310 static HRESULT Global_Replace(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1316 static HRESULT Global_StrReverse(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1318 WCHAR *ptr1, *ptr2, ch;
1322 TRACE("%s\n", debugstr_variant(arg));
1324 hres = to_string(arg, &ret);
1329 ptr2 = ret + SysStringLen(ret)-1;
1330 while(ptr1 < ptr2) {
1336 return return_bstr(res, ret);
1339 static HRESULT Global_InStrRev(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1345 static HRESULT Global_LoadPicture(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1351 static HRESULT Global_ScriptEngine(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1357 static HRESULT Global_ScriptEngineMajorVersion(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1363 static HRESULT Global_ScriptEngineMinorVersion(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1369 static HRESULT Global_ScriptEngineBuildVersion(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1375 static HRESULT Global_FormatNumber(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1381 static HRESULT Global_FormatCurrency(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1387 static HRESULT Global_FormatPercent(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1393 static HRESULT Global_FormatDateTime(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1399 static HRESULT Global_WeekdayName(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1401 int weekday, first_day = 0, abbrev = 0;
1407 assert(1 <= args_cnt && args_cnt <= 3);
1409 hres = to_int(arg+args_cnt-1, &weekday);
1414 hres = to_int(arg+args_cnt-2, &abbrev);
1419 hres = to_int(arg, &first_day);
1425 hres = VarWeekdayName(weekday, abbrev, first_day, 0, &ret);
1429 return return_bstr(res, ret);
1432 static HRESULT Global_MonthName(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1434 int month, abbrev = 0;
1440 assert(args_cnt == 1 || args_cnt == 2);
1442 hres = to_int(arg+args_cnt-1, &month);
1447 hres = to_int(arg, &abbrev);
1452 hres = VarMonthName(month, abbrev, 0, &ret);
1456 return return_bstr(res, ret);
1459 static HRESULT Global_Round(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1464 TRACE("%s\n", debugstr_variant(arg));
1479 hres = to_double(arg, &n);
1484 return return_double(res, round(n));
1487 static HRESULT Global_Escape(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1493 static HRESULT Global_Unescape(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1499 static HRESULT Global_Eval(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1505 static HRESULT Global_Execute(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1511 static HRESULT Global_ExecuteGlobal(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1517 static HRESULT Global_GetRef(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1523 static HRESULT Global_vbUseSystem(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1529 static HRESULT Global_vbUseSystemDayOfWeek(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1535 static HRESULT Global_vbSunday(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1538 return return_short(res, 1);
1541 static HRESULT Global_vbMonday(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1544 return return_short(res, 2);
1547 static HRESULT Global_vbTuesday(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1550 return return_short(res, 3);
1553 static HRESULT Global_vbWednesday(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1556 return return_short(res, 4);
1559 static HRESULT Global_vbThursday(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1562 return return_short(res, 5);
1565 static HRESULT Global_vbFriday(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1568 return return_short(res, 6);
1571 static HRESULT Global_vbSaturday(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1574 return return_short(res, 7);
1577 static HRESULT Global_vbFirstJan1(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1583 static HRESULT Global_vbFirstFourDays(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1589 static HRESULT Global_vbFirstFullWeek(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1595 static HRESULT Global_vbOKOnly(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1598 return return_short(res, MB_OK);
1601 static HRESULT Global_vbOKCancel(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1604 return return_short(res, MB_OKCANCEL);
1607 static HRESULT Global_vbAbortRetryIgnore(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1610 return return_short(res, MB_ABORTRETRYIGNORE);
1613 static HRESULT Global_vbYesNoCancel(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1616 return return_short(res, MB_YESNOCANCEL);
1619 static HRESULT Global_vbYesNo(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1622 return return_short(res, MB_YESNO);
1625 static HRESULT Global_vbRetryCancel(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1628 return return_short(res, MB_RETRYCANCEL);
1631 static HRESULT Global_vbCritical(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1637 static HRESULT Global_vbQuestion(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1643 static HRESULT Global_vbExclamation(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1649 static HRESULT Global_vbInformation(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1655 static HRESULT Global_vbDefaultButton1(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1661 static HRESULT Global_vbDefaultButton2(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1667 static HRESULT Global_vbDefaultButton3(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1673 static HRESULT Global_vbDefaultButton4(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1679 static HRESULT Global_vbApplicationModal(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1685 static HRESULT Global_vbSystemModal(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1691 static HRESULT Global_vbOK(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1694 return return_short(res, IDOK);
1697 static HRESULT Global_vbCancel(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1700 return return_short(res, IDCANCEL);
1703 static HRESULT Global_vbAbort(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1706 return return_short(res, IDABORT);
1709 static HRESULT Global_vbRetry(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1712 return return_short(res, IDRETRY);
1715 static HRESULT Global_vbIgnore(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1718 return return_short(res, IDIGNORE);
1721 static HRESULT Global_vbYes(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1724 return return_short(res, IDYES);
1727 static HRESULT Global_vbNo(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1730 return return_short(res, IDNO);
1733 static HRESULT Global_vbEmpty(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1739 static HRESULT Global_vbNull(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1745 static HRESULT Global_vbInteger(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1751 static HRESULT Global_vbLong(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1757 static HRESULT Global_vbSingle(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1763 static HRESULT Global_vbDouble(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1769 static HRESULT Global_vbCurrency(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1775 static HRESULT Global_vbDate(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1781 static HRESULT Global_vbString(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1787 static HRESULT Global_vbObject(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1793 static HRESULT Global_vbError(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1799 static HRESULT Global_vbBoolean(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1805 static HRESULT Global_vbVariant(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1811 static HRESULT Global_vbDataObject(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1817 static HRESULT Global_vbDecimal(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1823 static HRESULT Global_vbByte(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1829 static HRESULT Global_vbArray(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1835 static HRESULT Global_vbTrue(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1841 static HRESULT Global_vbFalse(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1847 static HRESULT Global_vbUseDefault(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1853 static HRESULT Global_vbBinaryCompare(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1859 static HRESULT Global_vbTextCompare(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1865 static HRESULT Global_vbDatabaseCompare(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1871 static HRESULT Global_vbGeneralDate(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1877 static HRESULT Global_vbLongDate(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1883 static HRESULT Global_vbShortDate(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1889 static HRESULT Global_vbLongTime(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1895 static HRESULT Global_vbShortTime(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1901 static HRESULT Global_vbObjectError(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1907 static HRESULT Global_vbBlack(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1913 static HRESULT Global_vbBlue(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1919 static HRESULT Global_vbCyan(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1925 static HRESULT Global_vbGreen(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1931 static HRESULT Global_vbMagenta(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1937 static HRESULT Global_vbRed(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1943 static HRESULT Global_vbWhite(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1949 static HRESULT Global_vbYellow(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1955 static HRESULT Global_vbCr(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1961 static HRESULT Global_vbCrLf(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1967 static HRESULT Global_vbNewLine(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1973 static HRESULT Global_vbFormFeed(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1979 static HRESULT Global_vbLf(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1985 static HRESULT Global_vbNullChar(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1991 static HRESULT Global_vbNullString(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1997 static HRESULT Global_vbTab(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
2003 static HRESULT Global_vbVerticalTab(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
2009 static HRESULT Global_vbMsgBoxHelpButton(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
2015 static HRESULT Global_vbMsgBoxSetForeground(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
2021 static HRESULT Global_vbMsgBoxRight(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
2027 static HRESULT Global_vbMsgBoxRtlReading(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
2033 static const builtin_prop_t global_props[] = {
2034 {DISPID_GLOBAL_VBUSESYSTEM, Global_vbUseSystem, BP_GET},
2035 {DISPID_GLOBAL_USESYSTEMDAYOFWEEK, Global_vbUseSystemDayOfWeek, BP_GET},
2036 {DISPID_GLOBAL_VBSUNDAY, Global_vbSunday, BP_GET},
2037 {DISPID_GLOBAL_VBMONDAY, Global_vbMonday, BP_GET},
2038 {DISPID_GLOBAL_VBTUESDAY, Global_vbTuesday, BP_GET},
2039 {DISPID_GLOBAL_VBWEDNESDAY, Global_vbWednesday, BP_GET},
2040 {DISPID_GLOBAL_VBTHURSDAY, Global_vbThursday, BP_GET},
2041 {DISPID_GLOBAL_VBFRIDAY, Global_vbFriday, BP_GET},
2042 {DISPID_GLOBAL_VBSATURDAY, Global_vbSaturday, BP_GET},
2043 {DISPID_GLOBAL_VBFIRSTJAN1, Global_vbFirstJan1, BP_GET},
2044 {DISPID_GLOBAL_VBFIRSTFOURDAYS, Global_vbFirstFourDays, BP_GET},
2045 {DISPID_GLOBAL_VBFIRSTFULLWEEK, Global_vbFirstFullWeek, BP_GET},
2046 {DISPID_GLOBAL_VBOKONLY, Global_vbOKOnly, BP_GET},
2047 {DISPID_GLOBAL_VBOKCANCEL, Global_vbOKCancel, BP_GET},
2048 {DISPID_GLOBAL_VBABORTRETRYIGNORE, Global_vbAbortRetryIgnore, BP_GET},
2049 {DISPID_GLOBAL_VBYESNOCANCEL, Global_vbYesNoCancel, BP_GET},
2050 {DISPID_GLOBAL_VBYESNO, Global_vbYesNo, BP_GET},
2051 {DISPID_GLOBAL_VBRETRYCANCEL, Global_vbRetryCancel, BP_GET},
2052 {DISPID_GLOBAL_VBCRITICAL, Global_vbCritical, BP_GET},
2053 {DISPID_GLOBAL_VBQUESTION, Global_vbQuestion, BP_GET},
2054 {DISPID_GLOBAL_VBEXCLAMATION, Global_vbExclamation, BP_GET},
2055 {DISPID_GLOBAL_VBINFORMATION, Global_vbInformation, BP_GET},
2056 {DISPID_GLOBAL_VBDEFAULTBUTTON1, Global_vbDefaultButton1, BP_GET},
2057 {DISPID_GLOBAL_VBDEFAULTBUTTON2, Global_vbDefaultButton2, BP_GET},
2058 {DISPID_GLOBAL_VBDEFAULTBUTTON3, Global_vbDefaultButton3, BP_GET},
2059 {DISPID_GLOBAL_VBDEFAULTBUTTON4, Global_vbDefaultButton4, BP_GET},
2060 {DISPID_GLOBAL_VBAPPLICATIONMODAL, Global_vbApplicationModal, BP_GET},
2061 {DISPID_GLOBAL_VBSYSTEMMODAL, Global_vbSystemModal, BP_GET},
2062 {DISPID_GLOBAL_VBOK, Global_vbOK, BP_GET},
2063 {DISPID_GLOBAL_VBCANCEL, Global_vbCancel, BP_GET},
2064 {DISPID_GLOBAL_VBABORT, Global_vbAbort, BP_GET},
2065 {DISPID_GLOBAL_VBRETRY, Global_vbRetry, BP_GET},
2066 {DISPID_GLOBAL_VBIGNORE, Global_vbIgnore, BP_GET},
2067 {DISPID_GLOBAL_VBYES, Global_vbYes, BP_GET},
2068 {DISPID_GLOBAL_VBNO, Global_vbNo, BP_GET},
2069 {DISPID_GLOBAL_VBEMPTY, Global_vbEmpty, BP_GET},
2070 {DISPID_GLOBAL_VBNULL, Global_vbNull, BP_GET},
2071 {DISPID_GLOBAL_VBINTEGER, Global_vbInteger, BP_GET},
2072 {DISPID_GLOBAL_VBLONG, Global_vbLong, BP_GET},
2073 {DISPID_GLOBAL_VBSINGLE, Global_vbSingle, BP_GET},
2074 {DISPID_GLOBAL_VBDOUBLE, Global_vbDouble, BP_GET},
2075 {DISPID_GLOBAL_VBCURRENCY, Global_vbCurrency, BP_GET},
2076 {DISPID_GLOBAL_VBDATE, Global_vbDate, BP_GET},
2077 {DISPID_GLOBAL_VBSTRING, Global_vbString, BP_GET},
2078 {DISPID_GLOBAL_VBOBJECT, Global_vbObject, BP_GET},
2079 {DISPID_GLOBAL_VBERROR, Global_vbError, BP_GET},
2080 {DISPID_GLOBAL_VBBOOLEAN, Global_vbBoolean, BP_GET},
2081 {DISPID_GLOBAL_VBVARIANT, Global_vbVariant, BP_GET},
2082 {DISPID_GLOBAL_VBDATAOBJECT, Global_vbDataObject, BP_GET},
2083 {DISPID_GLOBAL_VBDECIMAL, Global_vbDecimal, BP_GET},
2084 {DISPID_GLOBAL_VBBYTE, Global_vbByte, BP_GET},
2085 {DISPID_GLOBAL_VBARRAY, Global_vbArray, BP_GET},
2086 {DISPID_GLOBAL_VBTRUE, Global_vbTrue, BP_GET},
2087 {DISPID_GLOBAL_VBFALSE, Global_vbFalse, BP_GET},
2088 {DISPID_GLOBAL_VBUSEDEFAULT, Global_vbUseDefault, BP_GET},
2089 {DISPID_GLOBAL_VBBINARYCOMPARE, Global_vbBinaryCompare, BP_GET},
2090 {DISPID_GLOBAL_VBTEXTCOMPARE, Global_vbTextCompare, BP_GET},
2091 {DISPID_GLOBAL_VBDATABASECOMPARE, Global_vbDatabaseCompare, BP_GET},
2092 {DISPID_GLOBAL_VBGENERALDATE, Global_vbGeneralDate, BP_GET},
2093 {DISPID_GLOBAL_VBLONGDATE, Global_vbLongDate, BP_GET},
2094 {DISPID_GLOBAL_VBSHORTDATE, Global_vbShortDate, BP_GET},
2095 {DISPID_GLOBAL_VBLONGTIME, Global_vbLongTime, BP_GET},
2096 {DISPID_GLOBAL_VBSHORTTIME, Global_vbShortTime, BP_GET},
2097 {DISPID_GLOBAL_VBOBJECTERROR, Global_vbObjectError, BP_GET},
2098 {DISPID_GLOBAL_VBBLACK, Global_vbBlack, BP_GET},
2099 {DISPID_GLOBAL_VBBLUE, Global_vbBlue, BP_GET},
2100 {DISPID_GLOBAL_VBCYAN, Global_vbCyan, BP_GET},
2101 {DISPID_GLOBAL_VBGREEN, Global_vbGreen, BP_GET},
2102 {DISPID_GLOBAL_VBMAGENTA, Global_vbMagenta, BP_GET},
2103 {DISPID_GLOBAL_VBRED, Global_vbRed, BP_GET},
2104 {DISPID_GLOBAL_VBWHITE, Global_vbWhite, BP_GET},
2105 {DISPID_GLOBAL_VBYELLOW, Global_vbYellow, BP_GET},
2106 {DISPID_GLOBAL_VBCR, Global_vbCr, BP_GET},
2107 {DISPID_GLOBAL_VBCRLF, Global_vbCrLf, BP_GET},
2108 {DISPID_GLOBAL_VBNEWLINE, Global_vbNewLine, BP_GET},
2109 {DISPID_GLOBAL_VBFORMFEED, Global_vbFormFeed, BP_GET},
2110 {DISPID_GLOBAL_VBLF, Global_vbLf, BP_GET},
2111 {DISPID_GLOBAL_VBNULLCHAR, Global_vbNullChar, BP_GET},
2112 {DISPID_GLOBAL_VBNULLSTRING, Global_vbNullString, BP_GET},
2113 {DISPID_GLOBAL_VBTAB, Global_vbTab, BP_GET},
2114 {DISPID_GLOBAL_VBVERTICALTAB, Global_vbVerticalTab, BP_GET},
2115 {DISPID_GLOBAL_CCUR, Global_CCur, 0, 1},
2116 {DISPID_GLOBAL_CINT, Global_CInt, 0, 1},
2117 {DISPID_GLOBAL_CLNG, Global_CLng, 0, 1},
2118 {DISPID_GLOBAL_CBOOL, Global_CBool, 0, 1},
2119 {DISPID_GLOBAL_CBYTE, Global_CByte, 0, 1},
2120 {DISPID_GLOBAL_CDATE, Global_CDate, 0, 1},
2121 {DISPID_GLOBAL_CDBL, Global_CDbl, 0, 1},
2122 {DISPID_GLOBAL_CSNG, Global_CSng, 0, 1},
2123 {DISPID_GLOBAL_CSTR, Global_CStr, 0, 1},
2124 {DISPID_GLOBAL_HEX, Global_Hex, 0, 1},
2125 {DISPID_GLOBAL_OCT, Global_Oct, 0, 1},
2126 {DISPID_GLOBAL_VARTYPE, Global_VarType, 0, 1},
2127 {DISPID_GLOBAL_ISDATE, Global_IsDate, 0, 1},
2128 {DISPID_GLOBAL_ISEMPTY, Global_IsEmpty, 0, 1},
2129 {DISPID_GLOBAL_ISNULL, Global_IsNull, 0, 1},
2130 {DISPID_GLOBAL_ISNUMERIC, Global_IsNumeric, 0, 1},
2131 {DISPID_GLOBAL_ISARRAY, Global_IsArray, 0, 1},
2132 {DISPID_GLOBAL_ISOBJECT, Global_IsObject, 0, 1},
2133 {DISPID_GLOBAL_ATN, Global_Ant, 0, 1},
2134 {DISPID_GLOBAL_COS, Global_Cos, 0, 1},
2135 {DISPID_GLOBAL_SIN, Global_Sin, 0, 1},
2136 {DISPID_GLOBAL_TAN, Global_Tan, 0, 1},
2137 {DISPID_GLOBAL_EXP, Global_Exp, 0, 1},
2138 {DISPID_GLOBAL_LOG, Global_Log, 0, 1},
2139 {DISPID_GLOBAL_SQR, Global_Sqr, 0, 1},
2140 {DISPID_GLOBAL_RANDOMIZE, Global_Randomize, 0, 1},
2141 {DISPID_GLOBAL_RND, Global_Rnd, 0, 1},
2142 {DISPID_GLOBAL_TIMER, Global_Timer, 0, 0},
2143 {DISPID_GLOBAL_LBOUND, Global_LBound, 0, 1},
2144 {DISPID_GLOBAL_UBOUND, Global_UBound, 0, 1},
2145 {DISPID_GLOBAL_RGB, Global_RGB, 0, 3},
2146 {DISPID_GLOBAL_LEN, Global_Len, 0, 1},
2147 {DISPID_GLOBAL_LENB, Global_LenB, 0, 1},
2148 {DISPID_GLOBAL_LEFT, Global_Left, 0, 2},
2149 {DISPID_GLOBAL_LEFTB, Global_LeftB, 0, 2},
2150 {DISPID_GLOBAL_RIGHT, Global_Right, 0, 2},
2151 {DISPID_GLOBAL_RIGHTB, Global_RightB, 0, 2},
2152 {DISPID_GLOBAL_MID, Global_Mid, 0, 2, 3},
2153 {DISPID_GLOBAL_MIDB, Global_MidB, 0, 2, 3},
2154 {DISPID_GLOBAL_STRCOMP, Global_StrComp, 0, 2, 3},
2155 {DISPID_GLOBAL_LCASE, Global_LCase, 0, 1},
2156 {DISPID_GLOBAL_UCASE, Global_UCase, 0, 1},
2157 {DISPID_GLOBAL_LTRIM, Global_LTrim, 0, 1},
2158 {DISPID_GLOBAL_RTRIM, Global_RTrim, 0, 1},
2159 {DISPID_GLOBAL_TRIM, Global_Trim, 0, 1},
2160 {DISPID_GLOBAL_SPACE, Global_Space, 0, 1},
2161 {DISPID_GLOBAL_STRING, Global_String, 0, 0, 2},
2162 {DISPID_GLOBAL_INSTR, Global_InStr, 0, 2, 4},
2163 {DISPID_GLOBAL_INSTRB, Global_InStrB, 0, 3, 4},
2164 {DISPID_GLOBAL_ASCB, Global_AscB, 0, 1},
2165 {DISPID_GLOBAL_CHRB, Global_ChrB, 0, 1},
2166 {DISPID_GLOBAL_ASC, Global_Asc, 0, 1},
2167 {DISPID_GLOBAL_CHR, Global_Chr, 0, 1},
2168 {DISPID_GLOBAL_ASCW, Global_AscW, 0, 1},
2169 {DISPID_GLOBAL_CHRW, Global_ChrW, 0, 1},
2170 {DISPID_GLOBAL_ABS, Global_Abs, 0, 1},
2171 {DISPID_GLOBAL_FIX, Global_Fix, 0, 1},
2172 {DISPID_GLOBAL_INT, Global_Int, 0, 1},
2173 {DISPID_GLOBAL_SGN, Global_Sgn, 0, 1},
2174 {DISPID_GLOBAL_NOW, Global_Now, 0, 0},
2175 {DISPID_GLOBAL_DATE, Global_Date, 0, 0},
2176 {DISPID_GLOBAL_TIME, Global_Time, 0, 0},
2177 {DISPID_GLOBAL_DAY, Global_Day, 0, 1},
2178 {DISPID_GLOBAL_MONTH, Global_Month, 0, 1},
2179 {DISPID_GLOBAL_WEEKDAY, Global_Weekday, 0, 1, 2},
2180 {DISPID_GLOBAL_YEAR, Global_Year, 0, 1},
2181 {DISPID_GLOBAL_HOUR, Global_Hour, 0, 1},
2182 {DISPID_GLOBAL_MINUTE, Global_Minute, 0, 1},
2183 {DISPID_GLOBAL_SECOND, Global_Second, 0, 1},
2184 {DISPID_GLOBAL_DATEVALUE, Global_DateValue, 0, 1},
2185 {DISPID_GLOBAL_TIMEVALUE, Global_TimeValue, 0, 1},
2186 {DISPID_GLOBAL_DATESERIAL, Global_DateSerial, 0, 3},
2187 {DISPID_GLOBAL_TIMESERIAL, Global_TimeSerial, 0, 3},
2188 {DISPID_GLOBAL_INPUTBOX, Global_InputBox, 0, 1, 7},
2189 {DISPID_GLOBAL_MSGBOX, Global_MsgBox, 0, 1, 5},
2190 {DISPID_GLOBAL_CREATEOBJECT, Global_CreateObject, 0, 1},
2191 {DISPID_GLOBAL_GETOBJECT, Global_GetObject, 0, 0, 2},
2192 {DISPID_GLOBAL_DATEADD, Global_DateAdd, 0, 3},
2193 {DISPID_GLOBAL_DATEDIFF, Global_DateDiff, 0, 3, 5},
2194 {DISPID_GLOBAL_DATEPART, Global_DatePart, 0, 2, 4},
2195 {DISPID_GLOBAL_TYPENAME, Global_TypeName, 0, 1},
2196 {DISPID_GLOBAL_ARRAY, Global_Array, 0, 1},
2197 {DISPID_GLOBAL_ERASE, Global_Erase, 0, 1},
2198 {DISPID_GLOBAL_FILTER, Global_Filter, 0, 2, 4},
2199 {DISPID_GLOBAL_JOIN, Global_Join, 0, 1, 2},
2200 {DISPID_GLOBAL_SPLIT, Global_Split, 0, 1, 4},
2201 {DISPID_GLOBAL_REPLACE, Global_Replace, 0, 3, 6},
2202 {DISPID_GLOBAL_STRREVERSE, Global_StrReverse, 0, 1},
2203 {DISPID_GLOBAL_INSTRREV, Global_InStrRev, 0, 2, 4},
2204 {DISPID_GLOBAL_LOADPICTURE, Global_LoadPicture, 0, 1},
2205 {DISPID_GLOBAL_SCRIPTENGINE, Global_ScriptEngine, 0, 0},
2206 {DISPID_GLOBAL_SCRIPTENGINEMAJORVERSION, Global_ScriptEngineMajorVersion, 0, 0},
2207 {DISPID_GLOBAL_SCRIPTENGINEMINORVERSION, Global_ScriptEngineMinorVersion, 0, 0},
2208 {DISPID_GLOBAL_SCRIPTENGINEBUILDVERSION, Global_ScriptEngineBuildVersion, 0, 0},
2209 {DISPID_GLOBAL_FORMATNUMBER, Global_FormatNumber, 0, 1, 5},
2210 {DISPID_GLOBAL_FORMATCURRENCY, Global_FormatCurrency, 0, 1, 5},
2211 {DISPID_GLOBAL_FORMATPERCENT, Global_FormatPercent, 0, 1, 5},
2212 {DISPID_GLOBAL_FORMATDATETIME, Global_FormatDateTime, 0, 1, 2},
2213 {DISPID_GLOBAL_WEEKDAYNAME, Global_WeekdayName, 0, 1, 3},
2214 {DISPID_GLOBAL_MONTHNAME, Global_MonthName, 0, 1, 2},
2215 {DISPID_GLOBAL_ROUND, Global_Round, 0, 1, 2},
2216 {DISPID_GLOBAL_ESCAPE, Global_Escape, 0, 1},
2217 {DISPID_GLOBAL_UNESCAPE, Global_Unescape, 0, 1},
2218 {DISPID_GLOBAL_EVAL, Global_Eval, 0, 1},
2219 {DISPID_GLOBAL_EXECUTE, Global_Execute, 0, 1},
2220 {DISPID_GLOBAL_EXECUTEGLOBAL, Global_ExecuteGlobal, 0, 1},
2221 {DISPID_GLOBAL_GETREF, Global_GetRef, 0, 1},
2222 {DISPID_GLOBAL_VBMSGBOXHELPBUTTON, Global_vbMsgBoxHelpButton, BP_GET},
2223 {DISPID_GLOBAL_VBMSGBOXSETFOREGROUND, Global_vbMsgBoxSetForeground, BP_GET},
2224 {DISPID_GLOBAL_VBMSGBOXRIGHT, Global_vbMsgBoxRight, BP_GET},
2225 {DISPID_GLOBAL_VBMSGBOXRTLREADING, Global_vbMsgBoxRtlReading, BP_GET}
2228 HRESULT init_global(script_ctx_t *ctx)
2232 ctx->global_desc.ctx = ctx;
2233 ctx->global_desc.builtin_prop_cnt = sizeof(global_props)/sizeof(*global_props);
2234 ctx->global_desc.builtin_props = global_props;
2236 hres = get_typeinfo(GlobalObj_tid, &ctx->global_desc.typeinfo);
2240 hres = create_vbdisp(&ctx->global_desc, &ctx->global_obj);
2244 hres = create_script_disp(ctx, &ctx->script_obj);
2248 return init_err(ctx);