<SCRIPT language=VBScript>
' **********************************************************
' グローバル
' **********************************************************
Dim Value
Dim MyDisp
' **********************************************************
' クラス
' **********************************************************
Class Disp
Public DispArray() ' 動的配列
Public Counter ' 添え字カウンター
' ************************************************
' コンストラクタ
' ************************************************
Public Default Function InitSetting()
ReDim Preserve DispArray(0)
Counter = -1
end function
' ************************************************
' メソッド ( データセット )
' ************************************************
Function SetData( strValue )
Counter = Counter + 1
ReDim Preserve DispArray( Counter )
DispArray( Counter ) = strValue
end function
' ************************************************
' メソッド ( データ取得 )
' ************************************************
Function GetData()
GetData = Join( DispArray, vbCrLf )
end function
' ************************************************
' メソッド ( タイプセット )
' ************************************************
Function SetType( Target, Title )
SetData( "<TR>" )
SetData( "<TD style='font-weight:bold'>" & Title & "</TD>" )
if IsEmpty( Target ) then
SetData( "<TD>Empty</TD>" )
else
SetData( "<TD>not Empty</TD>" )
end if
if IsObject( Target ) then
SetData( "<TD>Object</TD>" )
else
SetData( "<TD>not Object</TD>" )
end if
if IsNull( Target ) then
SetData( "<TD>Null</TD>" )
else
SetData( "<TD>not Null</TD>" )
end if
SetData( "<TD>" & TypeName( Target ) & "</TD>" )
SetData( "<TD>" & VarType( Target ) & "</TD>" )
on error resume next
SetData( "<TD>" & Asc( Target ) & "</TD>" )
if Err.Number <> 0 then
SetData( "<TD>Error</TD>" )
end if
on error goto 0
on error resume next
SetData( "<TD>" & Len( Target ) & "</TD>" )
if Err.Number <> 0 then
SetData( "<TD>Error</TD>" )
end if
on error goto 0
on error resume next
if Target then
if Err.Number = 0 then
SetData( "<TD>True</TD>" )
else
SetData( "<TD>Error</TD>" )
end if
else
if Err.Number = 0 then
SetData( "<TD>False</TD>" )
else
SetData( "<TD>Error</TD>" )
end if
end if
on error goto 0
SetData( "</TR>" )
end function
End Class
'***********************************************************
' 変数内容のテスト
'***********************************************************
function ValueTest()
Set MyDisp = new Disp
Call MyDisp()
With ( MyDisp )
.SetData( "<TABLE border=1 cellpadding=5>" )
.SetData( "<TH> </TH>" )
.SetData( "<TH>IsEmpty</TH>" )
.SetData( "<TH>IsObject</TH>" )
.SetData( "<TH>IsNull</TH>" )
.SetData( "<TH>TypeName</TH>" )
.SetData( "<TH>VarType</TH>" )
.SetData( "<TH>ASC()</TH>" )
.SetData( "<TH>Len</TH>" )
.SetData( "<TH>if Value then</TH>" )
'*****************************************
' 初期状態
'*****************************************
Call .SetType( Value, "初期状態" )
'*****************************************
' Nothing
'*****************************************
Set Value = Nothing
Call .SetType( Value, "Set Value = Nothing" )
'*****************************************
' zero-length string
'*****************************************
Value = ""
Call .SetType( Value, "Value = """"" )
'*****************************************
' vbNullString
'*****************************************
Value = vbNullString
Call .SetType( Value, "Value = vbNullString" )
'*****************************************
' vbNullChar
'*****************************************
Value = vbNullChar
Call .SetType( Value, "Value = vbNullChar" )
'*****************************************
' Null
'*****************************************
Value = Null
Call .SetType( Value, "Value = Null" )
'*****************************************
' Empty
'*****************************************
Value = Empty
Call .SetType( Value, "Value = Empty" )
'*****************************************
' Array
'*****************************************
Value = Array()
Call .SetType( Value, "Value = Array()" )
'*****************************************
' False & True
'*****************************************
Value = False
Call .SetType( Value, "Value = False" )
Value = True
Call .SetType( Value, "Value = True" )
Value = "False"
Call .SetType( Value, "Value = ""False""" )
Value = "True"
Call .SetType( Value, "Value = ""True""" )
Value = 0
Call .SetType( Value, "Value = 0" )
Value = 1
Call .SetType( Value, "Value = 1" )
Value = "0"
Call .SetType( Value, "Value = ""0""" )
Value = "1"
Call .SetType( Value, "Value = ""1""" )
Value = -1
Call .SetType( Value, "Value = -1" )
Value = "-1"
Call .SetType( Value, "Value = ""-1""" )
Value = 17
Call .SetType( Value, "Value = 17" )
'*****************************************
' 文字列
'*****************************************
Value = "ABC"
Call .SetType( Value, "Value = ""ABC""" )
.SetData( "</TABLE>" )
document.write MyDisp.GetData
End With
end function
</SCRIPT>
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=Shift_JIS">
</HEAD>
<BODY>
<INPUT type=button value="テスト" onClick='Call ValueTest()'>
<DIV id=DispArea>
</DIV>
</BODY>
</HTML>
|