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
)
408 TRACE("%s\n", debugstr_variant(arg
));
410 hres
= to_string(arg
, &str
);
414 return return_bstr(res
, str
);
417 static inline WCHAR
hex_char(unsigned n
)
419 return n
< 10 ? '0'+n
: 'A'+n
-10;
422 static HRESULT
Global_Hex(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
427 TRACE("%s\n", debugstr_variant(arg
));
444 FIXME("unsupported type %s\n", debugstr_variant(arg
));
453 *ptr
-- = hex_char(n
& 0xf);
461 return return_string(res
, ptr
);
464 static HRESULT
Global_Oct(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
470 static HRESULT
Global_VarType(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
476 static HRESULT
Global_IsDate(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
482 static HRESULT
Global_IsEmpty(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
484 TRACE("(%s)\n", debugstr_variant(arg
));
486 assert(args_cnt
== 1);
490 V_BOOL(res
) = V_VT(arg
) == VT_EMPTY
? VARIANT_TRUE
: VARIANT_FALSE
;
495 static HRESULT
Global_IsNull(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
497 TRACE("(%s)\n", debugstr_variant(arg
));
499 assert(args_cnt
== 1);
503 V_BOOL(res
) = V_VT(arg
) == VT_NULL
? VARIANT_TRUE
: VARIANT_FALSE
;
508 static HRESULT
Global_IsNumeric(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
514 static HRESULT
Global_IsArray(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
520 static HRESULT
Global_IsObject(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
522 TRACE("(%s)\n", debugstr_variant(arg
));
524 assert(args_cnt
== 1);
528 V_BOOL(res
) = V_VT(arg
) == VT_DISPATCH
? VARIANT_TRUE
: VARIANT_FALSE
;
533 static HRESULT
Global_Ant(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
539 static HRESULT
Global_Cos(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
545 static HRESULT
Global_Sin(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
551 static HRESULT
Global_Tan(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
557 static HRESULT
Global_Exp(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
563 static HRESULT
Global_Log(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
569 static HRESULT
Global_Sqr(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
575 static HRESULT
Global_Randomize(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
581 static HRESULT
Global_Rnd(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
587 static HRESULT
Global_Timer(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
593 static HRESULT
Global_LBound(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
599 static HRESULT
Global_UBound(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
605 static HRESULT
Global_RGB(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
611 static HRESULT
Global_Len(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
616 TRACE("%s\n", debugstr_variant(arg
));
618 if(V_VT(arg
) == VT_NULL
)
619 return return_null(res
);
621 if(V_VT(arg
) != VT_BSTR
) {
624 hres
= to_string(arg
, &str
);
628 len
= SysStringLen(str
);
631 len
= SysStringLen(V_BSTR(arg
));
634 return return_int(res
, len
);
637 static HRESULT
Global_LenB(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
643 static HRESULT
Global_Left(vbdisp_t
*This
, VARIANT
*args
, unsigned args_cnt
, VARIANT
*res
)
645 BSTR str
, ret
, conv_str
= NULL
;
649 TRACE("(%s %s)\n", debugstr_variant(args
+1), debugstr_variant(args
));
651 if(V_VT(args
) == VT_BSTR
) {
654 hres
= to_string(args
, &conv_str
);
660 hres
= to_int(args
+1, &len
);
665 FIXME("len = %d\n", len
);
669 str_len
= SysStringLen(str
);
673 ret
= SysAllocStringLen(str
, len
);
674 SysFreeString(conv_str
);
676 return E_OUTOFMEMORY
;
678 return return_bstr(res
, ret
);
681 static HRESULT
Global_LeftB(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
687 static HRESULT
Global_Right(vbdisp_t
*This
, VARIANT
*args
, unsigned args_cnt
, VARIANT
*res
)
689 BSTR str
, ret
, conv_str
= NULL
;
693 TRACE("(%s %s)\n", debugstr_variant(args
), debugstr_variant(args
+1));
695 if(V_VT(args
+1) == VT_BSTR
) {
698 hres
= to_string(args
, &conv_str
);
704 hres
= to_int(args
+1, &len
);
709 FIXME("len = %d\n", len
);
713 str_len
= SysStringLen(str
);
717 ret
= SysAllocStringLen(str
+str_len
-len
, len
);
718 SysFreeString(conv_str
);
720 return E_OUTOFMEMORY
;
722 return return_bstr(res
, ret
);
725 static HRESULT
Global_RightB(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
731 static HRESULT
Global_Mid(vbdisp_t
*This
, VARIANT
*args
, unsigned args_cnt
, VARIANT
*res
)
733 int len
= -1, start
, str_len
;
737 TRACE("(%s %s ...)\n", debugstr_variant(args
), debugstr_variant(args
+1));
739 assert(args_cnt
== 2 || args_cnt
== 3);
741 if(V_VT(args
) != VT_BSTR
) {
742 FIXME("args[0] = %s\n", debugstr_variant(args
));
748 hres
= to_int(args
+1, &start
);
753 hres
= to_int(args
+2, &len
);
758 FIXME("len = %d\n", len
);
764 str_len
= SysStringLen(str
);
771 else if(len
> str_len
-start
)
776 V_BSTR(res
) = SysAllocStringLen(str
+start
, len
);
778 return E_OUTOFMEMORY
;
784 static HRESULT
Global_MidB(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
790 static HRESULT
Global_StrComp(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
796 static HRESULT
Global_LCase(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
801 TRACE("%s\n", debugstr_variant(arg
));
803 if(V_VT(arg
) == VT_NULL
) {
809 hres
= to_string(arg
, &str
);
816 for(ptr
= str
; *ptr
; ptr
++)
817 *ptr
= tolowerW(*ptr
);
827 static HRESULT
Global_UCase(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
832 TRACE("%s\n", debugstr_variant(arg
));
834 if(V_VT(arg
) == VT_NULL
) {
840 hres
= to_string(arg
, &str
);
847 for(ptr
= str
; *ptr
; ptr
++)
848 *ptr
= toupperW(*ptr
);
858 static HRESULT
Global_LTrim(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
860 BSTR str
, conv_str
= NULL
;
864 TRACE("%s\n", debugstr_variant(arg
));
866 if(V_VT(arg
) == VT_BSTR
) {
869 hres
= to_string(arg
, &conv_str
);
875 for(ptr
= str
; *ptr
&& isspaceW(*ptr
); ptr
++);
877 str
= SysAllocString(ptr
);
878 SysFreeString(conv_str
);
880 return E_OUTOFMEMORY
;
882 return return_bstr(res
, str
);
885 static HRESULT
Global_RTrim(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
887 BSTR str
, conv_str
= NULL
;
891 TRACE("%s\n", debugstr_variant(arg
));
893 if(V_VT(arg
) == VT_BSTR
) {
896 hres
= to_string(arg
, &conv_str
);
902 for(ptr
= str
+SysStringLen(str
); ptr
-1 > str
&& isspaceW(*(ptr
-1)); ptr
--);
904 str
= SysAllocStringLen(str
, ptr
-str
);
905 SysFreeString(conv_str
);
907 return E_OUTOFMEMORY
;
909 return return_bstr(res
, str
);
912 static HRESULT
Global_Trim(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
914 BSTR str
, conv_str
= NULL
;
915 WCHAR
*begin_ptr
, *end_ptr
;
918 TRACE("%s\n", debugstr_variant(arg
));
920 if(V_VT(arg
) == VT_BSTR
) {
923 hres
= to_string(arg
, &conv_str
);
929 for(begin_ptr
= str
; *begin_ptr
&& isspaceW(*begin_ptr
); begin_ptr
++);
930 for(end_ptr
= str
+SysStringLen(str
); end_ptr
-1 > begin_ptr
&& isspaceW(*(end_ptr
-1)); end_ptr
--);
932 str
= SysAllocStringLen(begin_ptr
, end_ptr
-begin_ptr
);
933 SysFreeString(conv_str
);
935 return E_OUTOFMEMORY
;
937 return return_bstr(res
, str
);
940 static HRESULT
Global_Space(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
946 TRACE("%s\n", debugstr_variant(arg
));
948 hres
= to_int(arg
, &n
);
953 FIXME("n = %d\n", n
);
960 str
= SysAllocStringLen(NULL
, n
);
962 return E_OUTOFMEMORY
;
972 static HRESULT
Global_String(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
978 static HRESULT
Global_InStr(vbdisp_t
*This
, VARIANT
*args
, unsigned args_cnt
, VARIANT
*res
)
980 VARIANT
*startv
, *str1v
, *str2v
;
987 assert(2 <= args_cnt
&& args_cnt
<= 4);
1001 FIXME("unsupported compare argument %s\n", debugstr_variant(args
));
1008 hres
= to_int(startv
, &start
);
1012 FIXME("start %d\n", start
);
1019 if(V_VT(str1v
) == VT_NULL
|| V_VT(str2v
) == VT_NULL
)
1020 return return_null(res
);
1022 if(V_VT(str1v
) != VT_BSTR
) {
1023 FIXME("Unsupported str1 type %s\n", debugstr_variant(str1v
));
1026 str1
= V_BSTR(str1v
);
1028 if(V_VT(str2v
) != VT_BSTR
) {
1029 FIXME("Unsupported str2 type %s\n", debugstr_variant(str2v
));
1032 str2
= V_BSTR(str2v
);
1034 if(start
< SysStringLen(str1
)) {
1037 ptr
= strstrW(str1
+start
, str2
);
1038 ret
= ptr
? ptr
-str1
+1 : 0;
1043 return return_int(res
, ret
);
1046 static HRESULT
Global_InStrB(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1052 static HRESULT
Global_AscB(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1058 static HRESULT
Global_ChrB(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1064 static HRESULT
Global_Asc(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1070 static HRESULT
Global_Chr(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1075 TRACE("%s\n", debugstr_variant(arg
));
1077 hres
= to_int(arg
, &c
);
1081 if(c
<= 0 || c
>= 0x100) {
1082 FIXME("invalid arg\n");
1089 V_VT(res
) = VT_BSTR
;
1090 V_BSTR(res
) = SysAllocStringLen(&ch
, 1);
1092 return E_OUTOFMEMORY
;
1097 static HRESULT
Global_AscW(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1103 static HRESULT
Global_ChrW(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1109 static HRESULT
Global_Abs(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1115 static HRESULT
Global_Fix(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1121 static HRESULT
Global_Int(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1127 static HRESULT
Global_Sgn(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1133 static HRESULT
Global_Now(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1141 SystemTimeToVariantTime(<
, &date
);
1142 return return_date(res
, date
);
1145 static HRESULT
Global_Date(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1151 static HRESULT
Global_Time(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1157 static HRESULT
Global_Day(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1163 static HRESULT
Global_Month(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1169 static HRESULT
Global_Weekday(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1175 static HRESULT
Global_Year(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1181 static HRESULT
Global_Hour(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1187 static HRESULT
Global_Minute(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1193 static HRESULT
Global_Second(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1199 static HRESULT
Global_DateValue(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1205 static HRESULT
Global_TimeValue(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1211 static HRESULT
Global_DateSerial(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1217 static HRESULT
Global_TimeSerial(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1223 static HRESULT
Global_InputBox(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1229 static HRESULT
Global_MsgBox(vbdisp_t
*This
, VARIANT
*args
, unsigned args_cnt
, VARIANT
*res
)
1237 FIXME("unsupported arg_cnt %d\n", args_cnt
);
1241 hres
= to_string(args
, &prompt
);
1245 hres
= show_msgbox(This
->desc
->ctx
, prompt
, res
);
1246 SysFreeString(prompt
);
1250 static HRESULT
Global_CreateObject(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1255 TRACE("(%s)\n", debugstr_variant(arg
));
1257 if(V_VT(arg
) != VT_BSTR
) {
1258 FIXME("non-bstr arg\n");
1259 return E_INVALIDARG
;
1262 obj
= create_object(This
->desc
->ctx
, V_BSTR(arg
));
1264 return VB_E_CANNOT_CREATE_OBJ
;
1267 hres
= IUnknown_QueryInterface(obj
, &IID_IDispatch
, (void**)&V_DISPATCH(res
));
1271 V_VT(res
) = VT_DISPATCH
;
1274 IUnknown_Release(obj
);
1278 static HRESULT
Global_GetObject(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1284 static HRESULT
Global_DateAdd(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1290 static HRESULT
Global_DateDiff(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1296 static HRESULT
Global_DatePart(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1302 static HRESULT
Global_TypeName(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1308 static HRESULT
Global_Array(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1314 static HRESULT
Global_Erase(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1320 static HRESULT
Global_Filter(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1326 static HRESULT
Global_Join(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1332 static HRESULT
Global_Split(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1338 static HRESULT
Global_Replace(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1344 static HRESULT
Global_StrReverse(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1346 WCHAR
*ptr1
, *ptr2
, ch
;
1350 TRACE("%s\n", debugstr_variant(arg
));
1352 hres
= to_string(arg
, &ret
);
1357 ptr2
= ret
+ SysStringLen(ret
)-1;
1358 while(ptr1
< ptr2
) {
1364 return return_bstr(res
, ret
);
1367 static HRESULT
Global_InStrRev(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1373 static HRESULT
Global_LoadPicture(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1379 static HRESULT
Global_ScriptEngine(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1385 static HRESULT
Global_ScriptEngineMajorVersion(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1391 static HRESULT
Global_ScriptEngineMinorVersion(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1397 static HRESULT
Global_ScriptEngineBuildVersion(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1403 static HRESULT
Global_FormatNumber(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1409 static HRESULT
Global_FormatCurrency(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1415 static HRESULT
Global_FormatPercent(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1421 static HRESULT
Global_FormatDateTime(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1427 static HRESULT
Global_WeekdayName(vbdisp_t
*This
, VARIANT
*args
, unsigned args_cnt
, VARIANT
*res
)
1429 int weekday
, first_day
= 1, abbrev
= 0;
1435 assert(1 <= args_cnt
&& args_cnt
<= 3);
1437 hres
= to_int(args
, &weekday
);
1442 hres
= to_int(args
+1, &abbrev
);
1447 hres
= to_int(args
+2, &first_day
);
1453 hres
= VarWeekdayName(weekday
, abbrev
, first_day
, 0, &ret
);
1457 return return_bstr(res
, ret
);
1460 static HRESULT
Global_MonthName(vbdisp_t
*This
, VARIANT
*args
, unsigned args_cnt
, VARIANT
*res
)
1462 int month
, abbrev
= 0;
1468 assert(args_cnt
== 1 || args_cnt
== 2);
1470 hres
= to_int(args
, &month
);
1475 hres
= to_int(args
+1, &abbrev
);
1480 hres
= VarMonthName(month
, abbrev
, 0, &ret
);
1484 return return_bstr(res
, ret
);
1487 static HRESULT
Global_Round(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1492 TRACE("%s\n", debugstr_variant(arg
));
1507 hres
= to_double(arg
, &n
);
1512 return return_double(res
, round(n
));
1515 static HRESULT
Global_Escape(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1521 static HRESULT
Global_Unescape(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1527 static HRESULT
Global_Eval(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1533 static HRESULT
Global_Execute(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1539 static HRESULT
Global_ExecuteGlobal(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1545 static HRESULT
Global_GetRef(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1551 static HRESULT
Global_vbUseSystem(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1557 static HRESULT
Global_vbUseSystemDayOfWeek(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1563 static HRESULT
Global_vbFirstJan1(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1569 static HRESULT
Global_vbFirstFourDays(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1575 static HRESULT
Global_vbFirstFullWeek(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1581 static HRESULT
Global_vbCritical(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1587 static HRESULT
Global_vbQuestion(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1593 static HRESULT
Global_vbExclamation(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1599 static HRESULT
Global_vbInformation(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1605 static HRESULT
Global_vbDefaultButton1(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1611 static HRESULT
Global_vbDefaultButton2(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1617 static HRESULT
Global_vbDefaultButton3(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1623 static HRESULT
Global_vbDefaultButton4(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1629 static HRESULT
Global_vbApplicationModal(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1635 static HRESULT
Global_vbSystemModal(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1641 static HRESULT
Global_vbOK(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1644 return return_short(res
, IDOK
);
1647 static HRESULT
Global_vbCancel(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1650 return return_short(res
, IDCANCEL
);
1653 static HRESULT
Global_vbAbort(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1656 return return_short(res
, IDABORT
);
1659 static HRESULT
Global_vbRetry(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1662 return return_short(res
, IDRETRY
);
1665 static HRESULT
Global_vbIgnore(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1668 return return_short(res
, IDIGNORE
);
1671 static HRESULT
Global_vbYes(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1674 return return_short(res
, IDYES
);
1677 static HRESULT
Global_vbNo(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1680 return return_short(res
, IDNO
);
1683 static HRESULT
Global_vbTrue(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1689 static HRESULT
Global_vbFalse(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1695 static HRESULT
Global_vbUseDefault(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1701 static HRESULT
Global_vbBinaryCompare(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1707 static HRESULT
Global_vbTextCompare(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1713 static HRESULT
Global_vbDatabaseCompare(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1719 static HRESULT
Global_vbGeneralDate(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1725 static HRESULT
Global_vbLongDate(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1731 static HRESULT
Global_vbShortDate(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1737 static HRESULT
Global_vbLongTime(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1743 static HRESULT
Global_vbShortTime(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1749 static HRESULT
Global_vbObjectError(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1755 static HRESULT
Global_vbBlack(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1761 static HRESULT
Global_vbBlue(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1767 static HRESULT
Global_vbCyan(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1773 static HRESULT
Global_vbGreen(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1779 static HRESULT
Global_vbMagenta(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1785 static HRESULT
Global_vbRed(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1791 static HRESULT
Global_vbWhite(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1797 static HRESULT
Global_vbYellow(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1803 static HRESULT
Global_vbCr(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1809 static HRESULT
Global_vbCrLf(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1815 static HRESULT
Global_vbNewLine(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1821 static HRESULT
Global_vbFormFeed(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1827 static HRESULT
Global_vbLf(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1833 static HRESULT
Global_vbNullChar(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1839 static HRESULT
Global_vbNullString(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1845 static HRESULT
Global_vbTab(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1851 static HRESULT
Global_vbVerticalTab(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1857 static HRESULT
Global_vbMsgBoxHelpButton(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1863 static HRESULT
Global_vbMsgBoxSetForeground(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1869 static HRESULT
Global_vbMsgBoxRight(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1875 static HRESULT
Global_vbMsgBoxRtlReading(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1881 static const builtin_prop_t global_props
[] = {
1882 {DISPID_GLOBAL_VBUSESYSTEM
, Global_vbUseSystem
, BP_GET
},
1883 {DISPID_GLOBAL_USESYSTEMDAYOFWEEK
, Global_vbUseSystemDayOfWeek
, BP_GET
},
1884 {DISPID_GLOBAL_VBSUNDAY
, NULL
, BP_GET
, 1},
1885 {DISPID_GLOBAL_VBMONDAY
, NULL
, BP_GET
, 2},
1886 {DISPID_GLOBAL_VBTUESDAY
, NULL
, BP_GET
, 3},
1887 {DISPID_GLOBAL_VBWEDNESDAY
, NULL
, BP_GET
, 4},
1888 {DISPID_GLOBAL_VBTHURSDAY
, NULL
, BP_GET
, 5},
1889 {DISPID_GLOBAL_VBFRIDAY
, NULL
, BP_GET
, 6},
1890 {DISPID_GLOBAL_VBSATURDAY
, NULL
, BP_GET
, 7},
1891 {DISPID_GLOBAL_VBFIRSTJAN1
, Global_vbFirstJan1
, BP_GET
},
1892 {DISPID_GLOBAL_VBFIRSTFOURDAYS
, Global_vbFirstFourDays
, BP_GET
},
1893 {DISPID_GLOBAL_VBFIRSTFULLWEEK
, Global_vbFirstFullWeek
, BP_GET
},
1894 {DISPID_GLOBAL_VBOKONLY
, NULL
, BP_GET
, MB_OK
},
1895 {DISPID_GLOBAL_VBOKCANCEL
, NULL
, BP_GET
, MB_OKCANCEL
},
1896 {DISPID_GLOBAL_VBABORTRETRYIGNORE
, NULL
, BP_GET
, MB_ABORTRETRYIGNORE
},
1897 {DISPID_GLOBAL_VBYESNOCANCEL
, NULL
, BP_GET
, MB_YESNOCANCEL
},
1898 {DISPID_GLOBAL_VBYESNO
, NULL
, BP_GET
, MB_YESNO
},
1899 {DISPID_GLOBAL_VBRETRYCANCEL
, NULL
, BP_GET
, MB_RETRYCANCEL
},
1900 {DISPID_GLOBAL_VBCRITICAL
, Global_vbCritical
, BP_GET
},
1901 {DISPID_GLOBAL_VBQUESTION
, Global_vbQuestion
, BP_GET
},
1902 {DISPID_GLOBAL_VBEXCLAMATION
, Global_vbExclamation
, BP_GET
},
1903 {DISPID_GLOBAL_VBINFORMATION
, Global_vbInformation
, BP_GET
},
1904 {DISPID_GLOBAL_VBDEFAULTBUTTON1
, Global_vbDefaultButton1
, BP_GET
},
1905 {DISPID_GLOBAL_VBDEFAULTBUTTON2
, Global_vbDefaultButton2
, BP_GET
},
1906 {DISPID_GLOBAL_VBDEFAULTBUTTON3
, Global_vbDefaultButton3
, BP_GET
},
1907 {DISPID_GLOBAL_VBDEFAULTBUTTON4
, Global_vbDefaultButton4
, BP_GET
},
1908 {DISPID_GLOBAL_VBAPPLICATIONMODAL
, Global_vbApplicationModal
, BP_GET
},
1909 {DISPID_GLOBAL_VBSYSTEMMODAL
, Global_vbSystemModal
, BP_GET
},
1910 {DISPID_GLOBAL_VBOK
, Global_vbOK
, BP_GET
},
1911 {DISPID_GLOBAL_VBCANCEL
, Global_vbCancel
, BP_GET
},
1912 {DISPID_GLOBAL_VBABORT
, Global_vbAbort
, BP_GET
},
1913 {DISPID_GLOBAL_VBRETRY
, Global_vbRetry
, BP_GET
},
1914 {DISPID_GLOBAL_VBIGNORE
, Global_vbIgnore
, BP_GET
},
1915 {DISPID_GLOBAL_VBYES
, Global_vbYes
, BP_GET
},
1916 {DISPID_GLOBAL_VBNO
, Global_vbNo
, BP_GET
},
1917 {DISPID_GLOBAL_VBEMPTY
, NULL
, BP_GET
, VT_EMPTY
},
1918 {DISPID_GLOBAL_VBNULL
, NULL
, BP_GET
, VT_NULL
},
1919 {DISPID_GLOBAL_VBINTEGER
, NULL
, BP_GET
, VT_I2
},
1920 {DISPID_GLOBAL_VBLONG
, NULL
, BP_GET
, VT_I4
},
1921 {DISPID_GLOBAL_VBSINGLE
, NULL
, BP_GET
, VT_R4
},
1922 {DISPID_GLOBAL_VBDOUBLE
, NULL
, BP_GET
, VT_R8
},
1923 {DISPID_GLOBAL_VBCURRENCY
, NULL
, BP_GET
, VT_CY
},
1924 {DISPID_GLOBAL_VBDATE
, NULL
, BP_GET
, VT_DATE
},
1925 {DISPID_GLOBAL_VBSTRING
, NULL
, BP_GET
, VT_BSTR
},
1926 {DISPID_GLOBAL_VBOBJECT
, NULL
, BP_GET
, VT_DISPATCH
},
1927 {DISPID_GLOBAL_VBERROR
, NULL
, BP_GET
, VT_ERROR
},
1928 {DISPID_GLOBAL_VBBOOLEAN
, NULL
, BP_GET
, VT_BOOL
},
1929 {DISPID_GLOBAL_VBVARIANT
, NULL
, BP_GET
, VT_VARIANT
},
1930 {DISPID_GLOBAL_VBDATAOBJECT
, NULL
, BP_GET
, VT_UNKNOWN
},
1931 {DISPID_GLOBAL_VBDECIMAL
, NULL
, BP_GET
, VT_DECIMAL
},
1932 {DISPID_GLOBAL_VBBYTE
, NULL
, BP_GET
, VT_UI1
},
1933 {DISPID_GLOBAL_VBARRAY
, NULL
, BP_GET
, VT_ARRAY
},
1934 {DISPID_GLOBAL_VBTRUE
, Global_vbTrue
, BP_GET
},
1935 {DISPID_GLOBAL_VBFALSE
, Global_vbFalse
, BP_GET
},
1936 {DISPID_GLOBAL_VBUSEDEFAULT
, Global_vbUseDefault
, BP_GET
},
1937 {DISPID_GLOBAL_VBBINARYCOMPARE
, Global_vbBinaryCompare
, BP_GET
},
1938 {DISPID_GLOBAL_VBTEXTCOMPARE
, Global_vbTextCompare
, BP_GET
},
1939 {DISPID_GLOBAL_VBDATABASECOMPARE
, Global_vbDatabaseCompare
, BP_GET
},
1940 {DISPID_GLOBAL_VBGENERALDATE
, Global_vbGeneralDate
, BP_GET
},
1941 {DISPID_GLOBAL_VBLONGDATE
, Global_vbLongDate
, BP_GET
},
1942 {DISPID_GLOBAL_VBSHORTDATE
, Global_vbShortDate
, BP_GET
},
1943 {DISPID_GLOBAL_VBLONGTIME
, Global_vbLongTime
, BP_GET
},
1944 {DISPID_GLOBAL_VBSHORTTIME
, Global_vbShortTime
, BP_GET
},
1945 {DISPID_GLOBAL_VBOBJECTERROR
, Global_vbObjectError
, BP_GET
},
1946 {DISPID_GLOBAL_VBBLACK
, Global_vbBlack
, BP_GET
},
1947 {DISPID_GLOBAL_VBBLUE
, Global_vbBlue
, BP_GET
},
1948 {DISPID_GLOBAL_VBCYAN
, Global_vbCyan
, BP_GET
},
1949 {DISPID_GLOBAL_VBGREEN
, Global_vbGreen
, BP_GET
},
1950 {DISPID_GLOBAL_VBMAGENTA
, Global_vbMagenta
, BP_GET
},
1951 {DISPID_GLOBAL_VBRED
, Global_vbRed
, BP_GET
},
1952 {DISPID_GLOBAL_VBWHITE
, Global_vbWhite
, BP_GET
},
1953 {DISPID_GLOBAL_VBYELLOW
, Global_vbYellow
, BP_GET
},
1954 {DISPID_GLOBAL_VBCR
, Global_vbCr
, BP_GET
},
1955 {DISPID_GLOBAL_VBCRLF
, Global_vbCrLf
, BP_GET
},
1956 {DISPID_GLOBAL_VBNEWLINE
, Global_vbNewLine
, BP_GET
},
1957 {DISPID_GLOBAL_VBFORMFEED
, Global_vbFormFeed
, BP_GET
},
1958 {DISPID_GLOBAL_VBLF
, Global_vbLf
, BP_GET
},
1959 {DISPID_GLOBAL_VBNULLCHAR
, Global_vbNullChar
, BP_GET
},
1960 {DISPID_GLOBAL_VBNULLSTRING
, Global_vbNullString
, BP_GET
},
1961 {DISPID_GLOBAL_VBTAB
, Global_vbTab
, BP_GET
},
1962 {DISPID_GLOBAL_VBVERTICALTAB
, Global_vbVerticalTab
, BP_GET
},
1963 {DISPID_GLOBAL_CCUR
, Global_CCur
, 0, 1},
1964 {DISPID_GLOBAL_CINT
, Global_CInt
, 0, 1},
1965 {DISPID_GLOBAL_CLNG
, Global_CLng
, 0, 1},
1966 {DISPID_GLOBAL_CBOOL
, Global_CBool
, 0, 1},
1967 {DISPID_GLOBAL_CBYTE
, Global_CByte
, 0, 1},
1968 {DISPID_GLOBAL_CDATE
, Global_CDate
, 0, 1},
1969 {DISPID_GLOBAL_CDBL
, Global_CDbl
, 0, 1},
1970 {DISPID_GLOBAL_CSNG
, Global_CSng
, 0, 1},
1971 {DISPID_GLOBAL_CSTR
, Global_CStr
, 0, 1},
1972 {DISPID_GLOBAL_HEX
, Global_Hex
, 0, 1},
1973 {DISPID_GLOBAL_OCT
, Global_Oct
, 0, 1},
1974 {DISPID_GLOBAL_VARTYPE
, Global_VarType
, 0, 1},
1975 {DISPID_GLOBAL_ISDATE
, Global_IsDate
, 0, 1},
1976 {DISPID_GLOBAL_ISEMPTY
, Global_IsEmpty
, 0, 1},
1977 {DISPID_GLOBAL_ISNULL
, Global_IsNull
, 0, 1},
1978 {DISPID_GLOBAL_ISNUMERIC
, Global_IsNumeric
, 0, 1},
1979 {DISPID_GLOBAL_ISARRAY
, Global_IsArray
, 0, 1},
1980 {DISPID_GLOBAL_ISOBJECT
, Global_IsObject
, 0, 1},
1981 {DISPID_GLOBAL_ATN
, Global_Ant
, 0, 1},
1982 {DISPID_GLOBAL_COS
, Global_Cos
, 0, 1},
1983 {DISPID_GLOBAL_SIN
, Global_Sin
, 0, 1},
1984 {DISPID_GLOBAL_TAN
, Global_Tan
, 0, 1},
1985 {DISPID_GLOBAL_EXP
, Global_Exp
, 0, 1},
1986 {DISPID_GLOBAL_LOG
, Global_Log
, 0, 1},
1987 {DISPID_GLOBAL_SQR
, Global_Sqr
, 0, 1},
1988 {DISPID_GLOBAL_RANDOMIZE
, Global_Randomize
, 0, 1},
1989 {DISPID_GLOBAL_RND
, Global_Rnd
, 0, 1},
1990 {DISPID_GLOBAL_TIMER
, Global_Timer
, 0, 0},
1991 {DISPID_GLOBAL_LBOUND
, Global_LBound
, 0, 1},
1992 {DISPID_GLOBAL_UBOUND
, Global_UBound
, 0, 1},
1993 {DISPID_GLOBAL_RGB
, Global_RGB
, 0, 3},
1994 {DISPID_GLOBAL_LEN
, Global_Len
, 0, 1},
1995 {DISPID_GLOBAL_LENB
, Global_LenB
, 0, 1},
1996 {DISPID_GLOBAL_LEFT
, Global_Left
, 0, 2},
1997 {DISPID_GLOBAL_LEFTB
, Global_LeftB
, 0, 2},
1998 {DISPID_GLOBAL_RIGHT
, Global_Right
, 0, 2},
1999 {DISPID_GLOBAL_RIGHTB
, Global_RightB
, 0, 2},
2000 {DISPID_GLOBAL_MID
, Global_Mid
, 0, 2, 3},
2001 {DISPID_GLOBAL_MIDB
, Global_MidB
, 0, 2, 3},
2002 {DISPID_GLOBAL_STRCOMP
, Global_StrComp
, 0, 2, 3},
2003 {DISPID_GLOBAL_LCASE
, Global_LCase
, 0, 1},
2004 {DISPID_GLOBAL_UCASE
, Global_UCase
, 0, 1},
2005 {DISPID_GLOBAL_LTRIM
, Global_LTrim
, 0, 1},
2006 {DISPID_GLOBAL_RTRIM
, Global_RTrim
, 0, 1},
2007 {DISPID_GLOBAL_TRIM
, Global_Trim
, 0, 1},
2008 {DISPID_GLOBAL_SPACE
, Global_Space
, 0, 1},
2009 {DISPID_GLOBAL_STRING
, Global_String
, 0, 0, 2},
2010 {DISPID_GLOBAL_INSTR
, Global_InStr
, 0, 2, 4},
2011 {DISPID_GLOBAL_INSTRB
, Global_InStrB
, 0, 3, 4},
2012 {DISPID_GLOBAL_ASCB
, Global_AscB
, 0, 1},
2013 {DISPID_GLOBAL_CHRB
, Global_ChrB
, 0, 1},
2014 {DISPID_GLOBAL_ASC
, Global_Asc
, 0, 1},
2015 {DISPID_GLOBAL_CHR
, Global_Chr
, 0, 1},
2016 {DISPID_GLOBAL_ASCW
, Global_AscW
, 0, 1},
2017 {DISPID_GLOBAL_CHRW
, Global_ChrW
, 0, 1},
2018 {DISPID_GLOBAL_ABS
, Global_Abs
, 0, 1},
2019 {DISPID_GLOBAL_FIX
, Global_Fix
, 0, 1},
2020 {DISPID_GLOBAL_INT
, Global_Int
, 0, 1},
2021 {DISPID_GLOBAL_SGN
, Global_Sgn
, 0, 1},
2022 {DISPID_GLOBAL_NOW
, Global_Now
, 0, 0},
2023 {DISPID_GLOBAL_DATE
, Global_Date
, 0, 0},
2024 {DISPID_GLOBAL_TIME
, Global_Time
, 0, 0},
2025 {DISPID_GLOBAL_DAY
, Global_Day
, 0, 1},
2026 {DISPID_GLOBAL_MONTH
, Global_Month
, 0, 1},
2027 {DISPID_GLOBAL_WEEKDAY
, Global_Weekday
, 0, 1, 2},
2028 {DISPID_GLOBAL_YEAR
, Global_Year
, 0, 1},
2029 {DISPID_GLOBAL_HOUR
, Global_Hour
, 0, 1},
2030 {DISPID_GLOBAL_MINUTE
, Global_Minute
, 0, 1},
2031 {DISPID_GLOBAL_SECOND
, Global_Second
, 0, 1},
2032 {DISPID_GLOBAL_DATEVALUE
, Global_DateValue
, 0, 1},
2033 {DISPID_GLOBAL_TIMEVALUE
, Global_TimeValue
, 0, 1},
2034 {DISPID_GLOBAL_DATESERIAL
, Global_DateSerial
, 0, 3},
2035 {DISPID_GLOBAL_TIMESERIAL
, Global_TimeSerial
, 0, 3},
2036 {DISPID_GLOBAL_INPUTBOX
, Global_InputBox
, 0, 1, 7},
2037 {DISPID_GLOBAL_MSGBOX
, Global_MsgBox
, 0, 1, 5},
2038 {DISPID_GLOBAL_CREATEOBJECT
, Global_CreateObject
, 0, 1},
2039 {DISPID_GLOBAL_GETOBJECT
, Global_GetObject
, 0, 0, 2},
2040 {DISPID_GLOBAL_DATEADD
, Global_DateAdd
, 0, 3},
2041 {DISPID_GLOBAL_DATEDIFF
, Global_DateDiff
, 0, 3, 5},
2042 {DISPID_GLOBAL_DATEPART
, Global_DatePart
, 0, 2, 4},
2043 {DISPID_GLOBAL_TYPENAME
, Global_TypeName
, 0, 1},
2044 {DISPID_GLOBAL_ARRAY
, Global_Array
, 0, 1},
2045 {DISPID_GLOBAL_ERASE
, Global_Erase
, 0, 1},
2046 {DISPID_GLOBAL_FILTER
, Global_Filter
, 0, 2, 4},
2047 {DISPID_GLOBAL_JOIN
, Global_Join
, 0, 1, 2},
2048 {DISPID_GLOBAL_SPLIT
, Global_Split
, 0, 1, 4},
2049 {DISPID_GLOBAL_REPLACE
, Global_Replace
, 0, 3, 6},
2050 {DISPID_GLOBAL_STRREVERSE
, Global_StrReverse
, 0, 1},
2051 {DISPID_GLOBAL_INSTRREV
, Global_InStrRev
, 0, 2, 4},
2052 {DISPID_GLOBAL_LOADPICTURE
, Global_LoadPicture
, 0, 1},
2053 {DISPID_GLOBAL_SCRIPTENGINE
, Global_ScriptEngine
, 0, 0},
2054 {DISPID_GLOBAL_SCRIPTENGINEMAJORVERSION
, Global_ScriptEngineMajorVersion
, 0, 0},
2055 {DISPID_GLOBAL_SCRIPTENGINEMINORVERSION
, Global_ScriptEngineMinorVersion
, 0, 0},
2056 {DISPID_GLOBAL_SCRIPTENGINEBUILDVERSION
, Global_ScriptEngineBuildVersion
, 0, 0},
2057 {DISPID_GLOBAL_FORMATNUMBER
, Global_FormatNumber
, 0, 1, 5},
2058 {DISPID_GLOBAL_FORMATCURRENCY
, Global_FormatCurrency
, 0, 1, 5},
2059 {DISPID_GLOBAL_FORMATPERCENT
, Global_FormatPercent
, 0, 1, 5},
2060 {DISPID_GLOBAL_FORMATDATETIME
, Global_FormatDateTime
, 0, 1, 2},
2061 {DISPID_GLOBAL_WEEKDAYNAME
, Global_WeekdayName
, 0, 1, 3},
2062 {DISPID_GLOBAL_MONTHNAME
, Global_MonthName
, 0, 1, 2},
2063 {DISPID_GLOBAL_ROUND
, Global_Round
, 0, 1, 2},
2064 {DISPID_GLOBAL_ESCAPE
, Global_Escape
, 0, 1},
2065 {DISPID_GLOBAL_UNESCAPE
, Global_Unescape
, 0, 1},
2066 {DISPID_GLOBAL_EVAL
, Global_Eval
, 0, 1},
2067 {DISPID_GLOBAL_EXECUTE
, Global_Execute
, 0, 1},
2068 {DISPID_GLOBAL_EXECUTEGLOBAL
, Global_ExecuteGlobal
, 0, 1},
2069 {DISPID_GLOBAL_GETREF
, Global_GetRef
, 0, 1},
2070 {DISPID_GLOBAL_VBMSGBOXHELPBUTTON
, Global_vbMsgBoxHelpButton
, BP_GET
},
2071 {DISPID_GLOBAL_VBMSGBOXSETFOREGROUND
, Global_vbMsgBoxSetForeground
, BP_GET
},
2072 {DISPID_GLOBAL_VBMSGBOXRIGHT
, Global_vbMsgBoxRight
, BP_GET
},
2073 {DISPID_GLOBAL_VBMSGBOXRTLREADING
, Global_vbMsgBoxRtlReading
, BP_GET
}
2076 HRESULT
init_global(script_ctx_t
*ctx
)
2080 ctx
->global_desc
.ctx
= ctx
;
2081 ctx
->global_desc
.builtin_prop_cnt
= sizeof(global_props
)/sizeof(*global_props
);
2082 ctx
->global_desc
.builtin_props
= global_props
;
2084 hres
= get_typeinfo(GlobalObj_tid
, &ctx
->global_desc
.typeinfo
);
2088 hres
= create_vbdisp(&ctx
->global_desc
, &ctx
->global_obj
);
2092 hres
= create_script_disp(ctx
, &ctx
->script_obj
);
2096 return init_err(ctx
);