3 ' vbslib ver3.00 Sep.22, 2009
\r
4 ' Copyright (c) 2008-2009, T's-Neko at Sage Plaisir 21 (Japan)
\r
5 ' All rights reserved. Based on 3-clause BSD license.
\r
8 Dim g_vbslib_main_Path
\r
9 g_vbslib_main_Path = g_SrcPath
\r
13 '********************************************************************************
\r
14 ' <<< Global variables >>>
\r
15 '********************************************************************************
\r
17 Dim g_WritablePathes
\r
18 Dim g_Err2, g_EchoObj
\r
23 Dim g_CurrentWritables
\r
24 Dim g_FileSystemRetryMSec
\r
25 Dim g_Player '// as Vbslib_Player
\r
27 Function InitializeModule
\r
28 ReDim g_WritablePathes(-1)
\r
29 Set g_CurrentWritables = new CurrentWritables : ErrCheck
\r
30 Set g_EchoObj = new EchoObj : ErrCheck
\r
31 Set g_Err2 = new Err2 : ErrCheck
\r
32 Set g_CUI = new CUI : ErrCheck
\r
33 g_FileSystemRetryMSec = 10*1000
\r
35 Dim g_InitializeModule
\r
36 Set g_InitializeModule = GetRef( "InitializeModule" )
\r
38 Function FinalizeModule( ThisPath, Reason )
\r
40 g_Err2.OnSuccessFinish
\r
42 g_Err2.OnErrorFinish
\r
46 Dim g_FinalizeModule: Set g_FinalizeModule = GetRef( "FinalizeModule" )
\r
47 Dim g_FinalizeLevel: g_FinalizeLevel = 100 ' If smaller, called early
\r
52 Const F_SubFolder = 4
\r
54 Const g_PauseMsg = "
\91±
\8ds
\82·
\82é
\82É
\82Í Enter
\83L
\81[
\82ð
\89\9f\82µ
\82Ä
\82
\82¾
\82³
\82¢ . . . "
\r
55 Const g_PauseMsgStone = 24
\r
59 '********************************************************************************
\r
60 ' <<< Error Code >>>
\r
61 '********************************************************************************
\r
63 Dim E_Others : E_Others = 1
\r
65 Dim E_AssertFail : E_AssertFail = &h80041001
\r
66 Dim E_TestFail : E_TestFail = &h80041003
\r
67 Dim E_BuildFail : E_BuildFail = &h80041004
\r
68 Dim E_OutOfWritable : E_OutOfWritable = &h80041005
\r
69 Dim E_NotFoundSymbol : E_NotFoundSymbol = &h80041006
\r
70 Dim E_ProgRetNotZero : E_ProgRetNotZero = &h80041007
\r
71 Dim E_Unexpected : E_Unexpected = &h80041008
\r
73 Dim E_WIN32_FILE_NOT_FOUND: E_WIN32_FILE_NOT_FOUND = &h80070002
\r
74 Dim E_WIN32_DIRECTORY : E_WIN32_DIRECTORY = &h8007010B
\r
76 Dim E_ProgTerminated : E_ProgTerminated = &hC0000005
\r
78 Dim E_FileNotExist : E_FileNotExist = 53
\r
79 Dim E_EndOfFile : E_EndOfFile = 62
\r
80 Dim E_WriteAccessDenied : E_WriteAccessDenied = 70
\r
81 Dim E_PathNotFound : E_PathNotFound = 76
\r
82 Dim E_AlreadyExist : E_AlreadyExist = 58
\r
86 '********************************************************************************
\r
87 ' <<< File Object >>>
\r
88 '********************************************************************************
\r
94 '*-------------------------------------------------------------------------*
\r
95 '* ### <<<< Debugging >>>>
\r
96 '*-------------------------------------------------------------------------*
\r
100 '********************************************************************************
\r
101 ' <<< [g_count_up] >>>
\r
102 '********************************************************************************
\r
105 Function g_count_up( i )
\r
106 If i > UBound( g_count ) Then Redim Preserve g_count(i)
\r
107 g_count_up = g_count(i) + 1
\r
108 g_count(i) = g_count_up
\r
113 '********************************************************************************
\r
114 ' <<< [SetTestMode] >>>
\r
115 '********************************************************************************
\r
116 Dim F_NotRandom : F_NotRandom = 1
\r
117 Dim g_TestModeFlags
\r
119 Sub SetTestMode( Flags )
\r
120 g_TestModeFlags = Flags
\r
125 '*-------------------------------------------------------------------------*
\r
126 '* ### <<<< User Interface >>>>
\r
127 '*-------------------------------------------------------------------------*
\r
131 '********************************************************************************
\r
132 ' <<< [EchoObj] Class >>>
\r
133 '********************************************************************************
\r
136 Public m_bDisableEchoOff
\r
143 '********************************************************************************
\r
145 '********************************************************************************
\r
146 Function echo( ByVal msg )
\r
147 If g_EchoObj.m_bEchoOff Then Exit Function
\r
149 If not IsEmpty( msg ) Then
\r
150 msg = GetEchoString( msg )
\r
152 If g_CommandPrompt = 0 Then
\r
153 If IsEmpty( g_EchoObj.m_Buf ) Then
\r
154 g_EchoObj.m_Buf = msg
\r
156 g_EchoObj.m_Buf = g_EchoObj.m_Buf & vbCRLF & msg
\r
158 g_EchoObj.m_BufN = g_EchoObj.m_BufN + 1
\r
159 If g_EchoObj.m_BufN >= 20 Then echo_flush
\r
164 If not IsEmpty( g_Test ) Then g_Test.WriteLogLine msg
\r
171 '********************************************************************************
\r
172 ' <<< [GetEchoString] >>>
\r
173 '********************************************************************************
\r
174 Function GetEchoString( ByVal msg )
\r
175 If IsObject( msg ) Then msg = msg.Value
\r
177 If IsNull( msg ) Then
\r
179 ElseIf VarType( msg ) = vbBoolean Then
\r
180 If msg Then msg = "True" _
\r
182 ElseIf IsArray( msg ) Then
\r
183 Dim a : Set a = new ArrayClass : ErrCheck
\r
185 msg = GetEchoString( a )
\r
188 GetEchoString = msg
\r
193 '********************************************************************************
\r
194 ' <<< [echo_flush] >>>
\r
195 '********************************************************************************
\r
197 If g_CommandPrompt = 0 and g_EchoObj.m_BufN > 0 Then
\r
198 If MsgBox( g_EchoObj.m_Buf, vbOKCancel, WScript.ScriptName ) = vbCancel Then
\r
201 g_EchoObj.m_Buf = Empty
\r
202 g_EchoObj.m_BufN = 0
\r
209 '********************************************************************************
\r
210 ' <<< [EchoOff] >>>
\r
211 '********************************************************************************
\r
215 Private Sub Class_Initialize
\r
216 m_Prev = g_EchoObj.m_bEchoOff
\r
217 g_EchoObj.m_bEchoOff = not g_EchoObj.m_bDisableEchoOff
\r
220 Private Sub Class_Terminate
\r
221 g_EchoObj.m_bEchoOff = m_Prev
\r
227 '********************************************************************************
\r
228 ' <<< [DisableEchoOff] >>>
\r
229 '********************************************************************************
\r
231 g_EchoObj.m_bDisableEchoOff = True
\r
236 '********************************************************************************
\r
237 ' <<< [echo_r] >>>
\r
238 ' return: output message
\r
239 '********************************************************************************
\r
240 Function echo_r( ByVal msg, redirect_path )
\r
242 Const ForAppending = 8
\r
244 If IsObject( msg ) Then msg = msg.Value
\r
246 If g_debug Then WScript.Echo msg
\r
248 If IsEmpty( redirect_path ) Then
\r
249 ElseIf redirect_path = "" Then
\r
250 If Not g_debug Then WScript.Echo msg
\r
252 Set f = g_fs.OpenTextFile( redirect_path, ForAppending, True, False )
\r
261 '********************************************************************************
\r
262 ' <<< old I/F [echo_c] >>>
\r
263 '********************************************************************************
\r
264 Function echo_c( ByVal msg )
\r
265 If g_cut_old Then Stop
\r
266 echo_c = echo( msg )
\r
271 '********************************************************************************
\r
273 '********************************************************************************
\r
277 Set f = g_fs.OpenTextFile( path )
\r
279 Do Until f.AtEndOfStream
\r
286 '********************************************************************************
\r
288 '********************************************************************************
\r
290 If g_CommandPrompt = 0 Then
\r
291 echo "
\91±
\8ds
\82·
\82é
\82É
\82Í Enter
\83L
\81[
\82ð
\89\9f\82µ
\82Ä
\82
\82¾
\82³
\82¢ . . ."
\r
294 g_CUI.input_sub g_PauseMsg, False
\r
300 '********************************************************************************
\r
301 ' <<< [pause2] >>>
\r
302 '********************************************************************************
\r
304 If WScript.Arguments.Named("wscript")=1 Then input g_PauseMsg
\r
309 '********************************************************************************
\r
311 '********************************************************************************
\r
312 Function input( ByVal msg )
\r
314 input = g_CUI.input( msg )
\r
320 '********************************************************************************
\r
321 ' <<< [set_input] >>>
\r
322 '********************************************************************************
\r
323 Sub set_input( Keys )
\r
325 g_CUI.m_Auto_Keys = Keys
\r
331 '********************************************************************************
\r
332 ' <<< [InputPath] >>>
\r
333 '********************************************************************************
\r
334 Const F_ChkFileExists = 1
\r
335 Const F_ChkFolderExists = 2
\r
336 Const F_AllowEnterOnly = 4
\r
338 Function InputPath( Prompt, Flags )
\r
342 path = input( Prompt )
\r
343 path = Trim( path )
\r
345 If path = "" and ( Flags and F_AllowEnterOnly ) Then Exit Do
\r
347 If Left( path, 1 ) = """" and Right( path, 1 ) = """" Then _
\r
348 path = Mid( path, 2, Len( path ) - 2 )
\r
350 If Flags = 0 Then Exit Do
\r
351 If Flags and F_ChkFileExists Then
\r
352 If g_fs.FileExists( path ) Then Exit Do
\r
354 If Flags and F_ChkFolderExists Then
\r
355 If g_fs.FolderExists( path ) Then Exit Do
\r
363 '********************************************************************************
\r
364 ' <<< [SendKeys] Send keyboard code stroke to OS >>>
\r
365 '********************************************************************************
\r
366 Sub SendKeys( ByVal window_title, ByVal keycords, ByVal late_time )
\r
367 WScript.Sleep late_time
\r
368 If window_title <> "" Then g_sh.AppActivate( window_title )
\r
370 g_sh.SendKeys keycords
\r
375 '*-------------------------------------------------------------------------*
\r
376 '* ### <<<< [CUI] Class >>>>
\r
377 '*-------------------------------------------------------------------------*
\r
381 Public m_Auto_InputFunc ' as string of auto input function name
\r
382 Public m_Auto_Src ' as string of path
\r
383 Public m_Auto_Keys ' as string of auto input keys
\r
384 Public m_Auto_KeyEnter ' as string of the character of replacing to enter key
\r
385 Public m_Auto_DebugCount ' as integer
\r
389 '********************************************************************************
\r
390 ' <<< [CUI::Class_Initialize] >>>
\r
391 '********************************************************************************
\r
392 Private Sub Class_Initialize
\r
393 Me.m_Auto_Keys = ""
\r
394 Me.m_Auto_KeyEnter = "."
\r
395 Me.m_Auto_DebugCount = Empty
\r
400 '********************************************************************************
\r
401 ' <<< [CUI::input] >>>
\r
402 '********************************************************************************
\r
403 Public Function input( ByVal msg )
\r
404 input = input_sub( msg, not IsEmpty( WScript.Arguments.Named.Item("GUI_input") ) )
\r
407 Public Function input_sub( ByVal msg, bGUI_input )
\r
411 If not IsEmpty( g_EchoObj.m_Buf ) Then msg = g_EchoObj.m_Buf + vbCRLF + msg
\r
412 g_EchoObj.m_Buf = Empty
\r
413 g_EchoObj.m_BufN = 0
\r
415 If msg = g_PauseMsg and Not IsEmpty( m_Auto_Keys ) And m_Auto_Keys <> "" Then
\r
416 '// Owner process does not wait in EchoStream
\r
417 Wscript.StdOut.Write Left( g_PauseMsg, g_PauseMsgStone )+"*"+Chr(8)+_
\r
418 Mid( g_PauseMsg, g_PauseMsgStone+1 )
\r
420 Wscript.StdOut.Write msg
\r
423 On Error Resume Next
\r
425 If Not IsEmpty( m_Auto_Keys ) And m_Auto_Keys <> "" Then
\r
426 If Not IsEmpty( m_Auto_KeyEnter ) Then
\r
427 e = InStr( m_Auto_Keys, m_Auto_KeyEnter )
\r
429 input_sub = m_Auto_Keys
\r
430 m_Auto_Keys = Empty
\r
432 input_sub = Left( m_Auto_Keys, e - 1 )
\r
433 m_Auto_Keys = Mid( m_Auto_Keys, e + 1 )
\r
436 input_sub = m_Auto_Keys
\r
437 m_Auto_Keys = Empty
\r
440 If IsEmpty( m_Auto_DebugCount ) Then
\r
441 Wscript.StdOut.WriteLine input_sub
\r
442 ElseIf m_Auto_DebugCount > 1 Then
\r
443 Wscript.StdOut.WriteLine input_sub
\r
444 m_Auto_DebugCount = m_Auto_DebugCount - 1
\r
446 Wscript.StdOut.Write input_sub
\r
448 input_sub = InputBox( msg, WScript.ScriptName, "" )
\r
449 Wscript.StdOut.WriteLine input_sub
\r
451 input_sub = Wscript.StdIn.ReadLine
\r
453 Wscript.StdOut.WriteLine ""
\r
456 ElseIf IsEmpty( m_Auto_InputFunc ) Then
\r
458 input_sub = InputBox( msg, WScript.ScriptName, "" )
\r
459 Wscript.StdOut.WriteLine input_sub
\r
461 input_sub = Wscript.StdIn.ReadLine
\r
464 If IsEmpty( m_Auto_Src ) Then
\r
465 Set InputFunc = GetRef( m_Auto_InputFunc )
\r
466 If Err.Number = 5 Then Wscript.StdOut.WriteLine vbCR+vbLF+"Not found function of """+_
\r
467 m_Auto_InputFunc +"""": Err.Clear
\r
468 If Not IsEmpty( InputFunc ) Then input_sub = InputFunc( msg )
\r
470 input_sub = call_vbs_t( m_Auto_Src, m_Auto_InputFunc, msg )
\r
471 If Err.Number = 5 Then Wscript.StdOut.WriteLine vbCR+vbLF+"Not found function of """+_
\r
472 m_Auto_InputFunc +""" in """+m_Auto_Src+"""" : Err.Clear
\r
473 If IsEmpty( input_sub ) Then Wscript.StdOut.Write msg : input_sub = Wscript.StdIn.ReadLine
\r
477 e = Err.Number : Err.Clear : On Error GoTo 0
\r
479 If e <> 62 Then Err.Raise e '62= End Of File (StdIn, ^C)
\r
487 '********************************************************************************
\r
488 ' <<< [CUI::SetAutoKeysFromMainArg] >>>
\r
489 '********************************************************************************
\r
490 Public Sub SetAutoKeysFromMainArg
\r
491 If not IsEmpty( Me.m_Auto_Keys ) and Me.m_Auto_Keys = "" Then
\r
492 Me.m_Auto_Keys = WScript.Arguments.Named.Item("set_input")
\r
493 Me.m_Auto_DebugCount = WScript.Arguments.Named.Item("set_input_debug")
\r
503 '*-------------------------------------------------------------------------*
\r
504 '* ### <<<< File >>>>
\r
505 '*-------------------------------------------------------------------------*
\r
509 '********************************************************************************
\r
510 ' <<< [AppKeyClass] >>>
\r
511 '********************************************************************************
\r
512 Const F_AskIfWarn = 0
\r
513 Const F_ErrIfWarn = 1
\r
514 Const F_IgnoreIfWarn = 2
\r
515 Const F_BreakIfWarn = 3
\r
520 Private m_WritableMode ' as Flags
\r
521 Private m_NewWritables()
\r
522 Public m_BreakByFName ' as string
\r
524 Private Sub Class_Initialize()
\r
525 m_WritableMode = F_AskIfWarn
\r
526 ReDim m_NewWritables(-1)
\r
529 Public Function SetKey( Key )
\r
530 If not IsEmpty( m_Key ) Then Err.Raise 1,,"Double Key"
\r
535 Public Sub SetKey_sub( Key )
\r
536 If not IsEmpty( m_Key ) Then Err.Raise 1,,"Double Key"
\r
537 m_bAppKey = ( Key Is g_AppKey )
\r
541 Public Function IsSame( Key )
\r
542 IsSame = ( m_Key Is Key ) and Key.IsSame_sub( Me )
\r
544 Public Function IsSame_sub( Key )
\r
545 IsSame_sub = ( m_Key Is Key )
\r
548 Public Sub CheckGlobalAppKey()
\r
549 If not m_bAppKey Then _
\r
550 MsgBox "[ERROR] This is not AppKey from main2"
\r
551 If not IsSame( g_AppKey ) Then _
\r
552 MsgBox "[ERROR] g_AppKey was overrided by unknown"
\r
554 Private Sub Class_Terminate()
\r
555 If m_bAppKey Then CheckGlobalAppKey
\r
559 '********************************************************************************
\r
560 ' <<< [AppKeyClass::NewWritable] >>>
\r
561 '********************************************************************************
\r
562 Public Function NewWritable( Pathes )
\r
563 Me.CheckGlobalAppKey
\r
564 Dim m : Set m = new Writables : ErrCheck
\r
565 m.SetPathes Me, Pathes
\r
566 Set NewWritable = m
\r
570 '********************************************************************************
\r
571 ' <<< [AppKeyClass::SetWritableMode] >>>
\r
572 '********************************************************************************
\r
573 Public Sub SetWritableMode( Flags )
\r
574 If g_AppKey Is Me Then
\r
575 If Flags = F_IgnoreIfWarn Then
\r
578 m_Key.SetWritableMode( Flags )
\r
584 Case F_AskIfWarn : echo ">SetWritableMode F_AskIfWarn"
\r
585 Case F_ErrIfWarn : echo ">SetWritableMode F_ErrIfWarn"
\r
586 Case F_IgnoreIfWarn:echo ">SetWritableMode F_IgnoreIfWarn"
\r
587 Case F_BreakIfWarn :echo ">SetWritableMode F_BreakIfWarn"
\r
588 Case Else : Err.Raise 1
\r
591 m_WritableMode = Flags
\r
594 Public Function GetWritableMode()
\r
595 If g_AppKey Is Me Then
\r
596 GetWritableMode = m_Key.GetWritableMode()
\r
598 GetWritableMode = m_WritableMode
\r
603 '********************************************************************************
\r
604 ' <<< [AppKeyClass::AddNewWritableFolder] >>>
\r
605 '********************************************************************************
\r
606 Public Sub AddNewWritableFolder( Path )
\r
607 If g_AppKey Is Me Then m_Key.AddNewWritableFolder( Path ) : Exit Sub
\r
609 Dim abs_path, passed_path, out
\r
612 If g_debug_or_test Then
\r
613 If StrComp( g_AppKey.m_BreakByFName, g_fs.GetFileName( Path ), vbTextCompare ) = 0 Then
\r
614 echo_r "Break by """ + g_AppKey.m_BreakByFName + """", ""
\r
620 '// If the folder in writable folder, Do nothing
\r
621 abs_path = g_CurrentWritables.CheckWritable( Path )
\r
622 If IsEmpty( abs_path ) Then Exit Sub
\r
625 '// If it is not able to add new writable, raise warning.
\r
626 If not IsEmpty( g_CurrentWritables.CheckAddNewWritable( abs_path, out ) ) Then _
\r
627 CheckWritable abs_path : Exit Sub
\r
631 '// Add to m_NewWritables
\r
632 '// (sample) writable="C:\A\*", passed="C:\A", abs="C:\A\B" ... new="C:\A\B\"
\r
633 '// (sample) writable="C:\A\*", passed="C:\A", abs="C:\A\B\a.txt" ... new="C:\A\B\"
\r
634 '// (sample) writable="C:\A\*", passed="C:\A", abs="C:\A\B\C\a.txt" ... new="C:\A\B\"
\r
635 '// (sample) writable="C:\*", passed="C:", abs="C:\A\B\C\a.txt" ... new="C:\A\"
\r
637 ReDim Preserve m_NewWritables( UBound( m_NewWritables ) + 1 )
\r
639 Dim i : i = InStr( Len(passed_path)+2, abs_path, "\" )
\r
641 m_NewWritables( UBound( m_NewWritables ) ) = abs_path + "\"
\r
643 m_NewWritables( UBound( m_NewWritables ) ) = Left( abs_path, i )
\r
650 '********************************************************************************
\r
651 ' <<< [AppKeyClass::CheckNewWritable] >>>
\r
652 '********************************************************************************
\r
653 Public Function CheckNewWritable( AbsPath )
\r
654 If g_AppKey Is Me Then CheckNewWritable = m_Key.CheckNewWritable( AbsPath ) : Exit Function
\r
658 For Each writable In m_NewWritables
\r
659 If StrComp( writable, Left( AbsPath, Len( writable ) ), 1 ) = 0 Then Exit Function
\r
661 CheckNewWritable = AbsPath
\r
665 '********************************************************************************
\r
666 ' <<< [AppKeyClass::Ask] >>>
\r
667 '********************************************************************************
\r
668 Public Sub Ask( CheckPath )
\r
669 If g_AppKey Is Me Then m_Key.Ask( CheckPath ) : Exit Sub
\r
671 Dim msg2 : msg2 = "" : If exist( CheckPath ) Then msg2 = "Cannot overwrite, "
\r
674 For Each writable In g_CurrentWritables.CurrentPathes
\r
675 If Right( writable, 3 ) = "\*\" Then
\r
676 If Left( writable, Len(writable) - 2 ) = Left( CheckPath, Len( writable ) - 2 ) or _
\r
677 Left( writable, Len(writable) - 3 ) = CheckPath Then
\r
678 If g_fs.FileExists( CheckPath ) Then
\r
679 msg2 = "Cannot overwrite NOT NEW file, "
\r
681 msg2 = "Cannot overwrite NOT NEW folder, "
\r
687 If m_WritableMode <> F_ErrIfWarn Then
\r
688 echo_r "<WARNING msg='" +msg2+ "Out of Writable, see the help of SetWritableMode.'" +_
\r
689 " path='" & CheckPath & "'/>", ""
\r
692 If m_WritableMode = F_AskIfWarn Then
\r
696 If g_CommandPrompt = 0 Then
\r
697 s = InputBox( "
\92¼
\91O
\82Ì
\83_
\83C
\83A
\83\8d\83O
\83E
\83B
\83\93\83h
\83E
\82É
\95\
\8e¦
\82µ
\82½
\83p
\83X
\82É
\83t
\83@
\83C
\83\8b\82ð
\8fo
\97Í
\82µ
\82Ü
\82·
\81B" & vbCRLF & _
\r
698 "(Y)
\82Í
\82¢
\81B
\83t
\83@
\83C
\83\8b\8fo
\97Í
\82ð
\8b\96\89Â
\82µ
\82Ü
\82·" & vbCRLF & "(A)
\88È
\8cã
\81A
\82·
\82×
\82Ä
\82Í
\82¢" & vbCRLF & _
\r
699 "(N)
\82¢
\82¢
\82¦
\81B
\83v
\83\8d\83O
\83\89\83\80\82ð
\8fI
\97¹
\82µ
\82Ü
\82·" & vbCRLF & "(R)
\83p
\83X
\82ð
\82à
\82¤
\88ê
\93x
\95\
\8e¦
\82µ
\82Ü
\82·", _
\r
700 "[WARNING] " +msg2+ "Out of Writable", "Y" )
\r
702 s = InputBox( "
\83R
\83}
\83\93\83h
\83v
\83\8d\83\93\83v
\83g
\82É
\95\
\8e¦
\82µ
\82½
\83p
\83X
\82É
\83t
\83@
\83C
\83\8b\82ð
\8fo
\97Í
\82µ
\82Ü
\82·
\81B" & vbCRLF & _
\r
703 "(Y)
\82Í
\82¢
\81B
\83t
\83@
\83C
\83\8b\8fo
\97Í
\82ð
\8b\96\89Â
\82µ
\82Ü
\82·" & vbCRLF & "(A)
\88È
\8cã
\81A
\82·
\82×
\82Ä
\82Í
\82¢" & vbCRLF & _
\r
704 "(N)
\82¢
\82¢
\82¦
\81B
\83v
\83\8d\83O
\83\89\83\80\82ð
\8fI
\97¹
\82µ
\82Ü
\82·" & vbCRLF & "(R)
\83p
\83X
\82ð
\82à
\82¤
\88ê
\93x
\95\
\8e¦
\82µ
\82Ü
\82·", _
\r
705 "[WARNING] " +msg2+ "Out of Writable", "Y" )
\r
708 If s="Y" or s="y" Then
\r
710 ElseIf s="A" or s="a" Then
\r
711 SetWritableMode F_IgnoreIfWarn
\r
713 ElseIf s="R" or s="r" Then
\r
714 MsgBox CheckPath, vbOKOnly, "[WARNING] Out of Writable"
\r
716 Err.Raise E_OutOfWritable,, "Out of Writable """ & CheckPath & """"
\r
717 ' Watch g_CurrentWritables.CurrentPathes and CheckPath
\r
722 If m_WritableMode = F_BreakIfWarn Then Stop '// Look at caller function using debugger
\r
723 If m_WritableMode = F_BreakIfWarn or m_WritableMode = F_ErrIfWarn Then
\r
724 Err.Raise E_OutOfWritable,, msg2+"Out of Writable """ & CheckPath & """"
\r
725 ' Watch g_CurrentWritables.CurrentPathes and Path (CheckPath)
\r
730 '********************************************************************************
\r
731 ' <<< [AppKeyClass::InPath] >>>
\r
732 '********************************************************************************
\r
733 Public Function InPath( ChkPathes, WritablePathes )
\r
734 If IsArray( ChkPathes ) or IsArray( WritablePathes ) Then
\r
737 echo ">InPath " & ChkPathes & ", " & WritablePathes
\r
741 '// ChkPathes To abs path
\r
742 If IsArray( ChkPathes ) Then
\r
743 ReDim cs( UBound( ChkPathes ) )
\r
744 For i=0 To UBound( cs )
\r
745 cs(i) = g_fs.GetAbsolutePathName( ChkPathes(i) ) + "\"
\r
749 cs(0) = g_fs.GetAbsolutePathName( ChkPathes ) + "\"
\r
753 '// WritablePathes To abs path
\r
754 If IsArray( WritablePathes ) Then
\r
755 ReDim ws( UBound( WritablePathes ) )
\r
756 For i=0 To UBound( ws )
\r
757 ws(i) = g_fs.GetAbsolutePathName( WritablePathes(i) ) + "\"
\r
761 ws(0) = g_fs.GetAbsolutePathName( WritablePathes ) + "\"
\r
769 If Left( c, Len(w) ) = w Then b = True : Exit For
\r
771 If not b Then InPath = False : Exit Function
\r
780 '********************************************************************************
\r
781 ' <<< [AppKeyClass::BreakByPath] >>>
\r
782 '********************************************************************************
\r
783 Public Function BreakByPath( Path )
\r
784 If StrComp( m_BreakByFName, g_fs.GetFileName( Path ), vbTextCompare ) = 0 Then
\r
785 echo_r "Break by """ + g_AppKey.m_BreakByFName + """", ""
\r
793 '********************************************************************************
\r
794 ' <<< [AppKeyClass::BreakByWildcard] >>>
\r
795 '********************************************************************************
\r
796 Public Function BreakByWildcard( Path, Flags )
\r
797 Dim folder, fnames()
\r
800 ExpandWildcard Path, Flags, folder, fnames
\r
801 For Each fname in fnames
\r
802 If StrComp( m_BreakByFName, g_fs.GetFileName( fname ), vbTextCompare ) = 0 Then
\r
803 echo_r "Break by """ + g_AppKey.m_BreakByFName + """", ""
\r
813 '********************************************************************************
\r
814 ' <<< [Writables] Class >>>
\r
815 '********************************************************************************
\r
820 Public Sub SetPathes( AppKey, Pathes )
\r
823 If not IsEmpty( m_AppKey ) Then Err.Raise 1,,"Double key"
\r
824 If not g_AppKey.IsSame( AppKey ) Then Err.Raise 1,,"Invalied AppKey"
\r
826 If IsArray( Pathes ) Then
\r
827 ReDim m_Pathes( UBound( Pathes ) + 1 )
\r
828 For i=0 To UBound( Pathes )
\r
829 abs_path = GetAbsPath( Pathes(i), Empty )
\r
830 g_CurrentWritables.AskFileAccess abs_path
\r
831 m_Pathes(i) = abs_path + "\"
\r
833 ElseIf TypeName( Pathes ) = "ArrayClass" Then
\r
834 ReDim m_Pathes( UBound( Pathes.m_Array ) + 1 )
\r
835 For i=0 To UBound( Pathes.m_Array )
\r
836 abs_path = GetAbsPath( Pathes(i), Empty )
\r
837 g_CurrentWritables.AskFileAccess abs_path
\r
838 m_Pathes(i) = abs_path + "\"
\r
841 ReDim m_Pathes( 1 )
\r
842 abs_path = GetAbsPath( Pathes, Empty )
\r
843 g_CurrentWritables.AskFileAccess abs_path
\r
844 m_Pathes(0) = abs_path + "\"
\r
847 GetObject_g_TempFile
\r
848 m_Pathes( UBound( m_Pathes ) ) = g_TempFile.m_FolderPath
\r
850 Set m_AppKey = AppKey
\r
853 Public Function Enable()
\r
854 Dim st : Set st = new WritablesStack : ErrCheck
\r
855 st.PushPathes m_AppKey, m_Pathes
\r
862 '********************************************************************************
\r
863 ' <<< [WritablesStack] Class >>>
\r
864 '********************************************************************************
\r
865 Class WritablesStack
\r
869 Public Sub PushPathes( AppKey, Pathes )
\r
870 Set m_Pathes = new ArrayClass : ErrCheck
\r
871 m_Pathes.Copy Pathes
\r
872 Set m_AppKey = AppKey
\r
873 g_CurrentWritables.PushPathes AppKey, Pathes
\r
876 Private Sub Class_Terminate()
\r
877 g_CurrentWritables.PopPathes m_AppKey, m_Pathes
\r
883 '********************************************************************************
\r
884 ' <<< [CurrentWritables] Class >>>
\r
885 '********************************************************************************
\r
886 Class CurrentWritables
\r
887 Private m_PathesStack ' as ArrayClass of ArrayClass
\r
889 Private m_ProgramFiles
\r
892 Private m_LOCALAPPDATA
\r
894 Public Property Get CurrentPathes
\r
895 If m_PathesStack.Count > 0 Then
\r
896 CurrentPathes = m_PathesStack.m_Array( m_PathesStack.Count-1 ).m_Array
\r
898 CurrentPathes = m_PathesStack.m_Array
\r
901 Public Property Get PathesStack : Set PathesStack = m_PathesStack : End Property
\r
904 Private Sub Class_Initialize()
\r
905 Set m_PathesStack = new ArrayClass : ErrCheck
\r
907 m_ProgramFiles = g_sh.ExpandEnvironmentStrings( "%ProgramFiles%" )
\r
908 m_windir = g_sh.ExpandEnvironmentStrings( "%windir%" )
\r
909 m_APPDATA = g_sh.ExpandEnvironmentStrings( "%APPDATA%" )
\r
910 m_LOCALAPPDATA = g_sh.ExpandEnvironmentStrings( "%LOCALAPPDATA%" )
\r
912 If m_ProgramFiles = "%ProgramFiles%" Then m_ProgramFiles = Empty
\r
913 If m_windir = "%windir%" Then m_windir = Empty
\r
914 If m_APPDATA = "%APPDATA%" Then m_APPDATA = Empty
\r
915 If m_LOCALAPPDATA = "%LOCALAPPDATA%" Then m_LOCALAPPDATA = Empty
\r
919 Public Sub PushPathes( AppKey, Pathes )
\r
921 If not g_AppKey.IsSame( AppKey ) Then Err.Raise 1,,"Invalied AppKey"
\r
922 Dim new_pathes : Set new_pathes = new ArrayClass : ErrCheck
\r
923 new_pathes.Copy Pathes
\r
924 m_PathesStack.Push new_pathes
\r
928 Public Sub PopPathes( AppKey, Pathes )
\r
931 If not g_AppKey.IsSame( AppKey ) Then Err.Raise 1,,"Invalied AppKey"
\r
933 For i=m_PathesStack.Count-1 To 0 Step -1
\r
934 If Pathes.Count = m_PathesStack.m_Array(i).Count Then
\r
935 For j=0 To Pathes.Count-1
\r
936 If Pathes.m_Array(j) <> m_PathesStack.m_Array(i).m_Array(j) Then Exit For
\r
938 If j = Pathes.Count Then Exit For '// If same all Pathes
\r
941 If i = -1 Then Err.Raise 1
\r
943 For i=i To m_PathesStack.Count-2
\r
944 Set m_PathesStack.m_Array(i) = m_PathesStack.m_Array(i+1)
\r
950 Public Function CheckWritable( Path )
\r
951 Dim abs_path, writable, s
\r
952 abs_path = g_fs.GetAbsolutePathName( Path )
\r
953 If Right( Path, 2 ) = "\." Then abs_path = abs_path + "\."
\r
955 For Each writable In Me.CurrentPathes
\r
956 If StrComp( writable, Left( abs_path, Len( writable ) ), 1 ) = 0 Then Exit Function
\r
960 For Each writable In Me.CurrentPathes
\r
961 If StrComp( writable, s, 1 ) = 0 Then Exit Function
\r
964 abs_path = g_AppKey.CheckNewWritable( abs_path )
\r
965 If IsEmpty( abs_path ) Then Exit Function
\r
967 If Right( abs_path, 2 ) = "\." Then abs_path = Left( abs_path, Len( abs_path ) - 2 )
\r
968 CheckWritable = abs_path
\r
972 Public Function CheckAddNewWritable( Path, out_PassedPath )
\r
973 Dim abs_path, writable
\r
974 abs_path = g_fs.GetAbsolutePathName( Path )
\r
975 If Right( Path, 2 ) = "\." Then abs_path = abs_path + "\."
\r
977 If not exist( Path ) Then
\r
978 '// If the folder already exists, do not writable
\r
980 For Each writable In Me.CurrentPathes
\r
981 If Right( writable, 3 ) = "\*\" Then
\r
982 If Left( writable, Len(writable) - 2 ) = Left( abs_path, Len( writable ) - 2 ) or _
\r
983 Left( writable, Len(writable) - 3 ) = abs_path Then
\r
984 out_PassedPath = Left( writable, Len(writable) - 3 )
\r
991 If Right( abs_path, 2 ) = "\." Then abs_path = Left( abs_path, Len( abs_path ) - 2 )
\r
992 CheckAddNewWritable = abs_path
\r
996 Public Sub AskFileAccess( AbsPath )
\r
997 If not IsEmpty( m_ProgramFiles ) Then _
\r
998 If Left( AbsPath, Len( m_ProgramFiles ) ) = m_ProgramFiles or _
\r
999 Left( m_ProgramFiles, Len( AbsPath ) ) = AbsPath Then _
\r
1000 g_AppKey.Ask AbsPath
\r
1002 If not IsEmpty( m_windir ) Then _
\r
1003 If Left( AbsPath, Len( m_windir ) ) = m_windir or _
\r
1004 Left( m_windir, Len( AbsPath ) ) = AbsPath Then _
\r
1005 g_AppKey.Ask AbsPath
\r
1007 If not IsEmpty( m_APPDATA ) Then _
\r
1008 If Left( AbsPath, Len( m_APPDATA ) ) = m_APPDATA or _
\r
1009 Left( m_APPDATA, Len( AbsPath ) ) = AbsPath Then _
\r
1010 g_AppKey.Ask AbsPath
\r
1012 If not IsEmpty( m_LOCALAPPDATA ) Then _
\r
1013 If Left( AbsPath, Len( m_LOCALAPPDATA ) ) = m_LOCALAPPDATA or _
\r
1014 Left( m_LOCALAPPDATA, Len( AbsPath ) ) = AbsPath Then _
\r
1015 g_AppKey.Ask AbsPath
\r
1022 '********************************************************************************
\r
1023 ' <<< [SetWritableMode] >>>
\r
1024 '********************************************************************************
\r
1025 Sub SetWritableMode( Flags )
\r
1026 g_AppKey.SetWritableMode Flags
\r
1030 '********************************************************************************
\r
1031 ' <<< [CheckWritable] Check not to modify out of working folder >>>
\r
1033 ' - If path is out of workfolder, raise error of E_OutOfWritable.
\r
1034 ' - This function is overritable, because other APIs calling this and g_CurrentWritables
\r
1036 '********************************************************************************
\r
1037 Sub CheckWritable( Path )
\r
1040 abs_path = g_CurrentWritables.CheckWritable( Path )
\r
1041 If IsEmpty( abs_path ) Then Exit Sub
\r
1042 g_AppKey.Ask abs_path
\r
1047 '********************************************************************************
\r
1048 ' <<< [set_workfolder] old function >>>
\r
1049 '********************************************************************************
\r
1050 Sub set_workfolder( ByVal dir )
\r
1051 If g_cut_old Then Stop
\r
1055 Class WorkFolderStack
\r
1056 Private Sub Class_Initialize()
\r
1057 If g_cut_old Then Stop
\r
1059 Public Sub set_( x ) : End Sub
\r
1062 '********************************************************************************
\r
1063 ' <<< [SetBreakByFName] >>>
\r
1064 '********************************************************************************
\r
1065 Sub SetBreakByFName( FName )
\r
1066 g_AppKey.m_BreakByFName = FName
\r
1070 '********************************************************************************
\r
1071 ' <<< [cd] change current directory >>>
\r
1074 '********************************************************************************
\r
1075 Sub cd( ByVal dir )
\r
1076 echo ">cd """ & dir & """"
\r
1080 On Error Resume Next
\r
1081 g_sh.CurrentDirectory = dir
\r
1082 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
1083 If en = E_WIN32_FILE_NOT_FOUND or en = E_WIN32_DIRECTORY Then _
\r
1084 Err.Raise en,, "
\83t
\83H
\83\8b\83_
\82Å
\82Í
\82 \82è
\82Ü
\82¹
\82ñ : " & dir
\r
1085 If en <> 0 Then Err.Raise en,,ed
\r
1091 '********************************************************************************
\r
1092 ' <<< [CurDirStack] >>>
\r
1093 '********************************************************************************
\r
1098 Private Sub Class_Initialize
\r
1099 m_Prev = g_sh.CurrentDirectory
\r
1102 Private Sub Class_Terminate
\r
1103 g_sh.CurrentDirectory = m_Prev
\r
1109 '********************************************************************************
\r
1110 ' <<< [pushd] push and change current directory >>>
\r
1113 '********************************************************************************
\r
1114 Dim g_pushd_stack()
\r
1115 Dim g_pushd_stack_n
\r
1117 Sub pushd( ByVal dir )
\r
1118 echo ">pushd " & dir
\r
1121 g_pushd_stack_n = g_pushd_stack_n + 1
\r
1122 Redim Preserve g_pushd_stack( g_pushd_stack_n )
\r
1124 Set sh = WScript.CreateObject("WScript.Shell")
\r
1125 g_pushd_stack( g_pushd_stack_n ) = sh.CurrentDirectory
\r
1126 sh.CurrentDirectory = dir
\r
1132 '********************************************************************************
\r
1133 ' <<< [popd] pop current directory >>>
\r
1134 '********************************************************************************
\r
1139 If g_pushd_stack_n < 1 Then Exit Sub
\r
1141 Set sh = WScript.CreateObject("WScript.Shell")
\r
1142 sh.CurrentDirectory = g_pushd_stack( g_pushd_stack_n )
\r
1144 g_pushd_stack_n = g_pushd_stack_n - 1
\r
1150 '********************************************************************************
\r
1153 ' - src : source file or folder path or wild card
\r
1154 ' - dst : destination folder path or renaming file path
\r
1156 ' - reference: vbslib.svg#copy
\r
1157 '********************************************************************************
\r
1158 Sub copy( ByVal src, ByVal dst )
\r
1161 ' If src had Wild card
\r
1162 If IsWildcard( src ) Then
\r
1166 echo ">copy """ & src & """, """ & dst & """"
\r
1167 If Not g_fs.FolderExists( dst ) Then Set en=new EchoOff : mkdir dst : en=Empty
\r
1168 If Not g_fs.FolderExists( GetParentAbsPath( src ) ) Then _
\r
1169 Err.Raise E_PathNotFound,,"
\83p
\83X
\82ª
\8c©
\82Â
\82©
\82è
\82Ü
\82¹
\82ñ
\81B"
\r
1171 g_AppKey.AddNewWritableFolder dst + "\." '// "\." is for able to make writable folder
\r
1172 If g_debug_or_test Then g_AppKey.BreakByWildcard src, F_File
\r
1174 On Error Resume Next
\r
1175 g_fs.CopyFile src, dst, True
\r
1176 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
1177 If en = E_FileNotExist Then en = 0
\r
1178 If en <> 0 Then Err.Raise en,,ed
\r
1180 Dim i_retry '// 1
\89ñ
\96Ú
\82É E_WriteAccessDenied
\82É
\82È
\82é
\82±
\82Æ
\82ª
\82½
\82Ü
\82É
\82 \82é
\82½
\82ß
\r
1181 For i_retry = 1 To 2
\r
1182 On Error Resume Next
\r
1183 g_fs.CopyFolder src, dst, True
\r
1184 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
1185 If en = E_PathNotFound Then en = 0
\r
1186 If i_retry >= 2 and en <> E_WriteAccessDenied Then
\r
1187 If en <> 0 Then Err.Raise en,,ed
\r
1189 If en = 0 Then Exit For
\r
1191 echo_r "<WARNING msg='" & ed & "' msg2='
\8dÄ
\8e\8e\8ds
\82µ
\82Ä
\82¢
\82Ü
\82·'/>", ""
\r
1192 Sleep g_FileSystemRetryMSec
\r
1196 ElseIf g_fs.FileExists( src ) Then
\r
1200 If g_fs.FolderExists( dst ) Then
\r
1201 dst = g_fs.BuildPath( dst, g_fs.GetFileName( src ) )
\r
1203 dst_fo = GetParentAbsPath( dst )
\r
1204 If dst_fo <> "" And Not g_fs.FolderExists( dst_fo ) Then _
\r
1205 Set en=new EchoOff : mkdir dst_fo : en=Empty
\r
1208 echo ">copy """ & src & """, """ & dst & """"
\r
1209 If not g_fs.FileExists( dst ) Then
\r
1210 g_AppKey.AddNewWritableFolder dst + "\." '// "\." is for able to make writable folder
\r
1212 g_AppKey.AddNewWritableFolder dst
\r
1215 On Error Resume Next
\r
1216 g_fs.CopyFile src, dst, True
\r
1217 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
1218 If en = 70 Then ed = ed + " : " + dst
\r
1219 If en <> 0 Then Err.Raise en,,ed
\r
1222 ' If src is folder
\r
1223 ElseIf g_fs.FolderExists( src ) Then
\r
1225 If Not g_fs.FolderExists( dst ) Then Set en=new EchoOff : mkdir dst : en=Empty
\r
1227 echo ">copy """ & src & """, """ & dst & """"
\r
1228 g_AppKey.AddNewWritableFolder dst
\r
1229 If g_debug_or_test Then g_AppKey.BreakByWildcard src+"\*", F_File or F_SubFolder
\r
1231 g_fs.CopyFolder src, g_fs.BuildPath( dst, g_fs.GetFileName( src ) ), True
\r
1236 echo ">copy """ & src & """, """ & dst & """"
\r
1237 g_AppKey.AddNewWritableFolder dst + "\." '// "\." is for able to make writable folder
\r
1238 g_fs.CopyFile src, dst, True ' Error occurs
\r
1245 '********************************************************************************
\r
1247 '********************************************************************************
\r
1248 Sub move( ByVal src, ByVal dst )
\r
1250 ' If src had Wild card
\r
1251 If IsWildcard( src ) Then
\r
1255 If Not g_fs.FolderExists( dst ) Then mkdir dst
\r
1256 echo ">move """ & src & """, """ & dst & """"
\r
1257 If Not g_fs.FolderExists( g_fs.GetParentFolderName( src ) ) Then _
\r
1258 Err.Raise E_PathNotFound,,"
\83p
\83X
\82ª
\8c©
\82Â
\82©
\82è
\82Ü
\82¹
\82ñ
\81B"
\r
1260 g_AppKey.AddNewWritableFolder dst + "\." '// "\." is for able to make writable folder
\r
1261 If g_debug_or_test Then g_AppKey.BreakByWildcard src, F_File
\r
1263 On Error Resume Next
\r
1264 g_fs.MoveFile src, dst
\r
1265 g_fs.MoveFolder src, dst
\r
1266 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
1267 If en = E_PathNotFound Then en = 0
\r
1268 If en = E_FileNotExist Then en = 0
\r
1269 If en <> 0 Then Err.Raise en,,ed
\r
1273 ElseIf g_fs.FileExists( src ) Then
\r
1277 If g_fs.FolderExists( dst ) Then
\r
1278 dst = g_fs.BuildPath( dst, g_fs.GetFileName( src ) )
\r
1280 dst_fo = g_fs.GetParentFolderName( dst )
\r
1281 If Not g_fs.FolderExists( dst_fo ) Then mkdir dst_fo
\r
1284 echo ">move """ & src & """, """ & dst & """"
\r
1285 If IsWildcard( src ) or not g_fs.FileExists( dst ) Then
\r
1286 g_AppKey.AddNewWritableFolder dst + "\." '// "\." is for able to make writable folder
\r
1288 g_AppKey.AddNewWritableFolder dst
\r
1291 g_fs.MoveFile src, dst
\r
1294 ' If src is folder
\r
1295 ElseIf g_fs.FolderExists( src ) Then
\r
1297 If Not g_fs.FolderExists( dst ) Then mkdir dst
\r
1299 echo ">move """ & src & """, """ & dst & """"
\r
1300 g_AppKey.AddNewWritableFolder dst
\r
1301 If g_debug_or_test Then g_AppKey.BreakByWildcard src+"\*", F_File or F_SubFolder
\r
1303 g_fs.MoveFolder src, g_fs.BuildPath( dst, g_fs.GetFileName( src ) )
\r
1308 echo ">move """ & src & """, """ & dst & """"
\r
1309 g_AppKey.AddNewWritableFolder dst + "\." '// "\." is for able to make writable folder
\r
1310 g_fs.MoveFile src, dst ' Error occurs
\r
1317 '********************************************************************************
\r
1319 '********************************************************************************
\r
1320 Sub ren( src, dst )
\r
1321 echo ">ren """ & src & """, """ & dst & """"
\r
1324 If g_fs.FileExists( src ) Then
\r
1325 g_AppKey.AddNewWritableFolder src
\r
1326 Set f = g_fs.GetFile( src )
\r
1327 f.Name = g_fs.GetFileName( dst )
\r
1329 g_AppKey.AddNewWritableFolder src + "\." '// "\." is for able to make writable folder
\r
1330 Set f = g_fs.GetFolder( src )
\r
1331 f.Name = g_fs.GetFileName( dst )
\r
1337 '********************************************************************************
\r
1338 ' <<< [SafeFileUpdate] >>>
\r
1339 '********************************************************************************
\r
1340 Sub SafeFileUpdate( FromTmpFilePath, ToUpdateFilePath )
\r
1341 echo ">SafeFileUpdate """ & FromTmpFilePath & """, """ & ToUpdateFilePath & """"
\r
1342 Dim en,ed,en2,ed2,i,path
\r
1345 path = g_fs.GetParentFolderName( ToUpdateFilePath ) + "\" + _
\r
1346 g_fs.GetBaseName( ToUpdateFilePath ) + "." & i & "." + g_fs.GetExtensionName( ToUpdateFilePath )
\r
1347 If not exist( path ) Then Exit For
\r
1349 If exist( path ) Then Err.Raise E_Other,,"
\83o
\83b
\83N
\83A
\83b
\83v
\82Ì
\83t
\83@
\83C
\83\8b\96¼
\82ª
\8dì
\82ê
\82Ü
\82¹
\82ñ
\81B
\81F" + ToUpdateFilePath
\r
1351 On Error Resume Next
\r
1352 g_fs.CopyFile ToUpdateFilePath, path, False
\r
1353 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
1354 If en <> 0 Then Err.Raise en,,"
\83o
\83b
\83N
\83A
\83b
\83v
\83R
\83s
\81[
\82É
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½
\81B"+vbCR+vbLF+_
\r
1355 "
\83o
\83b
\83N
\83A
\83b
\83v
\8c³
\81F"+ToUpdateFilePath+vbCR+vbLF+ "
\83o
\83b
\83N
\83A
\83b
\83v
\90æ
\81F"+path+vbCR+vbLF+ ed
\r
1357 del_to_trashbox path
\r
1359 On Error Resume Next
\r
1360 g_fs.CopyFile FromTmpFilePath, ToUpdateFilePath, True
\r
1361 en2 = Err.Number : ed2 = Err.Description : On Error GoTo 0
\r
1363 On Error Resume Next
\r
1364 g_fs.DeleteFile FromTmpFilePath
\r
1365 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
1367 If en2 <> 0 Then Err.Raise en2,,"
\8fã
\8f\91\82«
\83R
\83s
\81[
\82É
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½
\81B
\83S
\83~
\94 \82É
\93ü
\82ê
\82½
\8c³
\82Ì
\83t
\83@
\83C
\83\8b\82ð
\95\9c\8a\88\82³
\82¹
\82Ä
\82
\82¾
\82³
\82¢
\81B"+vbCR+vbLF+_
\r
1368 "
\83R
\83s
\81[
\8c³
\81F"+FromTmpFilePath+vbCR+vbLF+ "
\83R
\83s
\81[
\90æ
\81F"+ToUpdateFilePath+vbCR+vbLF+ ed2
\r
1370 If en <> 0 Then WScript.Echo "
\8dX
\90V
\82Í
\90¬
\8c÷
\82µ
\82Ü
\82µ
\82½
\82ª
\81A
\88ê
\8e\9e\83t
\83@
\83C
\83\8b\82Ì
\8dí
\8f\9c\82É
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½
\81B"+vbCR+vbLF+_
\r
1371 "
\88ê
\8e\9e\83t
\83@
\83C
\83\8b\81F"+FromTmpFilePath+vbCR+vbLF+ "
\8dX
\90V
\8dÏ
\82Ý
\83t
\83@
\83C
\83\8b\81F"+ToUpdateFilePath+vbCR+vbLF+ ed
\r
1377 '********************************************************************************
\r
1379 '********************************************************************************
\r
1380 Sub del( ByVal path )
\r
1381 echo ">del """ & path & """"
\r
1382 Dim ec : Set ec = new EchoOff
\r
1384 ' If path had Wild card
\r
1385 If IsWildCard( path ) Then
\r
1386 Dim folder, fname, fnames()
\r
1388 ExpandWildcard path, F_File, folder, fnames
\r
1389 For Each fname in fnames
\r
1390 del g_fs.BuildPath( folder, fname )
\r
1393 ExpandWildcard path, F_Folder, folder, fnames
\r
1394 For Each fname in fnames
\r
1395 del g_fs.BuildPath( folder, fname )
\r
1398 ' If path was file or folder path
\r
1401 If g_fs.FileExists( path ) Then
\r
1402 g_AppKey.AddNewWritableFolder path
\r
1403 g_fs.DeleteFile path
\r
1404 ElseIf g_fs.FolderExists( path ) Then
\r
1413 '********************************************************************************
\r
1414 ' <<< [del_subfolder] >>>
\r
1415 '********************************************************************************
\r
1416 Sub del_subfolder( ByVal path )
\r
1417 echo ">del_subfolder """ & path & """"
\r
1418 Dim folder, fname, fnames()
\r
1420 ExpandWildcard path, F_File Or F_SubFolder, folder, fnames
\r
1421 For Each fname in fnames
\r
1422 del g_fs.BuildPath( folder, fname )
\r
1425 ExpandWildcard path, F_Folder Or F_SubFolder, folder, fnames
\r
1426 For Each fname in fnames
\r
1427 del g_fs.BuildPath( folder, fname )
\r
1433 '********************************************************************************
\r
1434 ' <<< [del_to_trashbox] >>>
\r
1435 '********************************************************************************
\r
1436 Sub del_to_trashbox( ByVal path )
\r
1437 echo ">del_to_trashbox """ & path & """"
\r
1439 Dim sh_ap, TrashBox, folder, item, fname
\r
1440 Set sh_ap = CreateObject("Shell.Application")
\r
1441 Const ssfBITBUCKET = 10
\r
1443 g_AppKey.AddNewWritableFolder path + "\." '// "\." is for able to make writable folder
\r
1446 '//=== Check deletable by rename for Windows XP
\r
1447 On Error Resume Next
\r
1448 ren path, g_fs.GetFileName( path ) + "_deleting"
\r
1449 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
1450 If en = 70 Then Err.Raise 17,,"
\83S
\83~
\94 \82Ö
\88Ú
\93®
\82Å
\82«
\82Ü
\82¹
\82ñ : " + path
\r
1451 If en = 76 Then Exit Sub ' not found path
\r
1452 If en <> 0 Then Err.Raise en,,ed
\r
1453 On Error Resume Next
\r
1454 ren path + "_deleting", g_fs.GetFileName( path )
\r
1455 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
1456 If en <> 0 and en <> E_OutOfWritable Then Err.Raise en,,ed
\r
1459 '//=== move to trashbox
\r
1460 path = g_fs.GetAbsolutePathName( path )
\r
1461 fname = g_fs.GetFileName( path )
\r
1462 Set folder = sh_ap.NameSpace( g_fs.GetParentFolderName( path ) )
\r
1463 If folder is Nothing Then Exit Sub
\r
1464 Set item = folder.Items.Item( fname )
\r
1465 If item is Nothing Then Exit Sub
\r
1467 Set TrashBox = sh_ap.NameSpace( ssfBITBUCKET )
\r
1468 TrashBox.MoveHere item
\r
1471 '//=== for Windows Vista
\r
1472 ' If exist( path ) Then Err.Raise 17,,"
\83S
\83~
\94 \82Ö
\88Ú
\93®
\82Å
\82«
\82Ü
\82¹
\82ñ : " + path
\r
1475 '//=== for Windows XP
\r
1478 Set item = folder.Items.Item( fname )
\r
1479 If item is Nothing Then Exit Do
\r
1486 '********************************************************************************
\r
1487 ' <<< [del_confirmed] >>>
\r
1488 '********************************************************************************
\r
1489 Function del_confirmed( Path )
\r
1490 echo ">del_confirmed """ & Path & """"
\r
1491 If exist( Path ) Then
\r
1492 Dim r : r = input( "
\8dí
\8f\9c\82µ
\82Ä
\82æ
\82ë
\82µ
\82¢
\82Å
\82·
\82©
\81H : " + Path + " (Y/N)" )
\r
1493 del_confirmed = ( r="Y" or r="y" )
\r
1494 If del_confirmed Then del Path
\r
1496 del_confirmed = True
\r
1502 '********************************************************************************
\r
1503 ' <<< [mkdir] >>>
\r
1504 '********************************************************************************
\r
1505 Function mkdir( ByVal Path )
\r
1506 echo ">mkdir """ & Path & """"
\r
1507 Dim i, n, names(), fo2
\r
1509 g_AppKey.AddNewWritableFolder Path + "\."
\r
1511 If g_fs.FolderExists( Path ) Then mkdir = 0 : Exit Function
\r
1514 fo2 = g_fs.GetAbsolutePathName( Path )
\r
1516 If g_fs.FolderExists( fo2 ) Then Exit Do
\r
1519 Redim Preserve names(n)
\r
1520 names(n) = g_fs.GetFileName( fo2 )
\r
1521 fo2 = g_fs.GetParentFolderName( fo2 )
\r
1526 For n=n To 1 Step -1
\r
1527 fo2 = g_fs.BuildPath( fo2, names(n) )
\r
1528 g_fs.CreateFolder fo2
\r
1535 '********************************************************************************
\r
1536 ' <<< [mkdir_for] >>>
\r
1537 '********************************************************************************
\r
1538 Sub mkdir_for( Path )
\r
1541 s = g_fs.GetParentFolderName( Path )
\r
1542 If s = "" Then Exit Sub
\r
1548 '********************************************************************************
\r
1549 ' <<< [rmdir] >>>
\r
1550 '********************************************************************************
\r
1551 Sub rmdir( ByVal Path )
\r
1552 echo ">rmdir """ & Path & """"
\r
1553 Dim path2, iFolder, nFolder, fo, subf, f, file
\r
1555 If Not g_fs.FolderExists( Path ) Then Exit Sub
\r
1556 g_AppKey.AddNewWritableFolder Path + "\." '// "\." is for able to make writable folder
\r
1561 If Right( path2, 1 ) = "\" Then path2 = Left( path2, Len( path2 ) - 1 )
\r
1564 ReDim folderPathes(nFolder)
\r
1565 folderPathes(nFolder) = path2
\r
1567 ' Enum sub folders
\r
1569 While iFolder <= nFolder
\r
1570 Set fo = g_fs.GetFolder( folderPathes(iFolder) )
\r
1571 For Each subf in fo.SubFolders
\r
1572 nFolder = nFolder + 1
\r
1573 ReDim Preserve folderPathes(nFolder)
\r
1574 folderPathes(nFolder) = subf.Path
\r
1576 iFolder = iFolder + 1
\r
1579 ' Remove read only attribute of all files in sub folders
\r
1580 For iFolder = 1 To nFolder
\r
1581 Set fo = g_fs.GetFolder( folderPathes(iFolder) )
\r
1582 For Each f in fo.Files
\r
1583 Set file = g_fs.GetFile( f.Path )
\r
1584 If g_debug_or_test Then g_AppKey.BreakByPath( f.Path )
\r
1585 file.Attributes = file.Attributes And Not ReadOnly
\r
1591 Dim i_retry '// 1
\89ñ
\96Ú
\82É E_WriteAccessDenied
\82É
\82È
\82é
\82±
\82Æ
\82ª
\82½
\82Ü
\82É
\82 \82é
\82½
\82ß
\r
1592 For i_retry = 1 To 2
\r
1593 On Error Resume Next
\r
1594 g_fs.DeleteFolder( Path )
\r
1595 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
1596 If i_retry >= 2 and en <> E_WriteAccessDenied Then
\r
1597 If en = E_WriteAccessDenied Then ed = "Denied to delete the folder: "+ Path
\r
1598 If en <> 0 Then Err.Raise en,,ed
\r
1600 If en = 0 Then Exit For
\r
1602 echo_r "<WARNING msg='" & ed & "' msg2='
\8dÄ
\8e\8e\8ds
\82µ
\82Ä
\82¢
\82Ü
\82·'/>", ""
\r
1603 Sleep g_FileSystemRetryMSec
\r
1609 '********************************************************************************
\r
1610 ' <<< [exist] >>>
\r
1611 '********************************************************************************
\r
1612 Function exist( ByVal path )
\r
1613 If IsWildcard( path ) Then
\r
1614 Dim folder, fnames()
\r
1615 ExpandWildcard path, F_File or F_Folder, folder, fnames
\r
1616 exist = UBound( fnames ) <> -1
\r
1618 exist = ( g_fs.FileExists( path ) = True ) Or ( g_fs.FolderExists( path ) = True )
\r
1624 '********************************************************************************
\r
1625 ' <<< [fc] file compare as binary >>>
\r
1627 ' - return : True=same, False=different
\r
1628 '********************************************************************************
\r
1629 Function fc( path_a, path_b )
\r
1630 fc = fc_r( path_a, path_b, "" )
\r
1635 '********************************************************************************
\r
1636 ' <<< [fc_r] file compare as binary >>>
\r
1638 ' - return : True=same, False=different
\r
1639 '********************************************************************************
\r
1640 Function fc_r( path_a, path_b, redirect_path )
\r
1641 Dim opt : Set opt = new fc_option : ErrCheck
\r
1643 opt.m_RedirectPath = redirect_path
\r
1644 fc_r = fc_ex( path_a, path_b, opt )
\r
1648 '********************************************************************************
\r
1649 ' <<< [fc_ex] file compare as binary >>>
\r
1650 '********************************************************************************
\r
1651 Function fc_ex( PathA, PathB, Opt )
\r
1652 Dim cmdline, opt_echo, redirect_path, b_stdout
\r
1656 '//=== set cmdline from Opt.m_IniPath
\r
1657 cmdline = """" + g_vbslib_ver_folder + "feq.exe"""
\r
1658 If not IsEmpty( Opt ) Then
\r
1659 If not IsEmpty( Opt.m_IniPath ) Then
\r
1660 cmdline = cmdline + " /ini:""" + Opt.m_IniPath + """"
\r
1661 opt_echo = " /ini:" + g_fs.GetFileName( Opt.m_IniPath )
\r
1664 cmdline = cmdline + " """ + PathA + """ """ + PathB + """"
\r
1667 '//=== set redirect_path from Opt.m_RedirectPath
\r
1668 If not IsEmpty( Opt ) Then
\r
1669 redirect_path = Opt.m_RedirectPath
\r
1670 b_stdout = Opt.m_bStdOut
\r
1675 b = True : If Not IsEmpty( Opt ) Then b = (Opt.m_RedirectPath = "")
\r
1676 If b Then '// IsEmpty or
\r
1677 echo ">fc " + opt_echo + " """ + PathA + """ """ + PathB + """"
\r
1679 Dim f : Set f = g_fs.OpenTextFile( redirect_path, 8, True, False )
\r
1680 f.WriteLine ">fc " + opt_echo + " """ + PathA + """ """ + PathB + """"
\r
1687 chk_exist_in_lib "feq.exe"
\r
1688 Set ex = g_sh.Exec( cmdline )
\r
1689 If not IsEmpty( redirect_path ) Then redirect_path = g_sh.ExpandEnvironmentStrings( redirect_path )
\r
1690 fc_ex = ( WaitForFinishAndRedirect( ex, redirect_path ) = 0 )
\r
1695 '********************************************************************************
\r
1696 ' <<< [fc_option] >>>
\r
1697 '********************************************************************************
\r
1700 Public m_RedirectPath
\r
1706 '********************************************************************************
\r
1707 ' <<< [find] find lines including keyword >>>
\r
1708 '********************************************************************************
\r
1709 Function find( ByVal keyword, ByVal path )
\r
1711 Set f = g_fs.OpenTextFile( path )
\r
1714 Do Until f.AtEndOfStream
\r
1716 If InStr( line, keyword ) > 0 Then ret = ret + line
\r
1726 '********************************************************************************
\r
1727 ' <<< [find_c] find lines count including keyword >>>
\r
1728 '********************************************************************************
\r
1729 Function find_c( ByVal keyword, ByVal path )
\r
1731 Set f = g_fs.OpenTextFile( path )
\r
1734 Do Until f.AtEndOfStream
\r
1736 If InStr( line, keyword ) > 0 Then ret = ret + 1
\r
1746 '********************************************************************************
\r
1748 '********************************************************************************
\r
1749 Sub grep( Keyword, FolderPath, OutFName, Opt )
\r
1750 Dim ds_:Set ds_= New CurDirStack : ErrCheck
\r
1751 del "_grep_out.txt"
\r
1753 del "_grep_out.txt"
\r
1754 RunProg "cmd /C for /R %i in (*) do find """ + Keyword + """ ""%i"" >> _grep_out.txt", ""
\r
1756 move FolderPath + "\_grep_out.txt", "."
\r
1757 If OutFName <> "_grep_out.txt" Then ren "_grep_out.txt", OutFName
\r
1762 '********************************************************************************
\r
1764 '********************************************************************************
\r
1765 Sub sort( InPath, OutPath )
\r
1766 RunProg "cmd /C sort """ + InPath + """ /o """ + OutPath + """", ""
\r
1771 '********************************************************************************
\r
1772 ' <<< [CreateFile] Create 1 line text file >>>
\r
1773 '********************************************************************************
\r
1774 Function CreateFile( ByVal Path, ByVal Text )
\r
1777 t = InStr( Text, vbCRLF )
\r
1778 If t = 0 Then t = Text+"""" Else t = Left( Text, t-1 ) + """+vbCRLF+..."
\r
1779 echo ">CreateFile """ & Path & """, """ & t
\r
1781 If IsWildcard( Path ) Then Path = GetTempPath( Path ) : echo "Create """ & Path & """"
\r
1783 Dim ec : Set ec = new EchoOff : ErrCheck
\r
1785 g_AppKey.AddNewWritableFolder Path
\r
1787 Path = g_fs.GetAbsolutePathName( Path )
\r
1788 folder = g_fs.GetParentFolderName( Path )
\r
1791 Set t = g_fs.CreateTextFile( Path, True, (g_TextFileCreateFormat = F_Unicode) )
\r
1800 '********************************************************************************
\r
1801 ' <<< [ReadFile] >>>
\r
1802 '********************************************************************************
\r
1803 Function ReadFile( Path )
\r
1808 On Error Resume Next
\r
1809 Set f = g_fs.OpenTextFile( Path, 1, False, -2 )
\r
1810 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
1811 If en = E_FileNotExist Then Exit Function
\r
1812 If en <> 0 Then Err.Raise en,,ed
\r
1814 ReadFile = ReadAll( f )
\r
1819 '********************************************************************************
\r
1820 ' <<< [type_] >>>
\r
1821 '********************************************************************************
\r
1823 echo ">type_ """ & Path & """"
\r
1824 echo ReadFile( Path )
\r
1829 '********************************************************************************
\r
1830 ' <<< [OpenForRead] >>>
\r
1831 '********************************************************************************
\r
1832 Function OpenForRead( Path )
\r
1833 echo ">OpenForRead """ & Path & """"
\r
1836 On Error Resume Next
\r
1837 Set OpenForRead = g_fs.OpenTextFile( Path,,,-2 )
\r
1838 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
1839 If en = E_FileNotExist or en = E_PathNotFound Then Err.raise en,,ed+" : "+Path
\r
1840 If en <> 0 Then Err.Raise en,,ed
\r
1845 '********************************************************************************
\r
1846 ' <<< [OpenForWrite] >>>
\r
1847 '********************************************************************************
\r
1848 Const F_Shift_JIS = &h1000
\r
1849 Const F_Unicode = 2
\r
1850 Const F_Append = 4
\r
1852 Function OpenForWrite( ByVal Path, Flags )
\r
1853 echo ">OpenForWrite """ & Path & """"
\r
1855 Dim bUnicode : bUnicode = ((Flags and F_Unicode) = F_Unicode)
\r
1856 Dim bAppend : bAppend = ((Flags and F_Append) = F_Append)
\r
1857 If ( Flags and (F_Shift_JIS or F_Unicode) ) = 0 Then _
\r
1858 bUnicode = (g_TextFileCreateFormat = F_Unicode)
\r
1860 If IsWildcard( Path ) Then Path = GetTempPath( Path ) : echo "Create """ & Path & """"
\r
1862 g_AppKey.AddNewWritableFolder Path
\r
1864 On Error Resume Next
\r
1866 Set OpenForWrite = g_fs.OpenTextFile( Path, 8, True, -2 )
\r
1868 Set OpenForWrite = g_fs.CreateTextFile( Path, True, bUnicode )
\r
1870 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
1872 If en = E_PathNotFound Then
\r
1873 Dim fo : fo = g_fs.GetParentFolderName( Path )
\r
1874 If not g_fs.FolderExists( fo ) Then
\r
1876 On Error Resume Next
\r
1877 Set OpenForWrite = g_fs.CreateTextFile( Path, True, bUnicode )
\r
1878 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
1881 If en <> 0 Then Err.Raise en,,ed
\r
1886 '********************************************************************************
\r
1887 ' <<< [GetTempPath] >>>
\r
1888 '********************************************************************************
\r
1889 Class TempFileClass
\r
1890 Public m_FolderPath
\r
1891 Public m_LimitDate
\r
1897 Function GetTempPath( Param )
\r
1898 Dim param_abs, path, t, i, fo, f
\r
1900 GetObject_g_TempFile
\r
1902 '//=== Delete old files
\r
1903 g_AppKey.AddNewWritableFolder g_TempFile.m_FolderPath + "\."
\r
1904 If not g_fs.FolderExists( g_TempFile.m_FolderPath ) Then _
\r
1905 mkdir g_TempFile.m_FolderPath
\r
1907 Set fo = g_fs.GetFolder( g_TempFile.m_FolderPath )
\r
1908 For Each f in fo.Files
\r
1909 If f.DateLastModified < g_TempFile.m_LimitDate Then
\r
1910 g_fs.DeleteFile f.Path
\r
1913 For Each f in fo.SubFolders
\r
1914 If f.DateLastModified < g_TempFile.m_LimitDate Then
\r
1915 g_fs.DeleteFolder f.Path
\r
1920 '//=== path : Make unique path
\r
1922 param_abs = GetAbsPath( Param, g_TempFile.m_FolderPath +"\"+ _
\r
1923 Right( "0" & (Year(t) mod 100), 2 ) & _
\r
1924 Right( "0" & Month(t), 2 ) & Right( "0" & Day(t), 2 ) )
\r
1926 t = Right( "0" & (Year(t) mod 100), 2 ) & _
\r
1927 Right( "0" & Month(t), 2 ) & Right( "0" & Day(t), 2 ) & "_" & _
\r
1928 Right( "0" & Hour(t), 2 ) & Right( "0" & Minute(t), 2 ) & "_"
\r
1931 path = Replace( param_abs, "*", t & i )
\r
1932 If not exist( path ) Then Exit Do
\r
1934 If InStr( param_abs, "*" ) = 0 Then Exit Do
\r
1936 GetTempPath = path
\r
1941 '********************************************************************************
\r
1942 ' <<< [GetObject_g_TempFile] >>>
\r
1943 '********************************************************************************
\r
1944 Sub GetObject_g_TempFile()
\r
1945 If IsEmpty( g_TempFile ) Then
\r
1946 Set g_TempFile = new TempFileClass : ErrCheck
\r
1947 If IsDefined( "Setting_getTemp" ) Then
\r
1949 Setting_getTemp out1, out2
\r
1950 g_TempFile.m_FolderPath = out1
\r
1951 g_TempFile.m_LimitDate = out2
\r
1954 If IsEmpty( g_TempFile.m_FolderPath ) Then _
\r
1955 g_TempFile.m_FolderPath = env( "%Temp%\Report" )
\r
1956 If IsEmpty( g_TempFile.m_LimitDate ) Then _
\r
1957 g_TempFile.m_LimitDate = DateAdd( "d", -2, Now() )
\r
1959 If InStr( g_TempFile.m_FolderPath, "Temp" ) = 0 Then
\r
1960 echo "Not found ""Temp"" in temporary folder path in %Temp% or Setting_getTemp."
\r
1961 echo "Is this temporary folder path to delete? : " + g_TempFile.m_FolderPath
\r
1962 echo "
\82±
\82ê
\82Í
\8dí
\8f\9c\82µ
\82Ä
\82à
\82æ
\82¢
\88ê
\8e\9e\83t
\83H
\83\8b\83_
\82Ì
\83p
\83X
\82Å
\82·
\82©
\81H : " + g_TempFile.m_FolderPath
\r
1969 '********************************************************************************
\r
1970 ' <<< [ReadAll] >>>
\r
1971 '********************************************************************************
\r
1972 Function ReadAll( FileStream )
\r
1976 On Error Resume Next
\r
1977 ReadAll = FileStream.ReadAll
\r
1978 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
1979 If en = E_EndOfFile Then en = 0
\r
1980 If en <> 0 Then Err.Raise en,,ed
\r
1985 '********************************************************************************
\r
1986 ' <<< [Txt2BinTxt] >>>
\r
1987 '********************************************************************************
\r
1988 Sub Txt2BinTxt( SrcPath, DstPath )
\r
1990 Dim txt2bintxt_exe : txt2bintxt_exe = g_vbslib_ver_folder + "txt2bintxt.exe"
\r
1992 If not g_fs.FileExists( txt2bintxt_exe ) Then _
\r
1993 Err.Raise 1,, "not found txt2bintxt.exe in vbslib folder"
\r
1995 r = RunProg( """"+txt2bintxt_exe+""" """+SrcPath+""" """+DstPath+"""", Empty )
\r
1996 If r<>0 Then Err.Raise 1,, "error 0x" & Hex(r) & " in txt2bintxt.exe"
\r
2001 '********************************************************************************
\r
2002 ' <<< [WriteVBSLibHeader] >>>
\r
2003 '********************************************************************************
\r
2004 Sub WriteVBSLibHeader( OutFileStream, Opt )
\r
2007 Set f = g_fs.OpenTextFile( WScript.ScriptFullName )
\r
2008 Do Until f.AtEndOfStream
\r
2012 If InStr( line, "g_CommandPrompt =" ) > 0 and not IsEmpty( Opt ) Then
\r
2013 If not IsEmpty( Opt.m_OverCommandPrompt ) Then
\r
2014 line = " g_CommandPrompt = " & Opt.m_OverCommandPrompt
\r
2017 If InStr( line, "main()" ) > 0 Then Exit Do
\r
2018 If InStr( line, "main2(" ) > 0 Then Exit Do
\r
2020 OutFileStream.WriteLine line
\r
2025 Class WriteVBSLibHeader_Option
\r
2026 Public m_OverCommandPrompt
\r
2031 '********************************************************************************
\r
2032 ' <<< [GetAbsPath] >>>
\r
2033 '********************************************************************************
\r
2034 Function GetAbsPath( StepPath, ByVal BasePath )
\r
2035 Dim i, ii, i3, sep_ch, path
\r
2038 If IsEmpty( BasePath ) Then BasePath = g_sh.CurrentDirectory
\r
2039 If IsAbsPath( StepPath ) Then BasePath = Empty
\r
2042 '//=== sep_ch = separetor "\" or "/"
\r
2043 If IsEmpty( BasePath ) Then
\r
2044 i = InStr( StepPath, "\" )
\r
2045 ii = InStr( StepPath, "/" )
\r
2047 i = InStr( BasePath, "\" )
\r
2048 ii = InStr( BasePath, "/" )
\r
2052 If i > ii Then sep_ch = "/" Else sep_ch = "\"
\r
2057 If ii > 0 Then sep_ch = "/" Else sep_ch = "\"
\r
2059 '(debug point) watch "sep_ch"
\r
2062 '//=== Joint and Replace to sep_ch
\r
2063 If Right( BasePath, 1 ) = sep_ch or IsEmpty( BasePath ) Then
\r
2064 path = BasePath + StepPath
\r
2066 path = BasePath + sep_ch + StepPath
\r
2068 If sep_ch = "\" Then
\r
2069 path = Replace( path, "/", "\" )
\r
2071 path = Replace( path, "\", "/" )
\r
2073 '(debug point) watch "path"
\r
2077 i_root = InStr( path, sep_ch )
\r
2078 If Mid( path, i_root+1, 1 ) = sep_ch Then
\r
2079 i = InStr( i_root+2, path, sep_ch )
\r
2083 path = path + sep_ch
\r
2084 i_root = Len( path ) + 1
\r
2091 i = InStr( path, sep_ch+"."+sep_ch )
\r
2092 If i = 0 Then Exit Do
\r
2093 path = Left( path, i ) + Mid( path, i+3 )
\r
2095 If Right( path, 2 ) = sep_ch+"." Then path = Left( path, Len(path)-2 )
\r
2098 '//=== Cut xxx\..\
\r
2100 i = InStr( path, sep_ch+".."+sep_ch )
\r
2101 If i = 0 Then Exit Do
\r
2104 ii = InStr( i3+1, path, sep_ch )
\r
2105 If ii = 0 Then Exit Do
\r
2107 If i = i_root Then
\r
2108 path = Left( path, i ) + Mid( path, i+4 ) '// Cut "\..\"
\r
2110 path = Left( path, i3 ) + Mid( path, i+4 ) '// Cut xxx\..\
\r
2120 If Right( path, 3 ) = sep_ch+".." Then
\r
2121 i = Len( path ) - 2
\r
2122 If i = i_root Then
\r
2123 path = Left( path, i )
\r
2125 i = InStrRev( path, sep_ch, i-1 )
\r
2126 If i = i_root Then
\r
2127 path = Left( path, i )
\r
2129 path = Left( path, i-1 )
\r
2135 If Right( path, 1 ) = ":" Then path = path + sep_ch
\r
2138 '(debug point) watch "path"
\r
2145 '********************************************************************************
\r
2146 ' <<< [GetStepPath] >>>
\r
2147 ' - AbsPath, BasePath, (return) as string
\r
2148 '********************************************************************************
\r
2149 Function GetStepPath( AbsPath, BasePath )
\r
2150 Dim AbsPathU, BasePathU, path, sep_ch, i, ii
\r
2152 AbsPathU = UCase(AbsPath)
\r
2153 If IsEmpty( BasePath ) Then
\r
2154 BasePathU = UCase(g_sh.CurrentDirectory)
\r
2156 BasePathU = UCase(BasePath)
\r
2160 '// sep_ch = separetor "\" or "/"
\r
2161 i = InStr( AbsPath, "\" )
\r
2162 ii = InStr( AbsPath, "/" )
\r
2165 If i > ii Then sep_ch = "/" Else sep_ch = "\"
\r
2170 If ii > 0 Then sep_ch = "/" Else sep_ch = "\"
\r
2172 '(debug point) watch "sep_ch"
\r
2175 '// path = common parent folder path. The last character is not sep_ch
\r
2177 If Right( BasePathU, 1 ) = sep_ch Then path = Left( BasePathU, Len(BasePathU)-1 )
\r
2179 If path = Left( AbsPathU, Len(path) ) Then Exit Do
\r
2180 path = g_fs.GetParentFolderName( path )
\r
2182 If path = "" Then GetStepPath = AbsPath : Exit Function
\r
2183 If Right( path, 1 ) = sep_ch Then path = Left( path, Len(path)-1 )
\r
2184 '(debug point) watch "path"
\r
2187 '// GetStepPath = step path without ..\
\r
2188 GetStepPath = Mid( AbsPath, Len(path) + 2 )
\r
2189 '(debug point) watch "GetStepPath"
\r
2192 '// GetStepPath: Add "..\"
\r
2193 path = Mid( BasePath, Len(path) + 2 )
\r
2195 If path = "" Then Exit Do
\r
2196 path = g_fs.GetParentFolderName( path )
\r
2197 GetStepPath = ".." + sep_ch + GetStepPath
\r
2199 '(debug point) watch "GetStepPath"
\r
2202 If GetStepPath = "" Then GetStepPath = "."
\r
2207 '********************************************************************************
\r
2208 ' <<< [GetParentAbsPath] >>>
\r
2209 '********************************************************************************
\r
2210 Function GetParentAbsPath( Path )
\r
2211 GetParentAbsPath = g_fs.GetParentFolderName( g_fs.GetAbsolutePathName( Path ) )
\r
2216 '********************************************************************************
\r
2217 ' <<< [IsAbsPath] >>>
\r
2218 '********************************************************************************
\r
2219 Function IsAbsPath( Path )
\r
2220 Dim bs : bs = InStr( Path, "\" )
\r
2221 Dim sl : sl = InStr( Path, "/" )
\r
2222 Dim co : co = InStr( Path, ":" )
\r
2224 IsAbsPath = ( co > 0 and ( bs = co+1 or sl = co+1 ) )
\r
2228 '********************************************************************************
\r
2229 ' <<< [FindParent] >>>
\r
2230 '********************************************************************************
\r
2231 Function FindParent( TargetStepPath, StartFolderPath )
\r
2232 Dim base : base = GetAbsPath( StartFolderPath, Empty )
\r
2236 path = base + "\" + TargetStepPath
\r
2237 If g_fs.FileExists( path ) or g_fs.FolderExists( path ) Then Exit Do
\r
2238 base = g_fs.GetParentFolderName( base )
\r
2239 If base = "" Then Raise E_PathNotFound, _
\r
2240 "<ERROR msg='No FindParent' target='" + TargetStepPath + "'/>"
\r
2248 '********************************************************************************
\r
2249 ' <<< [GetTagJumpPath] >>>
\r
2250 '********************************************************************************
\r
2251 Function GetTagJumpPath( PathAndLine )
\r
2252 Dim i : i = InStrRev( PathAndLine, "(" )
\r
2254 GetTagJumpPath = Left( PathAndLine, i-1 )
\r
2256 GetTagJumpPath = PathAndLine
\r
2261 '********************************************************************************
\r
2262 ' <<< [IsWildcard] >>>
\r
2263 '********************************************************************************
\r
2264 Function IsWildcard( ByVal path )
\r
2265 IsWildcard = InStr( path, "?" ) <> 0 Or InStr( path, "*" ) <> 0
\r
2270 '********************************************************************************
\r
2271 ' <<< [ExpandWildcard] >>>
\r
2272 '********************************************************************************
\r
2273 Sub ExpandWildcard( ByVal wildcard_path, flags, folder, fnames )
\r
2276 folder = g_fs.GetParentFolderName( g_fs.GetAbsolutePathName( wildcard_path ) )
\r
2278 Set re = CreateObject("VBScript.RegExp")
\r
2280 s = g_fs.GetFileName( wildcard_path )
\r
2281 re.Pattern = "\\" : s = re.Replace( s, "\\" )
\r
2282 re.Pattern = "\." : s = re.Replace( s, "\." )
\r
2283 re.Pattern = "\$" : s = re.Replace( s, "\$" )
\r
2284 re.Pattern = "\^" : s = re.Replace( s, "\^" )
\r
2285 re.Pattern = "\{" : s = re.Replace( s, "\{" )
\r
2286 re.Pattern = "\}" : s = re.Replace( s, "\}" )
\r
2287 re.Pattern = "\[" : s = re.Replace( s, "\[" )
\r
2288 re.Pattern = "\]" : s = re.Replace( s, "\]" )
\r
2289 re.Pattern = "\(" : s = re.Replace( s, "\(" )
\r
2290 re.Pattern = "\)" : s = re.Replace( s, "\)" )
\r
2291 re.Pattern = "\|" : s = re.Replace( s, "\|" )
\r
2292 re.Pattern = "\+" : s = re.Replace( s, "\+" )
\r
2293 re.Pattern = "\*" : s = re.Replace( s, ".*" )
\r
2294 re.Pattern = "\?" : s = re.Replace( s, "." )
\r
2296 re.Pattern = "^" + s
\r
2297 If Left( re.Pattern, 3 ) = "^.*" Then re.Pattern = Mid( re.Pattern, 4 )
\r
2299 re.IgnoreCase = True
\r
2300 ReDim fnames( -1 )
\r
2302 ExpandWildcard_sub re, flags, folder, "", fnames
\r
2306 Sub ExpandWildcard_sub( re, flags, folder, step_folder, fnames )
\r
2309 If not g_fs.FolderExists( folder ) Then
\r
2310 Raise E_PathNotFound, "<ERROR msg='Not found folder' jp='
\83t
\83H
\83\8b\83_
\82ª
\8c©
\82Â
\82©
\82è
\82Ü
\82¹
\82ñ' " +_
\r
2311 "path='"+ folder +"'/>"
\r
2314 Set fo = g_fs.GetFolder( folder )
\r
2315 If flags And F_File Then
\r
2316 For Each f in fo.Files
\r
2317 If re.Test( f.Name ) Then
\r
2318 ReDim Preserve fnames( UBound(fnames) + 1 )
\r
2319 fnames( UBound(fnames) ) = step_folder + f.Name
\r
2323 If flags And F_Folder Then
\r
2324 For Each f in fo.SubFolders
\r
2325 If re.Test( f.Name ) Then
\r
2326 ReDim Preserve fnames( UBound(fnames) + 1 )
\r
2327 fnames( UBound(fnames) ) = step_folder + f.Name
\r
2332 If flags And F_SubFolder Then
\r
2333 For Each f in fo.SubFolders
\r
2334 ExpandWildcard_sub re, flags, f.Path, step_folder + f.Name + "\", fnames
\r
2341 '********************************************************************************
\r
2342 ' <<< [GetSubFolders] >>>
\r
2344 ' - folders : (out) array of folder pathes
\r
2345 ' - path : base folder path
\r
2346 '********************************************************************************
\r
2347 Sub GetSubFolders( folders, ByVal path )
\r
2349 EnumSubFolders folders, g_fs.GetFolder( path )
\r
2352 Sub EnumSubFolders( folders, fo )
\r
2355 ReDim Preserve folders( UBound(folders) + 1 )
\r
2356 folders( UBound(folders) ) = fo.Path
\r
2358 For Each subfo in fo.SubFolders
\r
2359 EnumSubFolders folders, subfo
\r
2365 '********************************************************************************
\r
2366 ' <<< [EnumFolderObject] >>>
\r
2368 ' out_Folders as Folder
\r
2369 ' FolderPath as string
\r
2371 ' For Each fo In folders
\r
2372 ' For Each f In fo.Files
\r
2373 ' n = f.DateLastModified
\r
2376 '********************************************************************************
\r
2377 Sub EnumFolderObject( FolderPath, out_Folders )
\r
2378 Dim i_set, i_get, n, f
\r
2380 ReDim out_Folders(0)
\r
2381 Set out_Folders(0) = g_fs.GetFolder( FolderPath )
\r
2382 i_set = 1 : i_get = 0
\r
2384 While i_get <= UBound( out_Folders )
\r
2385 n = out_Folders( i_get ).SubFolders.Count
\r
2386 ReDim Preserve out_Folders( UBound( out_Folders ) + n )
\r
2387 For Each f In out_Folders( i_get ).SubFolders
\r
2388 Set out_Folders( i_set ) = f
\r
2397 '********************************************************************************
\r
2398 ' <<< [RemoveWildcard] >>>
\r
2399 '********************************************************************************
\r
2400 Sub RemoveWildcard( WildCard, fnames )
\r
2401 Dim s, path, fname, i, n, wc, wc_len
\r
2404 '//=== check by with wildcard
\r
2405 If Left( WildCard, 1 ) = "*" Then
\r
2406 wc = LCase( Mid( WildCard, 2 ) ) : wc_len = Len( wc )
\r
2407 n = UBound( fnames )
\r
2411 fname = g_fs.GetFileName( path )
\r
2412 If LCase( Right( fname, wc_len ) ) = wc Then fnames(i) = Empty : Exit Do
\r
2413 path = g_fs.GetParentFolderName( path )
\r
2414 If path = "" Then Exit Do
\r
2419 '//=== check by no wildcard
\r
2421 wc = LCase( WildCard )
\r
2422 n = UBound( fnames )
\r
2426 fname = g_fs.GetFileName( path )
\r
2427 If LCase( fname ) = wc Then fnames(i) = Empty : Exit Do
\r
2428 path = g_fs.GetParentFolderName( path )
\r
2429 If path = "" Then Exit Do
\r
2435 '//=== shrink the array
\r
2437 For i = 0 To UBound( fnames )
\r
2438 If not IsEmpty( fnames(i) ) Then fnames(n) = fnames(i) : n = n + 1
\r
2440 Redim Preserve fnames( n - 1 )
\r
2445 '********************************************************************************
\r
2446 ' <<< [MeltCSV] >>>
\r
2447 '********************************************************************************
\r
2448 Function MeltCSV( Line, in_out_Start )
\r
2453 If i=0 Then Exit Function
\r
2456 '//=== Skip space character
\r
2458 c = Mid( Line, i, 1 )
\r
2459 If c<>" " and c<>vbTab Then Exit Do
\r
2465 '//=== If enclosed by " "
\r
2469 c = Mid( Line, i, 1 )
\r
2470 If c = "" Then Exit Do
\r
2473 c = Mid( Line, i, 1 )
\r
2474 If c = """" Then s = s + c Else Exit Do
\r
2483 If c = "" Then in_out_Start = 0 : Exit Function
\r
2484 If c = "," Then in_out_Start = i+1 : Exit Function
\r
2486 c = Mid( Line, i, 1 )
\r
2490 '//=== If no value
\r
2492 in_out_Start = i+1 : Exit Function
\r
2494 in_out_Start = 0 : Exit Function
\r
2497 '//=== If NOT enclosed by " "
\r
2500 If c = "" or c = "," Then Exit Do
\r
2503 c = Mid( Line, i, 1 )
\r
2506 MeltCSV = Trim( s )
\r
2508 If c = "" Then in_out_Start = 0 : Exit Function
\r
2509 If c = "," Then in_out_Start = i+1 : Exit Function
\r
2515 '********************************************************************************
\r
2516 ' <<< [CSVText] >>>
\r
2517 '********************************************************************************
\r
2518 Function CSVText( s )
\r
2519 If InStr( s, """" ) = 0 and InStr( s, "," ) = 0 and InStr( s, vbCRLF ) = 0 and _
\r
2520 Left( s, 1 ) <> " " and Right( s, 1 ) <> " " Then CSVText = s : Exit Function
\r
2521 CSVText = """" + Replace( s, """", """""" ) + """"
\r
2524 '********************************************************************************
\r
2525 ' <<< [XmlAttr] >>>
\r
2526 '********************************************************************************
\r
2527 Function XmlAttr( ByVal s )
\r
2528 s = Replace( s, "<", "<" )
\r
2529 s = Replace( s, """", """ )
\r
2530 '// s = Replace( s, "'", "'" )
\r
2531 XmlAttr = Replace( s, "&", "&" )
\r
2534 '********************************************************************************
\r
2535 ' <<< [XmlText] >>>
\r
2536 '********************************************************************************
\r
2537 Function XmlText( ByVal s )
\r
2538 s = Replace( s, "<", "<" )
\r
2539 s = Replace( s, ">", ">" )
\r
2540 XmlText = Replace( s, "&", "&" )
\r
2543 '********************************************************************************
\r
2544 ' <<< [LoadXML] >>>
\r
2545 '********************************************************************************
\r
2546 Const F_NoRoot = 1
\r
2547 Const F_Str = &h8000
\r
2549 Function LoadXML( PathOrStr, Opt )
\r
2550 Dim xml, r, t, i, c
\r
2551 Const start_tag = "<Dummy_Root_>"
\r
2552 Const end_tag = "</Dummy_Root_>"
\r
2554 If Opt and F_Str Then
\r
2555 i=1 : Do : c = Mid( PathOrStr, i, 1 ) : If c<>" " and c<>vbTab Then Exit Do
\r
2557 If (Opt and F_NoRoot) or c<>"<" Then
\r
2558 t = start_tag + PathOrStr + end_tag
\r
2563 t = ReadFile( PathOrStr )
\r
2564 i=1 : Do : c = Mid( t, i, 1 ) : If c<>" " and c<>vbTab Then Exit Do
\r
2566 If (Opt and F_NoRoot) or c<>"<" Then
\r
2567 t = start_tag + t + end_tag
\r
2571 Set xml = CreateObject("MSXML2.DOMDocument")
\r
2572 r = xml.loadXML( t )
\r
2574 t = start_tag + t + end_tag
\r
2575 r = xml.loadXML( t )
\r
2577 If not r Then Raise 1,"""" + PathOrStr + """
\82ª Unicode
\82Å
\82È
\82¢
\82©
\81A
\90³
\82µ
\82¢ XML
\8c`
\8e®
\82É
\82È
\82Á
\82Ä
\82¢
\82Ü
\82¹
\82ñ"
\r
2578 Set LoadXML = xml.lastChild '// If firstChild, <?xml> may be got.
\r
2582 'Function LoadXML( Path, Opt )
\r
2585 ' If not g_fs.FileExists( Path ) Then Err.Raise 53,,"""" + Path + """
\82ª
\8c©
\82Â
\82©
\82è
\82Ü
\82¹
\82ñ"
\r
2586 ' Set xml = WScript.CreateObject("MSXML2.DOMDocument")
\r
2587 ' r = xml.load( Path )
\r
2588 ' If r=0 Then Err.Raise 53,,"""" + Path + """
\82ª Unicode
\82Å
\82È
\82¢
\82©
\81A
\90³
\82µ
\82¢ XML
\8c`
\8e®
\82Å
\82Í
\82 \82è
\82Ü
\82¹
\82ñ"
\r
2589 ' Set LoadXML = xml.firstChild
\r
2594 '*-------------------------------------------------------------------------*
\r
2595 '* ### <<<< Function call and include >>>>
\r
2596 '*-------------------------------------------------------------------------*
\r
2600 '********************************************************************************
\r
2601 ' <<< [call_vbs] >>>
\r
2602 '********************************************************************************
\r
2603 Function call_vbs( path, func, param )
\r
2604 echo ">call_vbs """ & path & """, " & func
\r
2606 call_vbs = call_vbs_d( path, func, param )
\r
2608 call_vbs = call_vbs_t( path, func, param )
\r
2614 '*-------------------------------------------------------------------------*
\r
2615 '* ### <<<< Support of vbsool >>>>
\r
2616 '*-------------------------------------------------------------------------*
\r
2620 '********************************************************************************
\r
2621 ' <<< [ObjToXML] >>>
\r
2622 '********************************************************************************
\r
2623 Function ObjToXML( TagName, Objs, Opt )
\r
2627 If not IsEmpty( TagName ) Then out = "<" + TagName + ">" + vbCRLF
\r
2628 If IsArray( Objs ) Then
\r
2629 For Each o In Objs : If not IsEmpty(o) Then ObjToXML1 o, out
\r
2631 ElseIf TypeName( Objs ) = "ArrayClass" Then
\r
2632 For Each o In Objs.m_Array : ObjToXML1 o, out : Next
\r
2633 ElseIf IsObject( Objs ) Then
\r
2634 ObjToXML1 Objs, out
\r
2636 If not IsEmpty( TagName ) Then out = out + "</" + TagName + ">" + vbCRLF
\r
2637 ObjToXML = Left( out, Len( out ) - 2 )
\r
2641 Sub ObjToXML1( Obj, Out )
\r
2644 Out = Out + "<" + TypeName( Obj )
\r
2646 On Error Resume Next
\r
2648 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
2649 If en = 0 Then Out = Out + " Name=""" & XmlAttr( Obj.Name ) & """"
\r
2650 If en = 438 Then en = 0
\r
2651 If en <> 0 Then Err.Raise en,,ed
\r
2653 On Error Resume Next
\r
2654 ed = Obj.DefinePath
\r
2655 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
2656 If en = 0 Then Out = Out + " DefinePath=""" & XmlAttr( Obj.DefinePath ) & """"
\r
2657 If en = 438 Then en = 0
\r
2658 If en <> 0 Then Err.Raise en,,ed
\r
2660 Out = Out + "/>" + vbCRLF
\r
2667 '********************************************************************************
\r
2668 ' <<< [get_Object] >>>
\r
2669 '********************************************************************************
\r
2670 Function get_Object( Name )
\r
2673 On Error Resume Next
\r
2674 Dim get_func : Set get_func = GetRef( "get_" + Name )
\r
2675 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
2676 If en = 5 Then Err.Raise en,,ed + " : Not defined 'get_" + Name + "'"
\r
2677 If en <> 0 Then Err.Raise en,,ed
\r
2679 Set get_Object = get_func()
\r
2683 '********************************************************************************
\r
2684 ' <<< [get_ObjectFromFile] >>>
\r
2685 '********************************************************************************
\r
2686 Function get_ObjectFromFile( ModulePath, Name )
\r
2689 g_SrcPath = g_fs.GetAbsolutePathName( ModulePath )
\r
2690 If g_debug Then echo ">include """ + g_SrcPath + """"
\r
2691 Set f = g_fs.OpenTextFile( g_SrcPath )
\r
2693 ExecuteGlobal "'// " + g_SrcPath +vbCRLF+ f.ReadAll()
\r
2695 ExecuteGlobal f.ReadAll()
\r
2698 Dim get_func : Set get_func = GetRef( "get_" + Name )
\r
2699 Set get_ObjectFromFile = get_func()
\r
2704 '********************************************************************************
\r
2705 ' <<< [get_NameDelegator] >>>
\r
2706 '********************************************************************************
\r
2707 Dim g_NameDic : Set g_NameDic = CreateObject( "Scripting.Dictionary" )
\r
2709 Function get_NameDelegator( Name, TrueName, InterfaceName )
\r
2710 If g_NameDic.Exists( Name +"__"+ TrueName ) Then
\r
2711 Set get_NameDelegator = g_NameDic.Item( Name +"__"+ TrueName +"_"+ InterfaceName )
\r
2715 Set get_NameDelegator = new_X( InterfaceName + "_Delegator" ) : With get_NameDelegator
\r
2717 .m_Delegate = TrueName '// if validated was need.
\r
2718 If not g_bNeedValidateDelegate Then _
\r
2719 Set .m_Delegate = get_Object( TrueName ) '// if validated was not need.
\r
2722 Set g_NameDic.Item( Name +"__"+ TrueName +"_"+ InterfaceName ) = get_NameDelegator
\r
2726 Const F_ValidateOnlyDelegate = &h40000000
\r
2727 Dim g_bNeedValidateDelegate
\r
2730 Function NameDelegator_getTrueName( m )
\r
2731 If VarType( m.m_Delegate ) = vbString Then
\r
2732 NameDelegator_getTrueName = m.m_Delegate
\r
2734 NameDelegator_getTrueName = m.m_Delegate.TrueName
\r
2739 Sub NameDelegator_validate( m, Flags )
\r
2740 If VarType( m.m_Delegate ) = vbString Then
\r
2741 Set m.m_Delegate = get_Object( m.m_Delegate )
\r
2743 If ( Flags and F_ValidateOnlyDelegate ) = 0 Then _
\r
2744 m.m_Delegate.Validate Flags
\r
2748 Function NameDelegator_getXML( m )
\r
2749 If VarType( m.m_Delegate ) = vbString Then
\r
2750 NameDelegator_getXML = "<" + TypeName( m ) + _
\r
2751 " Name='" + m.Name + "' TrueName='" + m.TrueName + "'/>"
\r
2753 NameDelegator_getXML = "<" + TypeName( m ) + _
\r
2754 " Name='" + m.Name + "' TrueName='" + m.TrueName + "'>" +vbCRLF+_
\r
2755 m.m_Delegate.xml + vbCRLF + "</" + TypeName( m ) + ">"
\r
2761 '********************************************************************************
\r
2762 ' <<< [new_X] >>>
\r
2763 '********************************************************************************
\r
2764 Function new_X( Name )
\r
2767 On Error Resume Next
\r
2768 Dim new_f : Set new_f = GetRef( "new_" + Name )
\r
2769 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
2770 If en = 5 Then Err.Raise en,,ed + " : Not defined 'new_" + Name + "'"
\r
2771 If en <> 0 Then Err.Raise en,,ed
\r
2773 Set new_X = new_f()
\r
2778 '********************************************************************************
\r
2779 ' <<< [include_objs] >>>
\r
2780 '********************************************************************************
\r
2781 Dim g_included_paths : Set g_included_paths = CreateObject( "Scripting.Dictionary" )
\r
2783 Sub include_objs( Wildcard, Flags, out_GetObjectFuncs )
\r
2784 Dim ds_:Set ds_= new CurDirStack
\r
2785 Dim folder_path, fname_key_s, folders, fo, f, fi, t, en, ed
\r
2786 Dim fname_key : Set fname_key = new StrMatchKey
\r
2788 If g_fs.FolderExists( Wildcard ) Then
\r
2789 folder_path = Wildcard : fname_key_s = "*_obj.vbs"
\r
2791 folder_path = GetParentAbsPath( Wildcard ) : fname_key_s = g_fs.GetFileName( Wildcard )
\r
2793 fname_key.Keyword = LCase( fname_key_s )
\r
2795 ReDim out_GetObjectFuncs(-1)
\r
2797 EnumFolderObject folder_path, folders '// [out] folders
\r
2798 For Each fo In folders
\r
2799 For Each f In fo.Files
\r
2800 If fname_key.IsMatch( f.Name ) Then
\r
2801 g_SrcPath = f.Path
\r
2803 If IsEmpty( g_included_paths.Item( g_SrcPath ) ) Then
\r
2805 If g_debug Then echo ">include """ + f.Path + """"
\r
2807 ExecuteGlobal "Sub get_StaticObjects(a,b) : End Sub"
\r
2809 Set fi = g_fs.OpenTextFile( g_SrcPath )
\r
2810 If g_debug Then t = "'// " + g_SrcPath +vbCRLF+ fi.ReadAll() Else t = fi.ReadAll()
\r
2812 g_sh.CurrentDirectory = fo.Path
\r
2814 If not IsEmpty( g_debug_vbs_path ) and _
\r
2815 InStr( g_SrcPath, g_debug_vbs_path ) > 0 Then
\r
2816 InvestigateInterpretError2 g_SrcPath, en, ed
\r
2818 On Error Resume Next
\r
2819 ExecuteGlobal t '// Interpret g_SrcPath
\r
2820 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
2822 InvestigateInterpretError g_SrcPath, en, ed
\r
2826 ReDim Preserve out_GetObjectFuncs( UBound( out_GetObjectFuncs ) + 1 )
\r
2827 Set out_GetObjectFuncs( UBound( out_GetObjectFuncs ) ) = GetRef( "get_StaticObjects" )
\r
2829 Set g_included_paths.Item( g_SrcPath ) = out_GetObjectFuncs( UBound( out_GetObjectFuncs ) )
\r
2831 ReDim Preserve out_GetObjectFuncs( UBound( out_GetObjectFuncs ) + 1 )
\r
2832 Set out_GetObjectFuncs( UBound( out_GetObjectFuncs ) ) = g_included_paths.Item( g_SrcPath )
\r
2842 '********************************************************************************
\r
2843 ' <<< [get_ObjectsFromFile] >>>
\r
2844 '********************************************************************************
\r
2845 Sub get_ObjectsFromFile( GetObjectFuncs, InterfaceName, out_Objs )
\r
2846 If VarType( GetObjectFuncs ) = vbString Then
\r
2848 include_objs GetObjectFuncs, Empty, create_funcs '// [out] create_funcs
\r
2849 get_ObjectsFromFile_sub create_funcs, InterfaceName, out_Objs
\r
2851 get_ObjectsFromFile_sub GetObjectFuncs, InterfaceName, out_Objs
\r
2855 Sub get_ObjectsFromFile_sub( GetObjectFuncs, InterfaceName, out_Objs )
\r
2858 ReDim out_Objs(-1)
\r
2859 For Each func In GetObjectFuncs
\r
2861 Call func( InterfaceName, objs ) '// [out] objs
\r
2862 AddArrElem out_Objs, objs
\r
2868 '********************************************************************************
\r
2869 ' <<< [get_DefineInfoObject] >>>
\r
2870 '********************************************************************************
\r
2871 Class DefineInfoClass
\r
2875 Sub get_DefineInfoObject( in_out_Object, FullPath )
\r
2876 If not IsEmpty( in_out_Object ) and not g_bInvestigateInterpretError Then _
\r
2877 Raise 1, "2nd execute(include)"
\r
2878 Set in_out_Object = new DefineInfoClass
\r
2879 in_out_Object.FullPath = FullPath
\r
2883 '********************************************************************************
\r
2884 ' <<< [InvestigateInterpretError] >>>
\r
2885 '********************************************************************************
\r
2886 Dim g_debug_vbs_path
\r
2887 Dim g_debug_vbs_err_num
\r
2888 Dim g_bInvestigateInterpretError
\r
2890 Sub InvestigateInterpretError( Path, en, ed )
\r
2894 echo ">InvestigateInterpretError """ + Path + """"
\r
2895 g_bInvestigateInterpretError = True
\r
2897 Set f = g_fs.OpenTextFile( Path ) : t = f.ReadAll() : f.Close
\r
2899 On Error Resume Next
\r
2901 en2 = Err.Number : ed2 = Err.Description : On Error GoTo 0
\r
2904 Err.Raise en,,"<ERROR msg='"+ ed +"' include_path="+vbCRLF+"'"+ g_SrcPath +_
\r
2905 "'"+vbCRLF+"hint='2
\89ñ
\96Ú
\82Ì ExecuteGlobal
\82Å
\82Í
\83G
\83\89\81[
\82ª
\8fo
\82Ü
\82¹
\82ñ
\82Å
\82µ
\82½
\81B"+_
\r
2906 "
\8e\9f\82Ì
\83R
\81[
\83h
\82ð main
\8aÖ
\90\94\82É
\8bL
\8fq
\82µ
\82Ä
\8dÄ
\8eÀ
\8ds
\82µ
\82Ä
\82
\82¾
\82³
\82¢' add_code=" +vbCRLF+_
\r
2907 "'g_debug_vbs_path = """ + Path + """'/>"
\r
2910 echo GetErrStr( en, ed )
\r
2913 '// Try to display error line
\r
2914 RunProg "wscript.exe """ + Path + """", ""
\r
2917 '// Error of Duplicate Name
\r
2918 If en2 = 1041 Then
\r
2919 Err.Raise en,,"<ERROR msg='"+ ed +"' include_path="+vbCRLF+"'"+ g_SrcPath +_
\r
2920 "'"+vbCRLF+"hint='
\8e\9f\82Ì
\83R
\81[
\83h
\82ð main
\8aÖ
\90\94\82É
\8bL
\8fq
\82µ
\82Ä
\8dÄ
\8eÀ
\8ds
\82µ
\82Ä
\82
\82¾
\82³
\82¢' add_code=" +vbCRLF+_
\r
2921 "'g_debug_vbs_path = """ + Path + """ : g_debug_vbs_err_num = 1041'/>"
\r
2925 '// Try to break at error line ([attention] 2nd execute may different behavior)
\r
2926 Set f = g_fs.OpenTextFile( Path ) : t = f.ReadAll() : f.Close
\r
2927 ExecuteGlobal "'// This is 2nd execute(include) from InvestigateInterpretError." +vbCRLF + t
\r
2930 '// This is no new hint
\r
2931 Err.Raise en,,"<ERROR msg='"+ ed +"' include_path="+vbCRLF+"'"+ g_SrcPath + "'/>"
\r
2936 '********************************************************************************
\r
2937 ' <<< [InvestigateInterpretError2] >>>
\r
2938 '********************************************************************************
\r
2939 Sub InvestigateInterpretError2( Path, en, ed )
\r
2942 If g_debug_vbs_err_num = 1041 Then
\r
2944 InvestigateDuplicatedNameError g_SrcPath, en, ed
\r
2946 ElseIf g_debug_vbs_err_num = -1041 Then
\r
2947 Stop ' This is 1st include. Next is ...
\r
2948 g_debug_vbs_err_num = 1041
\r
2949 Set f = g_fs.OpenTextFile( Path ) : t = f.ReadAll() : f.Close
\r
2950 ExecuteGlobal t '// Interpret g_SrcPath
\r
2953 Set f = g_fs.OpenTextFile( Path ) : t = f.ReadAll() : f.Close
\r
2954 ExecuteGlobal t '// Interpret g_SrcPath
\r
2959 '********************************************************************************
\r
2960 ' <<< [InvestigateDuplicatedNameError] >>>
\r
2961 '********************************************************************************
\r
2962 Sub InvestigateDuplicatedNameError( Path, en, ed )
\r
2965 Set f = g_fs.OpenTextFile( Path )
\r
2966 Do Until f.AtEndOfStream
\r
2968 i = InStr( t, "Class" )
\r
2969 If i = 0 Then i = InStr( t, "Dim" )
\r
2973 If Mid(t,i,1)=" " Then Exit Do
\r
2977 If Mid(t,i,1)<>" " Then Exit Do
\r
2984 If not( (c>="A" and c<="Z") or (c>="a" and c<="z") or (c>="0" and c<="9") or c="_" ) Then _
\r
2989 If InStr( t, "Class" ) > 0 Then
\r
2990 c = "Class " + Mid( t, i, j-i ) + " : End Class"
\r
2992 c = "Dim " + Mid( t, i, j-i )
\r
2994 echo ">ExecuteGlobal """ + c + """"
\r
3001 Err.Raise en,,"<ERROR msg='"+ ed +"' include_path="+vbCRLF+"'"+ g_SrcPath +_
\r
3002 "'"+vbCRLF+"hint='2
\89ñ include
\82µ
\82Ä
\82¢
\82é
\89Â
\94\
\90«
\82ª
\82 \82è
\82Ü
\82·
\81B"+_
\r
3003 "
\8e\9f\82Ì
\83R
\81[
\83h
\82ð main
\8aÖ
\90\94\82É
\8bL
\8fq
\82µ
\82Ä
\8dÄ
\8eÀ
\8ds
\82µ
\82Ä
\82
\82¾
\82³
\82¢' add_code=" +vbCRLF+_
\r
3004 "'g_debug_vbs_path = """ + Path + """ : g_debug_vbs_err_num = -1041'/>"
\r
3009 '*-------------------------------------------------------------------------*
\r
3010 '* ### <<<< Process >>>>
\r
3011 '*-------------------------------------------------------------------------*
\r
3015 '********************************************************************************
\r
3016 ' <<< [env] Expand environment strings >>>
\r
3017 '********************************************************************************
\r
3019 If IsEmpty( s ) Then Exit Function '// for avoid to s=""
\r
3021 Dim p1, p2, symbol, value
\r
3024 p1 = InStr( i, s, "%" )
\r
3026 env = env & Mid( s, i )
\r
3029 env = env & Mid( s, i, p1 - i )
\r
3030 p2 = InStr( p1+1, s, "%" )
\r
3034 symbol = Mid( s, p1+1, p2-p1-1 )
\r
3035 value = GetVar( symbol )
\r
3036 If IsEmpty( value ) Then _
\r
3037 Err.Raise E_NotFoundSymbol,, "<ERROR msg='not found var symbol' symbol='"+ symbol +"'/>"
\r
3047 '********************************************************************************
\r
3048 ' <<< [start] >>>
\r
3049 '********************************************************************************
\r
3050 Sub start( cmdline )
\r
3051 echo ">start " & cmdline
\r
3052 cmdline = g_sh.ExpandEnvironmentStrings( cmdline )
\r
3056 On Error Resume Next
\r
3058 g_sh.Run cmdline,, FALSE
\r
3060 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
3061 If en = E_WIN32_FILE_NOT_FOUND Then _
\r
3062 Err.Raise en,,"
\83t
\83@
\83C
\83\8b\82©
\83t
\83H
\83\8b\83_
\82ª
\8c©
\82Â
\82©
\82è
\82Ü
\82¹
\82ñ : " + cmdline
\r
3063 If en <> 0 Then Err.Raise en,,ed
\r
3068 '********************************************************************************
\r
3069 ' <<< [RunProg] >>>
\r
3070 '********************************************************************************
\r
3071 Function RunProg( ByVal cmdline, stdout_stderr_redirect )
\r
3074 '// Set debug mode
\r
3075 If stdout_stderr_redirect = "_debug" Then
\r
3076 dbg_cmd = "cmd /K " : stdout_stderr_redirect = ""
\r
3082 '// Echo command line
\r
3083 echo ">current dir = """ & g_sh.CurrentDirectory & """"
\r
3084 If stdout_stderr_redirect = "" Then
\r
3085 echo ">RunProg " & cmdline
\r
3087 echo ">RunProg " & cmdline+" >> """+stdout_stderr_redirect+""""
\r
3092 cmdline = g_sh.ExpandEnvironmentStrings( cmdline )
\r
3095 '// avoid to stop by StdIn
\r
3096 if ( Left( cmdline, 7 ) = "cscript" ) Then _
\r
3097 cmdline = cmdline + " /GUI_input:1"
\r
3100 '// Create new process
\r
3102 Set ex = g_sh.Exec( cmdline )
\r
3103 stdout_stderr_redirect = g_sh.ExpandEnvironmentStrings( stdout_stderr_redirect )
\r
3104 RunProg = WaitForFinishAndRedirect( ex, stdout_stderr_redirect )
\r
3111 '********************************************************************************
\r
3112 ' <<< [WaitForFinishAndRedirect] >>>
\r
3113 'http://itpro.nikkeibp.co.jp/article/COLUMN/20080805/312155/?ST=develop&P=2
\r
3114 '********************************************************************************
\r
3115 Function WaitForFinishAndRedirect( ex, path )
\r
3119 If g_debug and IsEmpty( g_ChildHead ) Then g_ChildHead = ">|"
\r
3121 If path <> "" and path <> "nul" Then _
\r
3122 Set f = g_fs.OpenTextFile( path, 8, True, False )
\r
3124 Do While ex.Status = 0
\r
3125 If path = "nul" or IsEmpty( path ) Then
\r
3126 Do Until ex.StdOut.AtEndOfStream : ex.StdOut.ReadLine : Loop
\r
3127 Do Until ex.StdErr.AtEndOfStream : ex.StdErr.ReadLine : Loop
\r
3128 ElseIf path = "" Then
\r
3129 EchoStream ex.StdOut, WScript.StdOut, ex, g_ChildHead
\r
3130 EchoStream ex.StdErr, WScript.StdErr, ex, g_ChildHead
\r
3132 Do Until ex.StdOut.AtEndOfStream : f.WriteLine ex.StdOut.ReadLine : Loop
\r
3133 Do Until ex.StdErr.AtEndOfStream : f.WriteLine ex.StdErr.ReadLine : Loop
\r
3137 If path = "nul" or IsEmpty( path ) Then
\r
3138 Do Until ex.StdOut.AtEndOfStream : ex.StdOut.ReadLine : Loop
\r
3139 Do Until ex.StdErr.AtEndOfStream : ex.StdErr.ReadLine : Loop
\r
3140 ElseIf path = "" Then
\r
3141 EchoStream ex.StdOut, WScript.StdOut, ex, g_ChildHead
\r
3142 EchoStream ex.StdErr, WScript.StdErr, ex, g_ChildHead
\r
3144 Do Until ex.StdOut.AtEndOfStream : f.WriteLine ex.StdOut.ReadLine : Loop
\r
3145 Do Until ex.StdErr.AtEndOfStream : f.WriteLine ex.StdErr.ReadLine : Loop
\r
3147 WaitForFinishAndRedirect = ex.ExitCode
\r
3152 '********************************************************************************
\r
3153 ' <<< [EchoStream] echo supported No vbCRLF >>>
\r
3154 '********************************************************************************
\r
3155 Dim g_EchoStreamBuf
\r
3156 Sub EchoStream( StreamIn, StreamOut, ex, Prompt )
\r
3159 Do Until StreamIn.AtEndOfStream
\r
3160 c = StreamIn.Read(1)
\r
3161 If c <> vbCR and c <> vbLF Then
\r
3162 If g_EchoStreamBuf = "" Then StreamOut.Write Prompt
\r
3163 g_EchoStreamBuf = g_EchoStreamBuf + c
\r
3166 '// pause
\82Ì
\82Ý
\91Î
\89\9e\r
3167 If Left( g_EchoStreamBuf, 6 ) = "
\91±
\8ds
\82·
\82é
\82É
\82Í" Then
\r
3169 If g_EchoStreamBuf="
\91±
\8ds
\82·
\82é
\82É
\82Í
\89½
\82©
\83L
\81[
\82ð
\89\9f\82µ
\82Ä
\82
\82¾
\82³
\82¢ . . . " Then i = 1
\r
3170 If g_EchoStreamBuf=Left(g_PauseMsg,g_PauseMsgStone)+"*"+Chr(8) Then i = 3
\r
3171 If g_EchoStreamBuf=g_PauseMsg Then i = 2
\r
3174 If ex.Status = 0 Then
\r
3176 WScript.StdIn.ReadLine '// Waiting Enter from only main process
\r
3178 ex.StdIn.Write vbCR
\r
3181 ex.StdIn.Write vbCRLF
\r
3185 If not IsEmpty( g_Test ) Then g_Test.WriteLogLine g_EchoStreamBuf
\r
3186 g_EchoStreamBuf = ""
\r
3193 StreamOut.Write vbLF
\r
3194 If not IsEmpty( g_Test ) Then g_Test.WriteLogLine g_EchoStreamBuf
\r
3195 g_EchoStreamBuf = ""
\r
3204 '********************************************************************************
\r
3205 ' <<< [ArgumentExist] >>>
\r
3206 '********************************************************************************
\r
3207 Function ArgumentExist( name )
\r
3209 For Each key in WScript.Arguments.Named
\r
3210 If key = name Then ArgumentExist = True : Exit Function
\r
3212 ArgumentExist = False
\r
3217 '********************************************************************************
\r
3218 ' <<< [GetSearchOpenCmdLine] >>>
\r
3219 '********************************************************************************
\r
3220 Function GetSearchOpenCmdLine( PathAndName )
\r
3223 Dim i_sep, i_sharp, i_kakko, name_type, line_num
\r
3224 Const no_name_type = 0, line_type = 2, str_type = 3
\r
3227 '//=== Get path and name
\r
3228 i_sep = InStrRev( PathAndName, "\" )
\r
3229 i_sharp = InStrRev( PathAndName, "#" )
\r
3230 If i_sep >= i_sharp Then '// NoName = (7,5), (0,0), (7,0)
\r
3231 path = PathAndName : name = Empty
\r
3232 Else '// WithName = (5,7), (0,7)
\r
3233 path = Left( PathAndName, i_sharp - 1 )
\r
3234 name = Mid( PathAndName, i_sharp + 1 )
\r
3238 '//=== Get line number
\r
3239 If IsEmpty( name ) and Right( PathAndName, 1 ) = ")" Then
\r
3240 i_kakko = InStrRev( PathAndName, "(" )
\r
3241 line_num = Mid( PathAndName, i_kakko + 1 )
\r
3242 line_num = CInt( Left( line_num, Len( line_num ) - 1 ) )
\r
3243 '// not use TagJumpPath
\r
3244 path = Left( PathAndName, i_kakko - 1 )
\r
3249 path = GetAbsPath( path, Empty )
\r
3250 If not g_fs.FileExists( path ) Then _
\r
3251 Raise E_FileNotExist, "<ERROR msg='
\83t
\83@
\83C
\83\8b\82ª
\8c©
\82Â
\82©
\82è
\82Ü
\82¹
\82ñ' path='"+ path +"'/>"
\r
3254 '//=== Get command line template
\r
3255 If not IsDefined( "Setting_getEditorCmdLine" ) Then
\r
3256 cmd = """C:\Windows\notepad.exe"" ""%1"""
\r
3258 cmd = Setting_getEditorCmdLine( 3 )
\r
3259 name_type = str_type
\r
3260 If InStr( cmd, "%2" ) = 0 Then cmd = Empty
\r
3261 If IsEmpty( cmd ) and ( not IsEmpty( line_num ) or not IsEmpty( name ) ) Then
\r
3262 cmd = Setting_getEditorCmdLine( 2 )
\r
3263 name_type = line_type
\r
3265 If IsEmpty( cmd ) Then
\r
3266 cmd = Setting_getEditorCmdLine( 1 )
\r
3267 name_type = no_name_type
\r
3269 If IsEmpty( cmd ) Then
\r
3270 cmd = Setting_getEditorCmdLine( 0 )
\r
3271 cmd = """" + cmd + """ ""%1"""
\r
3273 If IsEmpty( cmd ) Then
\r
3274 cmd = """C:\Windows\notepad.exe"" ""%1"""
\r
3279 '//=== Replace command line
\r
3280 Select Case name_type
\r
3281 Case str_type : cmd = Replace( cmd, "%2", name )
\r
3283 If IsEmpty( line_num ) Then line_num = GetLineOfSearchOpen( path, name )
\r
3284 cmd = Replace( cmd, "%d", CStr( line_num ) )
\r
3286 GetSearchOpenCmdLine = Replace( cmd, "%1", path )
\r
3290 Function GetLineOfSearchOpen( Path, Name )
\r
3293 Set f = OpenForRead( Path )
\r
3295 Do Until f.AtEndOfStream
\r
3296 line = f.ReadLine()
\r
3297 If InStr( line, Name ) > 0 Then
\r
3298 GetLineOfSearchOpen = i
\r
3304 GetLineOfSearchOpen = 1
\r
3309 '********************************************************************************
\r
3310 ' <<< [GetDiffCmdLine] >>>
\r
3311 '********************************************************************************
\r
3312 Function GetDiffCmdLine( PathA, PathB )
\r
3313 If not IsDefined( "Setting_getDiffCmdLine" ) Then
\r
3314 echo "Diff """ + PathA + """ """ + PathB + """"
\r
3317 cmd = Setting_getDiffCmdLine( 2 )
\r
3318 cmd = Replace( cmd, "%1", GetTagJumpPath( PathA ) )
\r
3319 cmd = Replace( cmd, "%2", GetTagJumpPath( PathB ) )
\r
3320 GetDiffCmdLine = cmd
\r
3325 '********************************************************************************
\r
3326 ' <<< [GetDiffCmdLine3] >>>
\r
3327 '********************************************************************************
\r
3328 Function GetDiffCmdLine3( PathA, PathB, PathC )
\r
3329 If not IsDefined( "Setting_getDiffCmdLine" ) Then
\r
3330 echo "Diff """ + PathA + """ """ + PathB + """"
\r
3333 cmd = Setting_getDiffCmdLine( 3 )
\r
3334 cmd = Replace( cmd, "%1", GetTagJumpPath( PathA ) )
\r
3335 cmd = Replace( cmd, "%2", GetTagJumpPath( PathB ) )
\r
3336 cmd = Replace( cmd, "%3", GetTagJumpPath( PathC ) )
\r
3337 GetDiffCmdLine3 = cmd
\r
3342 '********************************************************************************
\r
3343 ' <<< [GetDiffCmdLineMulti] >>>
\r
3344 '********************************************************************************
\r
3345 Function GetDiffCmdLineMulti( Files )
\r
3348 echo "--------------------------------------------------------"
\r
3349 For i=0 To UBound( Files )
\r
3350 echo (i+1) & ". " & Files(i)(0)
\r
3352 op = CInt2( input( "Select number>" ) ) - 1
\r
3353 echo "--------------------------------------------------------"
\r
3356 Select Case UBound( Files(op)(1) )
\r
3358 Case 1: '// 2 files
\r
3359 GetDiffCmdLineMulti = GetDiffCmdLine( _
\r
3360 GetAbsPath( Files(op)(1)(0) +"\"+ Files(op)(0), Empty ), _
\r
3361 GetAbsPath( Files(op)(1)(1) +"\"+ Files(op)(0), Empty ) )
\r
3363 Case 2: '// 3 files
\r
3364 GetDiffCmdLineMulti = GetDiffCmdLine3( _
\r
3365 GetAbsPath( Files(op)(1)(0) +"\"+ Files(op)(0), Empty ), _
\r
3366 GetAbsPath( Files(op)(1)(1) +"\"+ Files(op)(0), Empty ), _
\r
3367 GetAbsPath( Files(op)(1)(2) +"\"+ Files(op)(0), Empty ) )
\r
3377 '*-------------------------------------------------------------------------*
\r
3378 '* ### <<<< Wait >>>>
\r
3379 '*-------------------------------------------------------------------------*
\r
3383 '********************************************************************************
\r
3384 ' <<< [Sleep] >>>
\r
3385 '********************************************************************************
\r
3386 Sub Sleep( ByVal msec )
\r
3387 echo ">Sleep " & msec
\r
3388 WScript.Sleep msec
\r
3393 '********************************************************************************
\r
3394 ' <<< [WaitForFile] Wait for make the file >>>
\r
3395 '********************************************************************************
\r
3396 Function WaitForFile( Path )
\r
3397 echo ">WaitForFile " & Path
\r
3400 '//=== Wait for file exists
\r
3402 While g_fs.FileExists( Path ) = False
\r
3403 WScript.Sleep 1000
\r
3404 f=f+1 : If f=3 Then WScript.Echo ">WaitForFile " & Path & " ..."
\r
3408 '//=== Open file supported lock
\r
3410 On Error Resume Next
\r
3411 Set f = g_fs.OpenTextFile( Path )
\r
3412 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
3413 If en <> E_WriteAccessDenied Then
\r
3414 If en <> 0 Then Err.Raise en,,ed
\r
3419 '//=== Read file supported lock
\r
3421 On Error Resume Next
\r
3422 WaitForFile = f.ReadLine
\r
3423 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
3424 If en <> E_EndOfFile Then
\r
3425 If en <> 0 Then Err.Raise en,,ed
\r
3433 '//=== Delete file
\r
3435 While g_fs.FileExists( Path )
\r
3436 WScript.Sleep 200 '// Delete may have delay ?
\r
3442 '*-------------------------------------------------------------------------*
\r
3443 '* ### <<<< Sound >>>>
\r
3444 '*-------------------------------------------------------------------------*
\r
3448 '********************************************************************************
\r
3450 '********************************************************************************
\r
3452 Player_validate '// g_Player
\r
3454 With g_Player.m_Obj
\r
3456 '// .PreviewMode = True '// Cannot play movie because WSH does not have window.
\r
3462 '********************************************************************************
\r
3463 ' <<< [SystemSound] >>>
\r
3464 '********************************************************************************
\r
3465 Sub SystemSound( Sound )
\r
3466 Const base = "HKEY_CURRENT_USER\AppEvents\Schemes\Apps\"
\r
3467 Const current = "\.Current\"
\r
3468 Const E_PathNotFound = &h80070002
\r
3470 Dim en,ed, parent, reg_path, file_path
\r
3472 For Each parent In Array( ".Default", "Explorer", "devenv", "dexplore", "sapisvr" )
\r
3473 reg_path = base + parent +"\"+ Sound + current
\r
3474 On Error Resume Next
\r
3475 file_path = env( g_sh.RegRead( reg_path ) )
\r
3476 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
3477 If en = 0 Then Exit For
\r
3478 If en <> E_PathNotFound Then Err.Raise en,,ed
\r
3480 If file_path <> "" and file_path <> reg_path Then Play file_path
\r
3484 '********************************************************************************
\r
3485 ' <<< [WaitForSound] >>>
\r
3486 '********************************************************************************
\r
3487 Sub WaitForSound( Timeout_msec )
\r
3488 Player_validate '// g_Player
\r
3490 Dim i : i = CInt( Timeout_msec / 250 )
\r
3491 If IsEmpty( Timeout_msec ) Then i=9
\r
3492 For i=i To 1 Step -1
\r
3493 If g_Player.m_Obj.PlayState = 1 Then Exit For
\r
3494 If g_Player.m_Obj.PlayState = 10 Then Raise E_PathNotFound, _
\r
3495 "<ERROR msg='Cannot play the file' path='" + g_Player.m_Obj.URL + "'/>"
\r
3497 If IsEmpty( Timeout_msec ) Then i=9
\r
3499 g_Player.m_Obj.Controls.Stop
\r
3502 '********************************************************************************
\r
3503 ' <<< [SetVolume] >>>
\r
3504 '********************************************************************************
\r
3505 Sub SetVolume( Volume )
\r
3506 Player_validate '// g_Player
\r
3507 g_Player.m_Obj.Settings.Volume = Volume
\r
3512 '********************************************************************************
\r
3513 ' <<< [Player_validate] >>>
\r
3514 '********************************************************************************
\r
3515 Sub Player_validate()
\r
3516 If IsEmpty( g_Player ) Then Set g_Player = new Vbslib_Player
\r
3519 Class Vbslib_Player
\r
3522 Private Sub Class_Initialize()
\r
3523 Set m_Obj = CreateObject( "WMPlayer.OCX" )
\r
3524 m_Obj.Settings.Volume = 100
\r
3527 Private Sub Class_Terminate()
\r
3529 For i=1 To 12 '// 12 = 3second for sound effects. Music will stop.
\r
3530 If m_Obj.PlayState = 1 or m_Obj.PlayState = 10 Then Exit For
\r
3539 '*-------------------------------------------------------------------------*
\r
3540 '* ### <<<< Variable, Array and collection >>>>
\r
3541 '*-------------------------------------------------------------------------*
\r
3545 '********************************************************************************
\r
3546 ' <<< [DicItem] >>>
\r
3547 '********************************************************************************
\r
3548 Function DicItem( Dic, Key )
\r
3549 If not Dic.Exists( Key ) Then Exit Function
\r
3550 If IsObject( Dic.Item( Key ) ) Then Set DicItem = Dic.Item( Key ) Else DicItem = Dic.Item( Key )
\r
3555 '********************************************************************************
\r
3556 ' <<< [DicToArr] >>>
\r
3557 '********************************************************************************
\r
3558 Sub DicToArr( Dic, Arr )
\r
3559 Dim keys : keys = Dic.Keys()
\r
3562 ReDim Arr( UBound( keys ) )
\r
3564 For Each key in keys
\r
3565 Set Arr(i) = new DicElem : ErrCheck
\r
3566 Arr(i).m_Key = key
\r
3567 If IsObject( Dic.Item(key) ) Then
\r
3568 Set Arr(i).m_Item = Dic.Item(key)
\r
3570 Arr(i).m_Item = Dic.Item(key)
\r
3582 '********************************************************************************
\r
3583 ' <<< [DicKeyToArr] >>>
\r
3584 '********************************************************************************
\r
3585 Sub DicKeyToArr( Dic, Arr )
\r
3586 Dim keys : keys = Dic.Keys()
\r
3589 ReDim Arr( UBound( keys ) )
\r
3591 For Each key in keys
\r
3599 '********************************************************************************
\r
3600 ' <<< [DicItemToArr] >>>
\r
3601 '********************************************************************************
\r
3602 Sub DicItemToArr( Dic, Arr )
\r
3603 Dim keys : keys = Dic.Keys()
\r
3606 ReDim Arr( UBound( keys ) )
\r
3608 For Each key in keys
\r
3609 If IsObject( Dic.Item(key) ) Then
\r
3610 Set Arr(i) = Dic.Item(key)
\r
3612 Arr(i) = dic.Item(key)
\r
3620 '********************************************************************************
\r
3621 ' <<< [CopyArr] >>>
\r
3622 '********************************************************************************
\r
3623 Sub CopyArr( Dst, Src )
\r
3624 If g_cut_old Then Stop ' Do not Dim a(). Dim a,b : b = Array( 1, 2 ) : a = b
\r
3626 If IsArray( Src ) Then
\r
3629 ReDim Dst( UBound( Src ) )
\r
3630 For i=UBound( Src ) To 0 Step -1
\r
3631 If IsObject( Src(i) ) Then Set Dst(i) = Src(i) Else Dst(i) = Src(i)
\r
3635 If IsObject( Src ) Then Set Dst(0) = Src Else Dst(0) = Src
\r
3640 '********************************************************************************
\r
3641 ' <<< [AddArrElem] >>>
\r
3642 '********************************************************************************
\r
3643 Sub AddArrElem( Dst, Src )
\r
3644 If TypeName( Dst ) = "Dictionary" Then
\r
3647 If IsArray( Src ) Then
\r
3648 For Each obj In Src : If not IsEmpty( obj ) Then
\r
3649 If IsObject( obj ) Then Set Dst.Item( obj.Name ) = obj Else Dst.Item( obj ) = True
\r
3651 ElseIf TypeName( Src ) = "Dictionary" Then
\r
3652 For Each key In Src.Keys()
\r
3653 If IsObject( Src.Item( key ) ) Then
\r
3654 Set Dst.Item( key ) = Src.Item( key )
\r
3656 Dst.Item( key ) = Src.Item( key )
\r
3660 If IsObject( Src ) Then Set Dst.Item( Src.Name ) = Src Else Dst.Item( Src.Name ) = True
\r
3665 n = UBound( Dst ) + 1
\r
3666 If IsArray( Src ) Then
\r
3667 ReDim Preserve Dst( n + UBound( Src ) )
\r
3668 For i=UBound( Src ) To 0 Step -1
\r
3669 If IsObject( Src(i) ) Then Set Dst(n+i) = Src(i) Else Dst(n+i) = Src(i)
\r
3671 ElseIf not IsEmpty( Src ) Then
\r
3672 ReDim Preserve Dst( n )
\r
3673 If IsObject( Src ) Then Set Dst(n) = Src Else Dst(n) = Src
\r
3680 '********************************************************************************
\r
3681 ' <<< [IsSameArray] >>>
\r
3682 '********************************************************************************
\r
3683 Function IsSameArray( Arr1, Arr2 )
\r
3686 If IsEmpty( Arr1 ) <> IsEmpty( Arr2 ) Then IsSameArray = False : Exit Function
\r
3687 If IsEmpty( Arr1 ) Then IsSameArray = True : Exit Function
\r
3689 If IsArray( Arr1 ) Then
\r
3690 If IsArray( Arr2 ) Then
\r
3691 If UBound( Arr1 ) <> UBound( Arr2 ) Then IsSameArray = False : Exit Function
\r
3693 If UBound( Arr1 ) <> UBound( Arr2.m_Array ) Then IsSameArray = False : Exit Function
\r
3695 low = LBound( Arr1 ) : up = UBound( Arr1 )
\r
3697 If IsArray( Arr2 ) Then
\r
3698 If UBound( Arr1.m_Array ) <> UBound( Arr2 ) Then IsSameArray = False : Exit Function
\r
3700 If UBound( Arr1.m_Array ) <> UBound( Arr2.m_Array ) Then IsSameArray = False : Exit Function
\r
3702 low = 0 : up = UBound( Arr1.m_Array )
\r
3706 If Arr1(i) <> Arr2(i) Then IsSameArray = False : Exit Function
\r
3708 IsSameArray = True
\r
3714 '********************************************************************************
\r
3715 ' <<< [QuickSort_fromDic] >>>
\r
3716 'dic as Scripting.Dictionary
\r
3717 'out_arr as [out] object array
\r
3718 '********************************************************************************
\r
3719 Sub QuickSort_fromDic( dic, out_arr, compare_func, param )
\r
3720 Dim i, i_last, elem
\r
3721 i_last = dic.Count - 1
\r
3722 Redim out_arr( i_last )
\r
3725 For Each elem In dic.Items
\r
3726 Set out_arr(i) = elem
\r
3730 QuickSort out_arr, 0, i_last, compare_func, param
\r
3736 '********************************************************************************
\r
3737 ' <<< [QuickSort] >>>
\r
3738 '********************************************************************************
\r
3739 Sub QuickSort( arr, i_left, i_right, compare_func, param )
\r
3740 Dim pivot, i_pivot, i_big, i_small, sw
\r
3742 If i_left >= i_right Then Exit Sub ' rule-b'
\r
3744 i_pivot = ( i_left + i_right ) \ 2
\r
3745 Set pivot = arr( i_pivot )
\r
3749 ' Dim i, sym, value
\r
3750 ' echo "QuickSort start ----------------------"
\r
3751 ' For i = i_left To i_right
\r
3752 ' QuickSort_Debug_getSym arr, i, sym, value
\r
3753 ' If i = i_pivot Then value = value & " (pivot)"
\r
3754 ' echo "(" & i & ") " & sym & " = " & value
\r
3756 ' If i_left = 0 and i_right = 4 Then Stop
\r
3759 i_big = i_left : i_small = i_right
\r
3761 '// Plus i_big if arr(i_big) is smaller than pivot
\r
3763 If compare_func( arr(i_big), pivot, param ) >= 0 Then Exit Do
\r
3767 '// Set i_small on equal or bigger than pivot
\r
3769 If i_small < i_pivot and i_small < i_big Then
\r
3770 If i_big < i_pivot Then
\r
3771 i_small = i_pivot : Exit Do
\r
3772 ElseIf i_small >= i_left Then
\r
3778 If compare_func( arr(i_small), pivot, param ) < 0 Then Exit Do
\r
3779 i_small = i_small - 1
\r
3783 If i_big < i_small Then ' rule-a
\r
3784 Set sw = arr(i_big) : Set arr(i_big) = arr(i_small) : Set arr(i_small) = sw
\r
3785 If i_big = i_pivot Then i_pivot = i_small
\r
3786 If i_small = i_pivot Then
\r
3788 If i_big >= i_small Then Exit Do ' rule-c'
\r
3790 If i_pivot > i_small Then i_small = i_pivot
\r
3798 ' echo "QuickSort middle ----------------------"
\r
3799 ' For i = i_left To i_right
\r
3800 ' QuickSort_Debug_getSym arr, i, sym, value
\r
3801 ' If i = i_big-1 Then value = value & " (i_big-1)"
\r
3802 ' If i = i_big Then value = value & " (i_big)"
\r
3803 ' echo "(" & i & ") " & sym & " = " & value
\r
3807 QuickSort arr, i_left, i_big-1, compare_func, param ' rule-b
\r
3808 QuickSort arr, i_big, i_right, compare_func, param ' rule-b
\r
3812 ' echo "QuickSort end ----------------------"
\r
3813 ' For i = i_left To i_right
\r
3814 ' QuickSort_Debug_getSym arr, i, sym, value
\r
3815 ' echo "(" & i & ") " & sym & " = " & value
\r
3821 'Sub QuickSort_Debug_getSym( Arr, Index, out_Symbol, out_Value )
\r
3822 ' out_Symbol = Index
\r
3823 ' out_Value = Arr(Index).id
\r
3828 '********************************************************************************
\r
3829 ' <<< [ShakerSort_fromDic] >>>
\r
3830 'dic as Scripting.Dictionary
\r
3831 'out_arr as [out] object array
\r
3832 '********************************************************************************
\r
3833 Sub ShakerSort_fromDic( dic, out_arr, sign, compare_func, param )
\r
3834 Dim i, i_last, elem
\r
3835 i_last = dic.Count - 1
\r
3836 Redim out_arr( i_last )
\r
3840 For Each elem In dic.Items
\r
3841 Set out_arr(i) = elem
\r
3846 For Each elem In dic.Items
\r
3847 Set out_arr(i) = elem
\r
3852 ShakerSort out_arr, 0, i_last, compare_func, param
\r
3857 '********************************************************************************
\r
3858 ' <<< [ShakerSort] >>>
\r
3859 '********************************************************************************
\r
3860 Sub ShakerSort( arr, ByVal i_left, ByVal i_right, compare_func, param )
\r
3865 For i=i_left+1 To i_right
\r
3866 If compare_func( arr(i-1), arr(i), param ) > 0 Then
\r
3867 Set sw = arr(i-1) : Set arr(i-1) = arr(i) : Set arr(i) = sw
\r
3871 If i_swap = i_left+1 Then Exit Do
\r
3872 i_right = i_swap-1
\r
3874 i_swap = i_right-1
\r
3875 For i=i_right-1 To i_left Step -1
\r
3876 If compare_func( arr(i), arr(i+1), param ) > 0 Then
\r
3877 Set sw = arr(i) : Set arr(i) = arr(i+1) : Set arr(i+1) = sw
\r
3881 If i_swap = i_right-1 Then Exit Do
\r
3888 '********************************************************************************
\r
3889 ' <<< [CInt2] >>>
\r
3891 '********************************************************************************
\r
3892 Function CInt2( v )
\r
3895 On Error Resume Next
\r
3897 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
3898 If en = 13 Then '// if sym is not number
\r
3900 ElseIf en <> 0 Then Err.Raise en,,ed End If
\r
3905 '********************************************************************************
\r
3906 ' <<< [MeltQuot] >>>
\r
3907 '********************************************************************************
\r
3908 Function MeltQuot( Line, in_out_Start )
\r
3915 c = Mid( Line, i, 1 )
\r
3916 If c = "" Then in_out_Start = 0 : Exit Function
\r
3917 If c = """" Then Exit Do
\r
3923 '//=== Search the end of "
\r
3926 c = Mid( Line, i, 1 )
\r
3927 If c = "" Then in_out_Start = 0 : Exit Do
\r
3928 If c = """" Then in_out_Start = i + 1 : Exit Do
\r
3933 '//=== Get the string
\r
3934 MeltQuot = Mid( Line, j, i - j )
\r
3940 '********************************************************************************
\r
3941 ' <<< [CreateGuid] >>>
\r
3942 '********************************************************************************
\r
3945 Function CreateGuid()
\r
3946 If g_TestModeFlags and F_NotRandom Then
\r
3947 g_TypeLib = g_TypeLib + 1
\r
3948 CreateGuid = "00000000-0000-0000-0000-" & Right( "000000000000" & g_TypeLib, 12 )
\r
3950 If IsEmpty( g_TypeLib ) Then Set g_TypeLib = CreateObject("Scriptlet.TypeLib")
\r
3951 CreateGuid = Mid( g_TypeLib.Guid, 2, 36 )
\r
3957 '********************************************************************************
\r
3958 ' <<< [ReplaceTextFile] >>>
\r
3959 '********************************************************************************
\r
3965 Sub new_ReplaceItem( objs, n )
\r
3966 Dim i:ReDim objs(n-1):For i=0 To n-1:Set objs(i)=new ReplaceItem :Next : ErrCheck
\r
3969 Sub ReplaceTextFile( SrcPath, TmpDstPath, bDstWillBeExist, ReplaceList, Opt )
\r
3970 echo ">ReplaceTextFile """ & SrcPath & """, """ & TmpDstPath & """, " & bDstWillBeExist
\r
3971 Dim rep, item, line
\r
3973 Set rep = StartReplace( SrcPath, TmpDstPath, bDstWillBeExist )
\r
3974 Do Until rep.r.AtEndOfStream
\r
3975 line = rep.r.ReadLine
\r
3976 For Each item In ReplaceList
\r
3977 line = Replace( line, item.Src, item.Dst )
\r
3979 rep.w.WriteLine line
\r
3986 '********************************************************************************
\r
3987 ' <<< [StartReplace] >>>
\r
3988 '********************************************************************************
\r
3989 Function StartReplace( SrcPath, TmpDstPath, bDstWillBeExist )
\r
3990 echo ">StartReplace """ & SrcPath & """, """ & TmpDstPath & """, " & bDstWillBeExist
\r
3991 Dim ec : Set ec = new EchoOff : ErrCheck
\r
3992 Dim m : Set m = new StartReplaceObj : ErrCheck
\r
3993 m.Init1 SrcPath, TmpDstPath, bDstWillBeExist
\r
3994 Set StartReplace = m
\r
3999 '********************************************************************************
\r
4000 ' <<< [StartReplace2] >>>
\r
4001 '********************************************************************************
\r
4002 Function StartReplace2( SrcPath, MidPath, Flags, TmpDstPath, bDstWillBeExist )
\r
4003 echo ">StartReplace2 """ & SrcPath & """, """ & MidPath & """, """ & TmpDstPath & """, " & bDstWillBeExist
\r
4004 Dim ec : Set ec = new EchoOff : ErrCheck
\r
4005 Dim m : Set m = new StartReplaceObj : ErrCheck
\r
4006 m.Init2 SrcPath, MidPath, Flags, TmpDstPath, bDstWillBeExist
\r
4007 Set StartReplace2 = m
\r
4011 Dim F_Txt2BinTxt : F_Txt2BinTxt = 2
\r
4014 Class StartReplaceObj
\r
4015 Public m_SrcPath ' as string
\r
4016 Public m_TmpDstPath ' as string
\r
4017 Public m_bDstWillBeExist ' as boolean
\r
4019 Public m_MidPath ' as string
\r
4020 Public m_Flags ' as bitfield
\r
4022 Public r ' as TextStream of m_SrcPath
\r
4023 Public w ' as TextStream of m_TmpDstPath
\r
4025 Private m_bFinished
\r
4028 Public Sub Init1( SrcPath, TmpDstPath, bDstWillBeExist )
\r
4030 Dim ec : Set ec = new EchoOff : ErrCheck
\r
4032 m_SrcPath = SrcPath
\r
4033 m_TmpDstPath = TmpDstPath
\r
4034 m_bDstWillBeExist = bDstWillBeExist
\r
4036 mkdir g_fs.GetParentFolderName( g_fs.GetAbsolutePathName( m_TmpDstPath ) )
\r
4037 Set Me.r = OpenTextFile( m_SrcPath )
\r
4039 On Error Resume Next
\r
4040 Set Me.w = g_fs.CreateTextFile( m_TmpDstPath, bDstWillBeExist, (g_TextFileConvertFormat = F_Unicode) )
\r
4041 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
4042 If en = E_AlreadyExist Then Err.Raise en,, "
\8aù
\82É
\93¯
\96¼
\82Ì
\83t
\83@
\83C
\83\8b\82ª
\91¶
\8dÝ
\82µ
\82Ä
\82¢
\82Ü
\82·
\81B: " + m_TmpDstPath
\r
4043 If en <> 0 Then Err.Raise en,,ed
\r
4047 Public Sub Init2( SrcPath, MidPath, Flags, TmpDstPath, bDstWillBeExist )
\r
4048 Init1 SrcPath, MidPath, bDstWillBeExist
\r
4049 m_MidPath = MidPath
\r
4050 m_TmpDstPath = TmpDstPath
\r
4051 m_Flags = Flags or 1
\r
4055 Public Sub Finish()
\r
4056 Dim ec : Set ec = new EchoOff : ErrCheck
\r
4060 If not IsEmpty( m_MidPath ) Then
\r
4061 If m_Flags and F_Txt2BinTxt Then
\r
4062 Txt2BinTxt m_MidPath, m_TmpDstPath
\r
4064 copy m_MidPath, m_TmpDstPath
\r
4069 If not m_bDstWillBeExist Then
\r
4070 copy m_TmpDstPath, m_SrcPath
\r
4073 m_bFinished = True
\r
4077 Public Sub ExitFinish( Opt )
\r
4078 m_bFinished = True
\r
4080 If not IsEmpty( m_MidPath ) Then del m_MidPath
\r
4085 Private Sub Class_Terminate()
\r
4086 Dim en,ed : en = Err.Number : ed = Err.Description
\r
4087 On Error Resume Next ' This clears the error
\r
4090 If en <> 0 and en <> 21 Then del m_TmpDstPath
\r
4091 ErrorCheckInTerminate
\r
4092 If en = 0 and not m_bFinished Then NotCallFinish
\r
4093 On Error GoTo 0 : If en <> 0 Then Err.Raise en,,ed
\r
4101 '********************************************************************************
\r
4102 ' <<< [TextFileCreateFormat] >>>
\r
4103 '********************************************************************************
\r
4104 Dim g_TextFileCreateFormat
\r
4105 Class TextFileCreateFormat
\r
4107 Private Sub Class_Initialize() : m_Prev = g_TextFileCreateFormat : End Sub
\r
4108 Public Sub Set_( Format ) : g_TextFileCreateFormat = Format : End Sub
\r
4109 Private Sub Class_Terminate : g_TextFileCreateFormat = m_Prev : End Sub
\r
4114 '********************************************************************************
\r
4115 ' <<< [TextFileConvertFormat] >>>
\r
4116 '********************************************************************************
\r
4117 Dim g_TextFileConvertFormat
\r
4118 Class TextFileConvertFormat
\r
4120 Private Sub Class_Initialize() : m_Prev = g_TextFileConvertFormat : End Sub
\r
4121 Public Sub Set_( Format ) : g_TextFileConvertFormat = Format : End Sub
\r
4122 Private Sub Class_Terminate : g_TextFileConvertFormat = m_Prev : End Sub
\r
4127 '-------------------------------------------------------------------------
\r
4128 ' ### <<<< [ArrayClass] Class >>>>
\r
4129 '-------------------------------------------------------------------------
\r
4134 Private Sub Class_Initialize
\r
4135 ReDim m_Array( -1 )
\r
4138 Public Default Property Get Item( i )
\r
4139 If IsObject( m_Array(i) ) Then Set Item = m_Array(i) Else Item = m_Array(i)
\r
4142 Public Property Let Item( i, value )
\r
4143 m_Array(i) = value
\r
4146 Public Sub ToEmpty()
\r
4147 ReDim m_Array( -1 )
\r
4150 Public Sub ReDim_( UBoundValue )
\r
4151 ReDim Preserve m_Array( UBoundValue )
\r
4154 Public Sub Add( elem )
\r
4158 Public Sub Push( elem )
\r
4159 ReDim Preserve m_Array( UBound(m_Array) + 1 )
\r
4160 If IsObject( elem ) Then
\r
4161 Set m_Array( UBound(m_Array) ) = elem
\r
4163 m_Array( UBound(m_Array) ) = elem
\r
4167 Public Function Pop()
\r
4168 If IsObject( m_Array( UBound(m_Array) ) ) Then
\r
4169 Set Pop = m_Array( UBound(m_Array) )
\r
4171 Pop = m_Array( UBound(m_Array) )
\r
4173 ReDim Preserve m_Array( UBound(m_Array) - 1 )
\r
4176 Public Property Get Count()
\r
4177 Count = UBound(m_Array) + 1
\r
4180 Public Property Get UBound_()
\r
4181 UBound_ = UBound(m_Array)
\r
4185 WScript.Echo Value
\r
4188 Public Property Get Value()
\r
4191 s = "count = " & Count
\r
4192 For Each i In m_Array
\r
4193 If IsObject( i ) Then
\r
4194 s = s + vbCRLF + "Class " & TypeName( i )
\r
4195 On Error Resume Next
\r
4196 s = s + vbCRLF + i.Value
\r
4199 If e <> 0 And e <> 438 Then Err.Raise e
\r
4201 s = s + vbCRLF + "each = " & i
\r
4207 Public Sub Copy( SrcArr )
\r
4208 If IsArray( SrcArr ) Then
\r
4210 ElseIf TypeName( SrcArr ) = "ArrayClass" Then
\r
4211 m_Array = SrcArr.m_Array
\r
4217 Public Sub AddElems( SrcArr )
\r
4218 If IsArray( SrcArr ) Then
\r
4219 AddArrElem m_Array, SrcArr
\r
4220 ElseIf TypeName( SrcArr ) = "ArrayClass" Then
\r
4221 AddArrElem m_Array, SrcArr.m_Array
\r
4230 '-------------------------------------------------------------------------
\r
4231 ' ### <<<< [ArrayDictionary] Class >>>>
\r
4232 '-------------------------------------------------------------------------
\r
4234 Class ArrayDictionary
\r
4238 Private Sub Class_Initialize
\r
4239 Set m_Dic = CreateObject("Scripting.Dictionary")
\r
4242 Public Sub ToEmpty
\r
4246 Public Sub Add( key, item )
\r
4249 If m_Dic.Exists( key ) Then
\r
4250 m_Dic.Item( key ).Add item
\r
4252 Set dic_item = New ArrayClass : ErrCheck
\r
4254 m_Dic.Add key, dic_item
\r
4258 Public Function Count
\r
4261 For Each i in m_Dic.Items()
\r
4262 Count = Count + i.Count
\r
4269 WScript.Echo "--- ArrayDictionary ------------------------------"
\r
4270 WScript.Echo "key count = " & m_Dic.Count
\r
4272 WScript.Echo "item count = " & Count
\r
4274 For Each i in m_Dic.Keys()
\r
4275 WScript.Echo "key=""" & i & """"
\r
4276 m_Dic.Item(i).Echo
\r
4285 '-------------------------------------------------------------------------
\r
4286 ' ### <<<< [StringStream] Class >>>>
\r
4287 '-------------------------------------------------------------------------
\r
4289 Class StringStream
\r
4292 Public m_INextLine
\r
4293 Private m_RaedLine, m_WriteLine, m_bPrevIsWrite
\r
4294 Public Property Get Line()
\r
4295 If m_bPrevIsWrite Then Line = m_WriteLine Else Line = m_ReadLine
\r
4298 Public Sub SetString( Str )
\r
4305 Public Function ReadLine()
\r
4308 i = InStr( m_INextLine, m_Str, vbCRLF )
\r
4310 ReadLine = Mid( m_Str, m_INextLine, i - m_INextLine )
\r
4311 m_INextLine = i + 2
\r
4313 ReadLine = Mid( m_Str, m_INextLine )
\r
4315 m_INextLine = Empty
\r
4317 m_RaedLine = m_RaedLine + 1
\r
4320 Public Function ReadAll()
\r
4325 Public Property Get AtEndOfStream : AtEndOfStream = IsEmpty( m_Str ) : End Property
\r
4326 Public Sub Write( Str ) : m_Str = m_Str + Str : End Sub
\r
4327 Public Sub WriteLine( LineStr ) : m_Str = m_Str + LineStr + vbCRLF : m_WriteLine = m_WriteLine + 1 : End Sub
\r
4332 '-------------------------------------------------------------------------
\r
4333 ' ### <<<< [StrMatchKey] Class >>>>
\r
4334 '-------------------------------------------------------------------------
\r
4337 Public Property Let Keyword( s )
\r
4339 m_LeftCount = InStr( s, "*" ) - 1
\r
4340 m_LeftStr = Left( s, m_LeftCount )
\r
4341 m_RightCount = Len( s ) - m_LeftCount - 1
\r
4342 m_RightStr = Right( s, m_RightCount )
\r
4344 If InStr( m_LeftCount + 2, s, "*" ) > 0 Then _
\r
4345 Raise 1,"*
\82ð
\95¡
\90\94\8ew
\92è
\82·
\82é
\82±
\82Æ
\82Í
\82Å
\82«
\82Ü
\82¹
\82ñ"
\r
4348 Public Property Get Keyword()
\r
4349 Keyword = m_Keyword
\r
4353 Public Function IsMatch( TestStr )
\r
4354 '// m_Keyword must be low case
\r
4356 If LCase( Right( TestStr, m_RightCount ) ) = m_RightStr Then
\r
4357 If m_LeftCount = 0 Then IsMatch = True : Exit Function
\r
4358 If LCase( Left( TestStr, m_LeftCount ) ) = m_LeftStr Then
\r
4364 Public Function IsMatchULCase( TestStr )
\r
4365 If Right( TestStr, m_RightCount ) = m_RightStr Then
\r
4366 If m_LeftCount = 0 Then IsMatchULCase = True : Exit Function
\r
4367 If Left( TestStr, m_LeftCount ) = m_LeftStr Then
\r
4368 IsMatchULCase = True
\r
4375 Public m_LeftCount
\r
4376 Public m_RightCount
\r
4383 '********************************************************************************
\r
4385 '********************************************************************************
\r
4386 Function LenK( Str )
\r
4387 Dim c, a, i, n_zen
\r
4391 c = Mid( Str, i, 1 )
\r
4392 If c = "" Then LenK = i - 1 + n_zen : Exit Function
\r
4394 If a >= 256 or a < 0 Then n_zen = n_zen + 1
\r
4401 '********************************************************************************
\r
4402 ' <<< [DateAddStr] >>>
\r
4403 '********************************************************************************
\r
4404 Function DateAddStr( BaseDate, Plus )
\r
4405 Dim i, i2, c, flag, num, unit, i_over
\r
4407 DateAddStr = BaseDate
\r
4409 i_over = Len( Plus ) + 1
\r
4411 '//=== Skip spaces
\r
4412 While Mid( Plus, i, 1 ) = " " : i=i+1 : WEnd
\r
4416 c = Mid( Plus, i, 1 )
\r
4419 ElseIf c = "-" Then
\r
4425 '//=== Skip spaces
\r
4426 While Mid( Plus, i, 1 ) = " " : i=i+1 : WEnd
\r
4428 If i = i_over Then Exit Do
\r
4431 c = Mid( Plus, i, 1 )
\r
4433 While (c >= "0" and c <= "9") or c="-" or c="+" : i2=i2+1 : c = Mid( Plus, i2, 1 ) : WEnd
\r
4434 num = CInt( Mid( Plus, i, i2 - i ) )
\r
4437 '//=== Skip spaces
\r
4438 While Mid( Plus, i, 1 ) = " " : i=i+1 : WEnd
\r
4441 c = Mid( Plus, i, 1 )
\r
4443 While (c >= "a" and c <= "z") or (c >= "A" and c <= "Z") : i2=i2+1 : c = Mid( Plus, i2, 1 ) : WEnd
\r
4444 Select Case LCase( Mid( Plus, i, i2 - i ) )
\r
4445 Case "year", "years" : unit = "yyyy"
\r
4446 Case "month", "months" : unit = "m"
\r
4447 Case "day", "days" : unit = "d"
\r
4448 Case "hour", "hours" : unit = "h"
\r
4449 Case "minute","minutes","min": unit = "n"
\r
4450 Case "second","seconds","sec": unit = "s"
\r
4451 Case Else Err.Raise 1,,"
\92P
\88Ê
\82ª
\82¨
\82©
\82µ
\82¢"
\r
4456 DateAddStr = DateAdd( unit, flag * num, DateAddStr )
\r
4462 '*-------------------------------------------------------------------------*
\r
4463 '* ### <<<< System (safe part) >>>>
\r
4464 '*-------------------------------------------------------------------------*
\r
4468 '********************************************************************************
\r
4469 ' <<< [RegRead] >>>
\r
4470 '********************************************************************************
\r
4471 Function RegRead( Path )
\r
4473 If TryStart(e) Then On Error Resume Next
\r
4474 RegRead = g_sh.RegRead( Path )
\r
4475 If TryEnd Then On Error GoTo 0
\r
4476 If e.num = E_PathNotFound or e.num = E_WIN32_FILE_NOT_FOUND Then
\r
4479 If e.num <> 0 Then e.Raise
\r
4485 '********************************************************************************
\r
4486 ' <<< [RegEnumKey] >>>
\r
4487 '********************************************************************************
\r
4488 Sub RegEnumKey( ByVal Path, out_Keys, Opt )
\r
4490 Dim keys, key, i, u
\r
4492 If IsEmpty( Opt ) Then RegEnumKey_sub Path, out_Keys : Exit Sub
\r
4495 out_Keys(0) = Path
\r
4498 RegEnumKey_sub out_Keys(i), keys '// get keys
\r
4500 If not IsNull( keys ) Then
\r
4501 For Each key In keys
\r
4503 ReDim Preserve out_Keys( u + 1 )
\r
4504 out_Keys(u) = out_Keys(i) + "\" + key
\r
4508 If i > u Then Exit Do
\r
4513 Sub RegEnumKey_sub( ByVal Path, out_Keys )
\r
4514 Dim reg, i, root_key
\r
4516 i = InStr( Path, "\" )
\r
4517 Select Case Left( Path, i - 1 )
\r
4518 Case "HKEY_CLASSES_ROOT" : root_key = &h80000000
\r
4519 Case "HKEY_CURRENT_USER" : root_key = &h80000001
\r
4520 Case "HKEY_LOCAL_MACHINE" : root_key = &h80000002
\r
4521 Case "HKEY_USERS" : root_key = &h80000003
\r
4522 Case "HKEY_PERFORMANCE_DATA":root_key= &h80000004
\r
4523 Case "HKEY_CURRENT_CONFIG": root_key = &h80000005
\r
4524 Case "HKEY_DYN_DATA" : root_key = &h80000006
\r
4525 Case Else : Err.Raise &h80070002
\r
4528 Path = Mid( Path, i + 1 )
\r
4530 If IsEmpty( g_reg ) Then _
\r
4531 Set g_reg = GetObject("winmgmts:{impersonationLevel=impersonate}!root/default:StdRegProv")
\r
4532 g_reg.EnumKey root_key, Path, out_Keys
\r
4534 If IsNull( out_Keys ) Then ReDim out_Keys(-1)
\r
4539 '********************************************************************************
\r
4540 ' <<< [RegEnumValues] >>>
\r
4541 '********************************************************************************
\r
4542 Class RegValueName
\r
4548 Sub RegEnumValues( ByVal Path, out_Values )
\r
4549 Dim reg, i, root_key, names, types
\r
4551 i = InStr( Path, "\" )
\r
4552 Select Case Left( Path, i - 1 )
\r
4553 Case "HKEY_CLASSES_ROOT" : root_key = &h80000000
\r
4554 Case "HKEY_CURRENT_USER" : root_key = &h80000001
\r
4555 Case "HKEY_LOCAL_MACHINE" : root_key = &h80000002
\r
4556 Case "HKEY_USERS" : root_key = &h80000003
\r
4557 Case "HKEY_PERFORMANCE_DATA":root_key= &h80000004
\r
4558 Case "HKEY_CURRENT_CONFIG": root_key = &h80000005
\r
4559 Case "HKEY_DYN_DATA" : root_key = &h80000006
\r
4560 Case Else : Err.Raise &h80070002
\r
4563 Path = Mid( Path, i + 1 )
\r
4565 If IsEmpty( g_reg ) Then _
\r
4566 Set g_reg = GetObject("winmgmts:{impersonationLevel=impersonate}!root/default:StdRegProv")
\r
4567 g_reg.EnumValues root_key, Path, names, types
\r
4569 ReDim out_Values( UBound( names ) )
\r
4570 For i=0 To UBound( names )
\r
4572 Set out_Values(i) = new RegValueName : ErrCheck
\r
4574 out_Values(i).Name = names(i)
\r
4576 Select Case types(i)
\r
4577 Case 1 : out_Values(i).Type_ = "REG_SZ"
\r
4578 Case 2 : out_Values(i).Type_ = "REG_EXPAND_SZ"
\r
4579 Case 3 : out_Values(i).Type_ = "REG_BINARY"
\r
4580 Case 4 : out_Values(i).Type_ = "REG_DWORD"
\r
4581 Case 7 : out_Values(i).Type_ = "REG_MULTI_SZ"
\r
4587 '********************************************************************************
\r
4588 ' <<< [RegExists] >>>
\r
4589 '********************************************************************************
\r
4590 Function RegExists( Path )
\r
4592 Const E_PathNotFound = &h80070002
\r
4594 On Error Resume Next
\r
4596 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
4597 If en = E_PathNotFound Then RegExists = False : Exit Function
\r
4598 If en <> 0 Then Err.Raise en,,ed
\r
4603 '*-------------------------------------------------------------------------*
\r
4604 '* ### <<<< Error, Err2 >>>>
\r
4605 '*-------------------------------------------------------------------------*
\r
4609 '********************************************************************************
\r
4610 ' <<< [Finish] >>>
\r
4611 '********************************************************************************
\r
4618 '********************************************************************************
\r
4619 ' <<< [Error] >>>
\r
4620 '********************************************************************************
\r
4627 '********************************************************************************
\r
4629 '********************************************************************************
\r
4632 Public Number ' Err.Number
\r
4633 Public num ' Err.Number
\r
4634 Public Description ' Err.Description (Error Message)
\r
4635 Public desc ' Err.Description (Error Message)
\r
4636 Public Source ' Err.Source
\r
4637 Public ErrID ' count of (num <> 0) in each first Copy after Clear
\r
4638 Public RaiseID ' count of (num <> 0) in Copy
\r
4639 Public BreakErrID ' as integer
\r
4640 Public BreakRaiseID ' as integer
\r
4642 Private Sub Class_Initialize
\r
4643 num = 0 : Description = "" : ErrID = 0 : RaiseID = 0
\r
4646 Public Sub OnSuccessFinish
\r
4647 If Err.Number = 0 and Me.num <> 0 Then
\r
4648 echo "<ERROR msg='Script finished before Err2.Clear or Raise the error'"+vbCRLF+_
\r
4649 "jp='
\83G
\83\89\81[
\82ª Err2.Clear
\82Ü
\82½
\82Í Raise
\82³
\82ê
\82È
\82¢
\82Å
\8fI
\97¹
\82µ
\82Ü
\82µ
\82½'"+vbCRLF+_
\r
4650 "err_symbol='E_NotClear' />"
\r
4652 Dim b_dbg : b_dbg = not IsDefined( "Setting_getCanExceptionDebugger" )
\r
4653 If not b_dbg Then b_dbg = Setting_getCanExceptionDebugger()
\r
4655 If Me.ErrID >= 2 or b_dbg Then
\r
4656 echo "Run debugger with writing following code in main function." + vbCRLF + _
\r
4657 "g_Err2.BreakErrID = " & Me.ErrID & " [or] " & Me.ErrID & ".5"
\r
4659 On Error Resume Next
\r
4660 Err.Raise Me.num, Me.Source, Me.desc
\r
4664 Public Sub OnErrorFinish
\r
4665 If Me.num <> 0 Then
\r
4666 echo "Run debugger with writing following code in main function." + vbCRLF + _
\r
4667 "g_Err2.BreakErrID = " & Me.ErrID & " [or] " & Me.ErrID & ".5"
\r
4671 Public Sub Copy( err )
\r
4672 Me.Number = err.Number
\r
4673 Me.num = err.Number
\r
4674 Me.Description = err.Description
\r
4675 Me.desc = err.Description
\r
4676 Me.Source = err.Source
\r
4677 If Me.num <> 0 Then Me.RaiseID = Me.RaiseID + 1 : If Me.RaiseID = 1 Then Me.ErrID = Me.ErrID + 1
\r
4680 Public Function Value
\r
4681 Value = GetErrStr( num, Description )
\r
4684 Public Sub OverRaise( e_num, e_desc )
\r
4686 Description = e_desc
\r
4692 Err.Raise 1 '// Look at caller function using watch window of debugger.
\r
4694 Err.Raise num, Source, Description '// Re-raise previous Error again.
\r
4695 '// Write g_Err2.BreakErrID = (ErrID) or (ErrID)+0.5 at the first of main function.
\r
4696 '// [sample] g_Err2.BreakErrID = 1
\r
4701 num = 0 : Description = "" : RaiseID = 0
\r
4707 '********************************************************************************
\r
4708 ' <<< [Raise] >>>
\r
4709 '********************************************************************************
\r
4710 Sub Raise( ErrNum, Description )
\r
4711 g_Err2.num = ErrNum
\r
4712 g_Err2.Source = "ERROR"
\r
4713 g_Err2.Description = Description
\r
4714 g_Err2.RaiseID = g_Err2.RaiseID + 1 : If g_Err2.RaiseID = 1 Then g_Err2.ErrID = g_Err2.ErrID + 1
\r
4716 echo "Run debugger with writing following code in main function."
\r
4717 echo "g_Err2.BreakErrID = " & g_Err2.ErrID & " [or] " & g_Err2.ErrID & ".5"
\r
4719 Err.raise g_Err2.num, g_Err2.Source, g_Err2.Description
\r
4724 '********************************************************************************
\r
4725 ' <<< [SetErrBreak] >>>
\r
4726 '********************************************************************************
\r
4727 Sub SetErrBreak( ErrID, RaiseID )
\r
4728 g_Err2.BreakErrID = ErrID
\r
4729 g_Err2.BreakRaiseID = RaiseID
\r
4734 '********************************************************************************
\r
4735 ' <<< [NestPos] >>>
\r
4736 '********************************************************************************
\r
4738 Public m_HereArr()
\r
4740 Private Sub Class_Initialize '
\83R
\83\93\83X
\83g
\83\89\83N
\83^
\r
4741 Redim m_HereArr(0)
\r
4745 Public Function GetPos( arr )
\r
4747 u = UBound( m_HereArr )
\r
4749 Redim Preserve arr(u-1)
\r
4752 arr(i) = m_HereArr(i)
\r
4756 Public Sub OnBlockStart
\r
4758 u = UBound( m_HereArr )
\r
4759 m_HereArr(u) = m_HereArr(u) + 1
\r
4760 Redim Preserve m_HereArr(u+1)
\r
4761 m_HereArr(u+1) = 0
\r
4764 Public Sub OnBlockEnd
\r
4765 Redim Preserve m_HereArr( UBound( m_HereArr ) - 1 )
\r
4771 '********************************************************************************
\r
4772 ' <<< [NotCallFinish] >>>
\r
4773 '********************************************************************************
\r
4774 Sub NotCallFinish()
\r
4775 echo "[ERROR] not call Finish"
\r
4777 If g_b_cscript_exe Then pause
\r
4783 '********************************************************************************
\r
4784 ' <<< [ErrorCheckInTerminate] >>>
\r
4785 '********************************************************************************
\r
4786 Sub ErrorCheckInTerminate()
\r
4787 If Err.Number <> 0 Then
\r
4788 echo GetErrStr( Err.Number, Err.Description + " in Class_Terminate" )
\r
4790 If g_b_cscript_exe Then pause
\r
4796 '********************************************************************************
\r
4797 ' <<< [TryStart] >>>
\r
4798 '********************************************************************************
\r
4799 Function TryStart( e )
\r
4801 If IsEmpty( e.BreakErrID ) Then
\r
4804 If e.ErrID = e.BreakErrID - 1 Then
\r
4814 '********************************************************************************
\r
4815 ' <<< [Trying] >>>
\r
4816 '********************************************************************************
\r
4818 Trying = (Err.Number=0)
\r
4819 If not Trying Then If g_Err2.ErrID = g_Err2.BreakErrID - 1.5 Then g_Err2.BreakErrID = Empty :_
\r
4820 Stop '// Look at caller function by call stack window
\r
4825 '********************************************************************************
\r
4826 ' <<< [TryEnd] >>>
\r
4827 '********************************************************************************
\r
4829 ' Do not have parameters.
\r
4830 ' Because "If TryEnd(e) Then On Error Goto 0" cannot get error, if e is not Dim.
\r
4832 If Err.Number <> 0 Then
\r
4835 If g_Err2.ErrID = g_Err2.BreakErrID Then
\r
4841 If g_Err2.ErrID = g_Err2.BreakErrID - 0.5 Then g_Err2.BreakErrID = Empty :_
\r
4842 Stop '// Look at caller function by call stack window
\r
4850 '********************************************************************************
\r
4851 ' <<< [ErrCheck] >>>
\r
4852 '********************************************************************************
\r
4854 If Err.Number <> 0 Then g_Err2.Copy Err : g_Err2.Raise
\r
4858 '********************************************************************************
\r
4859 ' <<< [chk_exist_in_lib] >>>
\r
4861 ' - If there is not path in vbslib folder, raise error of E_FileNotExist.
\r
4862 '********************************************************************************
\r
4863 Sub chk_exist_in_lib( ByVal path )
\r
4864 If not exist( g_vbslib_ver_folder + path ) Then Err.Raise E_FileNotExist,, _
\r
4865 "Not found """ + g_vbslib_ver_folder + path + """"
\r
4870 '-------------------------------------------------------------------------
\r
4871 ' ### <<<< [SkipSection] Class >>>>
\r
4872 '-------------------------------------------------------------------------
\r
4874 Public m_CurrentSecNum
\r
4875 Public m_SkipToSecNum
\r
4879 Dim g_bSkipSectionSupport
\r
4881 Sub SkipToSection( Num )
\r
4882 If IsEmpty( Num ) Then
\r
4883 g_SkipSection = Empty
\r
4885 Set g_SkipSection = new SkipSection
\r
4886 g_SkipSection.m_SkipToSecNum = Num
\r
4890 Function NotSkipSection()
\r
4891 g_bSkipSectionSupport = True
\r
4892 If IsEmpty( g_SkipSection ) Then NotSkipSection = True : Exit Function
\r
4893 Dim m : Set m = g_SkipSection
\r
4894 m.m_CurrentSecNum = m.m_CurrentSecNum + 1
\r
4895 If m.m_CurrentSecNum < m.m_SkipToSecNum Then NotSkipSection = False : Exit Function
\r
4896 echo "<Section num='" & m.m_CurrentSecNum & "'/>"
\r
4897 NotSkipSection = True
\r
4902 '-------------------------------------------------------------------------
\r
4903 ' ### <<<< [FinObj] Class >>>>
\r
4904 '-------------------------------------------------------------------------
\r
4906 Public m_Vars ' as Dictionay
\r
4907 Public m_FinallyFunc
\r
4909 Private Sub Class_Initialize
\r
4910 Set m_Vars = CreateObject("Scripting.Dictionary")
\r
4913 Public Sub SetFunc( FuncName )
\r
4914 Set m_FinallyFunc = GetRef( FuncName )
\r
4917 Public Sub SetVar( Name, Var )
\r
4918 If IsObject( Var ) Then Set m_Vars.Item( Name ) = Var _
\r
4919 Else m_Vars.Item( Name ) = Var
\r
4922 Private Sub Class_Terminate()
\r
4923 If not IsEmpty( m_FinallyFunc ) Then
\r
4924 Dim en, ed : en = Err.Number : ed = Err.Description
\r
4925 m_FinallyFunc m_Vars
\r