Function packString( ByVal strString, ByVal intWidth)
ON ERROR RESUME NEXT
Err.Clear
strString = CStr(strString)
If Err.Number Then
Call Wscript.Echo "INVALID_ERRORMESSAGE_TYPE_AS_INPUT"
Err.Clear
Wscript.Quit("EXIT_INVALID_PARAM")
End If
intWidth = CInt(intWidth)
If Err.Number Then
Call Wscript.Echo "INVALID_ERRORMESSAGE_TYPE_AS_INPUT"
Err.Clear
Wscript.Quit("EXIT_INVALID_PARAM")
End If
If IsNull(strString) OR IsEmpty(strString) OR Len(strString) = 0 Then
If intwidth = 0 then
packString = "TEXT_NA"
Exit Function
Else
packString = "TEXT_NA" & Space(intWidth-3)
Exit Function
End If
End If
If intWidth >= LengthinBytes(strString) Then
packString = strString & Space(intWidth-LengthinBytes(strString))
Else
If intWidth = 0 then
packString = LeftBytes(strString, LengthinBytes(strString))
Else
packString = LeftBytes(strString, intWidth)
End If
End If
End Function
ON ERROR RESUME NEXT
Err.Clear
strString = CStr(strString)
If Err.Number Then
Call Wscript.Echo "INVALID_ERRORMESSAGE_TYPE_AS_INPUT"
Err.Clear
Wscript.Quit("EXIT_INVALID_PARAM")
End If
intWidth = CInt(intWidth)
If Err.Number Then
Call Wscript.Echo "INVALID_ERRORMESSAGE_TYPE_AS_INPUT"
Err.Clear
Wscript.Quit("EXIT_INVALID_PARAM")
End If
If IsNull(strString) OR IsEmpty(strString) OR Len(strString) = 0 Then
If intwidth = 0 then
packString = "TEXT_NA"
Exit Function
Else
packString = "TEXT_NA" & Space(intWidth-3)
Exit Function
End If
End If
If intWidth >= LengthinBytes(strString) Then
packString = strString & Space(intWidth-LengthinBytes(strString))
Else
If intWidth = 0 then
packString = LeftBytes(strString, LengthinBytes(strString))
Else
packString = LeftBytes(strString, intWidth)
End If
End If
End Function
그외,. COM 개체를 이용하는 경우에는,..
Set objCmdLib = CreateObject("Microsoft.CmdLib")
Set objCmdLib.ScriptingHost = WScript.Application
wscript.echo objCmdLib.packString("한글","2")
Set objCmdLib.ScriptingHost = WScript.Application
wscript.echo objCmdLib.packString("한글","2")
댓글 없음:
댓글 쓰기