Sideway BICK BlogSideway BICK BLOG from Sideway

A Sideway to Sideway Home

Link:http://output.to/sideway/default.asp?qno=180500001

Script, Scripting Language, VBScript elements, Server-Side VBScript Transfer Control Statement

VBScript Transfer Control Statement

The Transfer Control statements are .

Call Statement

last updated 11/21/2017

to transfers control to a Sub or Function procedure.

Syntax

name [argumentlist]
Call name ([argumentlist])

Argument

CallOptional keyword. If specified, you must enclose argumentlist in parentheses.nameRequired. Name of the procedure to call.(…)Optional, required if Call is specified. A pair of parenthetic brackets is needed to enclose argumentlist.argumentlistOptional. to specified Comma-delimited list of variables, arrays, or expressions to pass to the procedure.

Remarks

  • The Call keyword is needed when calling a procedure.
  • The Call keyword is used to call a procedure that requires arguments, argumentlist must be enclosed in parentheses.
  • However, the function's return value is discarded, when using either Call syntax to call any intrinsic or user-defined function since the return value due to Call is assigned to nothing. However, the returned value due the function itself is still available if other keywords are used instead of keyword Call. .

Requirement

1

Examples

Examples of Call Statement

ASP VbScript Command:
<script runat="server" language="VBScript">
Dim vars,strs,cmda
cmda=array("a","b","xfunc","a","xfunc1(5)","b","Call xfunc","a","Call xfunc1(b)","b")
Dim ucnt,tmp,i:ucnt=UBound(cmda):If var=1 Then:tmp="":Else:tmp="<b>vars</b>":End If:For i=0 to ucnt:tmp=tmp&"<b>"&rmv_ctrl(cmda(i))&", TypeName</b>":Next:Response.Write "Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /internet/users/sideblog/default.asp<br />"&"<i>"&tmp&"</i>"
Function dsp_x:Dim tmp_a,tmp_b,i:If varx=0  Then:Execute vars:End If:If var=1 Then:tmp_a="":Else:tmp_a=rmv_ctrl(vars):End If:For i=0 to ucnt:tmp_b=cmd_b(cmda(i)):if i/2=fix(i/2) Then:tmp_b="<b>"&tmp_b&"</b>":End If:tmp_a=tmp_a&tmp_b:Next:Response.Write "<i>"&tmp_a&"</i>":End Function
Function rmv_ctrl(blk_str):Select Case blk_str:Case chr(0):blk_str="NUL":Case chr(1):blk_str="SOH":Case chr(2):blk_str="STX":Case chr(3):blk_str="ETX":Case chr(4):blk_str="EOT":Case chr(5):blk_str="ENQ":Case chr(6):blk_str="ACK":Case chr(7):blk_str="BEL":Case chr(8):blk_str="BS":Case chr(9):blk_str="HT":Case chr(10):blk_str="LF":Case chr(11):blk_str="VT":Case chr(12):blk_str="FF":Case chr(13):blk_str="CR":Case chr(14):blk_str="SO":Case chr(15):blk_str="SI":Case chr(16):blk_str="DLE":Case chr(17):blk_str="DC1":Case chr(18):blk_str="DC2":Case chr(19):blk_str="DC3":Case chr(20):blk_str="DC4":Case chr(21):blk_str="NAK":Case chr(22):blk_str="SYN":Case chr(23):blk_str="ETB":Case chr(24):blk_str="CAN":Case chr(25):blk_str="EM":Case chr(26):blk_str="SUB":Case chr(27):blk_str="ESC":Case chr(28):blk_str="FS":Case chr(29):blk_str="GS":Case chr(30):blk_str="RS":Case chr(31):blk_str="US":Case chr(127):blk_str="DEL":End Select:rmv_ctrl=blk_str:If IsNull(blk_str) OR IsEmpty(Blk_str) OR blk_str="" OR IsNumeric(Blk_str) Then:Else:rmv_ctrl=Replace(Replace(Replace(Replace(Replace(blk_str,"&","&amp;"),"  "," &nbsp;"),"""","&quot;"),"<","&lt;"),">","&gt;"): End If :End Function
Function cmd_b(blk_str):cmd_b="["&cmd_x(blk_str)&"], "&cmd_x("TypeName("&blk_str&")"):End Function
Function cmd_x(blk_str):On Error Resume Next:Dim xans, tmp:xans="":tmp="":execute "xans="&blk_str:If Err.Number <> 0  Then:xans=cmd_x("TypeName("&blk_str&")"):Select Case xans:Case 9::Case Else:xans="error":End Select:End If:If IsArray(xans)=False Then:cmd_x=rmv_ctrl(xans): Else:tmp=lst_arry(xans):cmd_x=trim(tmp):End If:End Function
Function lst_arry(blk_str):Dim tmp,i,q:q="""":tmp="":For i=0 to UBound(blk_str):if VarType(blk_str(i))>1 And VarType(blk_str(i))<6 Then:q="'":End If:tmp=tmp&" "&q&rmv_ctrl(blk_str(i))&q:Next:lst_arry=trim(tmp):End Function

vars="dim a,b:a=0:b=1:Function xfunc:a=b:xfunc=5:End Function:Function xfunc1(c):b=a*c:xfunc1=5*c:End Function":Execute vars:dsp_x
vars="a=Null:b=3":dsp_x
vars="a=Null:b=5":dsp_x
vars="a=Null:b=3:xfunc":dsp_x
vars="a=Null:b=5:call xfunc":dsp_x
</script>
HTML Web Page In-line Output:
Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /internet/users/sideblog/default.asp
varsa, TypeNameb, TypeNamexfunc, TypeNamea, TypeNamexfunc1(5), TypeNameb, TypeNameCall xfunc, TypeNamea, TypeNameCall xfunc1(b), TypeNameb, TypeNamedim a,b:a=0:b=1:Function xfunc:a=b:xfunc=5:End Function:Function xfunc1(c):b=a*c:xfunc1=5*c:End Function[0], Integer[1], Integer[5], Integer[1], Integer[25], Integer[5], Integer[error], error[1], Integer[error], error[5], Integera=Null:b=3[], Null[3], Integer[5], Integer[3], Integer[25], Integer[15], Integer[error], error[3], Integer[error], error[15], Integera=Null:b=5[], Null[5], Integer[5], Integer[5], Integer[25], Integer[25], Integer[error], error[5], Integer[error], error[25], Integera=Null:b=3:xfunc[3], Integer[3], Integer[5], Integer[3], Integer[25], Integer[15], Integer[error], error[3], Integer[error], error[15], Integera=Null:b=5:call xfunc[5], Integer[5], Integer[5], Integer[5], Integer[25], Integer[25], Integer[error], error[5], Integer[error], error[25], Integer

Execute Statement

last updated 11/21/2017

to executes one or more specified statements.

Syntax

Execute statement

Argument

ExecuteRequired keyword. to indicate the start of Execute.statementOptional. is a string expression containing one or more statements for execution. Include multiple statements in the statement argument, using colons or embedded line breaks to separate them.

Remarks

  • In VBScript, x = y can be interpreted two ways. The first is as an assignment statement, where the value of y is assigned to x. The second interpretation is as an expression that tests if x and y have the same value. If they do, result is True; if they are not, result is False. The Execute statement always uses the first interpretation, whereas the Eval method always uses the second.
  • But, In Microsoft® JScript®, no confusion exists between assignment and comparison, because the assignment operator (=) is different from the comparison operator(==).
  • The context in which the Execute statement is invoked determines what objects and variables are available to the code being run. In-scope objects and variables are available to code running in an Execute statement. However, it is important to understand that if you execute code that creates a procedure, that procedure does not inherit the scope of the procedure in which it occurred.
  • Like any procedure, the new procedure's scope is global, and it inherits everything in the global scope. Unlike any other procedure, its context is not global scope, so it can only be executed in the context of the procedure where the Execute statement occurred. However, if the same Execute statement is invoked outside of a procedure (i.e., in global scope), not only does it inherit everything in global scope, but it can also be called from anywhere, since its context is global.

Requirement

5

Examples

Examples of Execute Statement

ASP VbScript Command:
<script runat="server" language="VBScript">
Dim vars,strs,cmda:varx=1
cmda=array("vX","vY","vZ")
Dim ucnt,tmp,i:ucnt=UBound(cmda):If var=1 Then:tmp="":Else:tmp="<b>vars</b>":End If:For i=0 to ucnt:tmp=tmp&"<b>"&rmv_ctrl(cmda(i))&", TypeName</b>":Next:Response.Write "Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /internet/users/sideblog/default.asp<br />"&"<i>"&tmp&"</i>"
Function dsp_x:Dim tmp_a,tmp_b,i:If varx=0  Then:Execute vars:End If:If var=1 Then:tmp_a="":Else:tmp_a=rmv_ctrl(vars):End If:For i=0 to ucnt:tmp_b=cmd_b(cmda(i)):if i/2=fix(i/2) Then:tmp_b="<b>"&tmp_b&"</b>":End If:tmp_a=tmp_a&tmp_b:Next:Response.Write "<i>"&tmp_a&"</i>":End Function
Function rmv_ctrl(blk_str):Select Case blk_str:Case chr(0):blk_str="NUL":Case chr(1):blk_str="SOH":Case chr(2):blk_str="STX":Case chr(3):blk_str="ETX":Case chr(4):blk_str="EOT":Case chr(5):blk_str="ENQ":Case chr(6):blk_str="ACK":Case chr(7):blk_str="BEL":Case chr(8):blk_str="BS":Case chr(9):blk_str="HT":Case chr(10):blk_str="LF":Case chr(11):blk_str="VT":Case chr(12):blk_str="FF":Case chr(13):blk_str="CR":Case chr(14):blk_str="SO":Case chr(15):blk_str="SI":Case chr(16):blk_str="DLE":Case chr(17):blk_str="DC1":Case chr(18):blk_str="DC2":Case chr(19):blk_str="DC3":Case chr(20):blk_str="DC4":Case chr(21):blk_str="NAK":Case chr(22):blk_str="SYN":Case chr(23):blk_str="ETB":Case chr(24):blk_str="CAN":Case chr(25):blk_str="EM":Case chr(26):blk_str="SUB":Case chr(27):blk_str="ESC":Case chr(28):blk_str="FS":Case chr(29):blk_str="GS":Case chr(30):blk_str="RS":Case chr(31):blk_str="US":Case chr(127):blk_str="DEL":End Select:rmv_ctrl=blk_str:If IsNull(blk_str) OR IsEmpty(Blk_str) OR blk_str="" OR IsNumeric(Blk_str) Then:Else:rmv_ctrl=Replace(Replace(Replace(Replace(Replace(blk_str,"&","&amp;"),"  "," &nbsp;"),"""","&quot;"),"<","&lt;"),">","&gt;"): End If :End Function
Function cmd_b(blk_str):cmd_b="["&cmd_x(blk_str)&"], "&cmd_x("TypeName("&blk_str&")"):End Function
Function cmd_x(blk_str):On Error Resume Next:Dim xans, tmp:xans="":tmp="":execute "xans="&blk_str:If Err.Number <> 0  Then:xans=cmd_x("TypeName("&blk_str&")"):Select Case xans:Case 9::Case Else:xans="error":End Select:End If:If IsArray(xans)=False Then:cmd_x=rmv_ctrl(xans): Else:tmp=lst_arry(xans):cmd_x=trim(tmp):End If:End Function
Function lst_arry(blk_str):Dim tmp,i,q:q="""":tmp="":For i=0 to UBound(blk_str):if VarType(blk_str(i))>1 And VarType(blk_str(i))<6 Then:q="'":End If:tmp=tmp&" "&q&rmv_ctrl(blk_str(i))&q:Next:lst_arry=trim(tmp):End Function

vars="Dim vI,vX,vY,vZ:vI=10:vX=0:vY=0:vZ=0":Execute vars:dsp_x
vars="Sub Proc1:Dim vX:vX=1+vI:vY=vX+vI:Execute ""Sub Proc2:vZ=vX+vI:End Sub"":Proc2:vI=vI+10:End Sub:Proc1":Execute vars:dsp_x
vars="Proc1":Execute vars:dsp_x
vars="Execute ""Sub Proc2:vZ=vX+vI:End Sub"":Proc2":Execute vars:dsp_x
</script>
HTML Web Page In-line Output:
Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /internet/users/sideblog/default.asp
varsvX, TypeNamevY, TypeNamevZ, TypeNameDim vI,vX,vY,vZ:vI=10:vX=0:vY=0:vZ=0[0], Integer[0], Integer[0], IntegerSub Proc1:Dim vX:vX=1+vI:vY=vX+vI:Execute "Sub Proc2:vZ=vX+vI:End Sub":Proc2:vI=vI+10:End Sub:Proc1[0], Integer[21], Integer[10], IntegerProc1[0], Integer[41], Integer[20], IntegerExecute "Sub Proc2:vZ=vX+vI:End Sub":Proc2[0], Integer[41], Integer[30], Integer

ExecuteGlobal Statement

last updated 11/22/2017

to execute one or more specified statements in the global namespace of a script.

Syntax

ExecuteGlobal statement

Argument

ExecuteGlobalRequired keyword. to indicate the start of ExecuteGlobal.statementOptional. is a string expression containing one or more statements for execution. Include multiple statements in the statement argument, using colons or embedded line breaks to separate them.

Remarks

  • In VBScript, x = y can be interpreted two ways. The first is as an assignment statement, where the value of y is assigned to x. The second interpretation is as an expression that tests if x and y have the same value. If they do, result is True; if they are not, result is False. The Execute statement always uses the first interpretation, whereas the Eval method always uses the second.
  • But, In Microsoft® JScript®, no confusion exists between assignment and comparison, because the assignment operator (=) is different from the comparison operator(==).
  • All statements used with ExecuteGlobal are executed in the script's global namespace. This allows code to be added to the program so that any procedure can access it. For example, a VBScript Class statement can be executed at run time and functions can subsequently create new instances of the class.
  • Adding procedures and classes at runtime can be useful, but also introduces the possibility of overwriting existing global variable and functions at runtime. Because this can cause significant programming problems, care should be exercised when using the ExecuteGlobal statement. If you don't need access to a variable or function outside of a procedure, use the Execute statement that will only affect the namespace of the calling function.

Requirement

5

Examples

Examples of ExecuteGlobal Statement

ASP VbScript Command:
<script runat="server" language="VBScript">
Dim vars,strs,cmda:varx=1
cmda=array("vX","vY","vZ")
Dim ucnt,tmp,i:ucnt=UBound(cmda):If var=1 Then:tmp="":Else:tmp="<b>vars</b>":End If:For i=0 to ucnt:tmp=tmp&"<b>"&rmv_ctrl(cmda(i))&", TypeName</b>":Next:Response.Write "Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /internet/users/sideblog/default.asp<br />"&"<i>"&tmp&"</i>"
Function dsp_x:Dim tmp_a,tmp_b,i:If varx=0  Then:Execute vars:End If:If var=1 Then:tmp_a="":Else:tmp_a=rmv_ctrl(vars):End If:For i=0 to ucnt:tmp_b=cmd_b(cmda(i)):if i/2=fix(i/2) Then:tmp_b="<b>"&tmp_b&"</b>":End If:tmp_a=tmp_a&tmp_b:Next:Response.Write "<i>"&tmp_a&"</i>":End Function
Function rmv_ctrl(blk_str):Select Case blk_str:Case chr(0):blk_str="NUL":Case chr(1):blk_str="SOH":Case chr(2):blk_str="STX":Case chr(3):blk_str="ETX":Case chr(4):blk_str="EOT":Case chr(5):blk_str="ENQ":Case chr(6):blk_str="ACK":Case chr(7):blk_str="BEL":Case chr(8):blk_str="BS":Case chr(9):blk_str="HT":Case chr(10):blk_str="LF":Case chr(11):blk_str="VT":Case chr(12):blk_str="FF":Case chr(13):blk_str="CR":Case chr(14):blk_str="SO":Case chr(15):blk_str="SI":Case chr(16):blk_str="DLE":Case chr(17):blk_str="DC1":Case chr(18):blk_str="DC2":Case chr(19):blk_str="DC3":Case chr(20):blk_str="DC4":Case chr(21):blk_str="NAK":Case chr(22):blk_str="SYN":Case chr(23):blk_str="ETB":Case chr(24):blk_str="CAN":Case chr(25):blk_str="EM":Case chr(26):blk_str="SUB":Case chr(27):blk_str="ESC":Case chr(28):blk_str="FS":Case chr(29):blk_str="GS":Case chr(30):blk_str="RS":Case chr(31):blk_str="US":Case chr(127):blk_str="DEL":End Select:rmv_ctrl=blk_str:If IsNull(blk_str) OR IsEmpty(Blk_str) OR blk_str="" OR IsNumeric(Blk_str) Then:Else:rmv_ctrl=Replace(Replace(Replace(Replace(Replace(blk_str,"&","&amp;"),"  "," &nbsp;"),"""","&quot;"),"<","&lt;"),">","&gt;"): End If :End Function
Function cmd_b(blk_str):cmd_b="["&cmd_x(blk_str)&"], "&cmd_x("TypeName("&blk_str&")"):End Function
Function cmd_x(blk_str):On Error Resume Next:Dim xans, tmp:xans="":tmp="":execute "xans="&blk_str:If Err.Number <> 0  Then:xans=cmd_x("TypeName("&blk_str&")"):Select Case xans:Case 9::Case Else:xans="error":End Select:End If:If IsArray(xans)=False Then:cmd_x=rmv_ctrl(xans): Else:tmp=lst_arry(xans):cmd_x=trim(tmp):End If:End Function
Function lst_arry(blk_str):Dim tmp,i,q:q="""":tmp="":For i=0 to UBound(blk_str):if VarType(blk_str(i))>1 And VarType(blk_str(i))<6 Then:q="'":End If:tmp=tmp&" "&q&rmv_ctrl(blk_str(i))&q:Next:lst_arry=trim(tmp):End Function

vars="Dim vI,vX,vY,vZ:vI=10:vX=0:vY=0:vZ=0":Execute vars:dsp_x
vars="Sub Proc1:Dim vX:vX=1+vI:vY=vX+vI:ExecuteGlobal ""Sub Proc2:vZ=vX+vI:End Sub"":Proc2:vI=vI+10:End Sub:Proc1:Proc2":Execute vars:dsp_x
vars="Proc1":Execute vars:dsp_x
vars="Execute ""Sub Proc2:vZ=vX+vI:End Sub"":Proc2":Execute vars:dsp_x
</script>
HTML Web Page In-line Output:
Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /internet/users/sideblog/default.asp
varsvX, TypeNamevY, TypeNamevZ, TypeNameDim vI,vX,vY,vZ:vI=10:vX=0:vY=0:vZ=0[0], Integer[0], Integer[0], IntegerSub Proc1:Dim vX:vX=1+vI:vY=vX+vI:ExecuteGlobal "Sub Proc2:vZ=vX+vI:End Sub":Proc2:vI=vI+10:End Sub:Proc1:Proc2[0], Integer[21], Integer[20], IntegerProc1[0], Integer[41], Integer[20], IntegerExecute "Sub Proc2:vZ=vX+vI:End Sub":Proc2[0], Integer[41], Integer[30], Integer

Exit Statement

last updated 11/22/2017

to exit a block of Do…Loop, For…Next, Function, or Sub code.

Syntax

Exit Do
Exit For
Exit Function
Exit Property
Exit Sub

Argument

ExitRequired keyword. to indicate the start of Exit.DoRequired. to specify the Do type of block to be exit.ForRequired. to specify the For type of block to be exit.FunctionRequired. to specify the Function type of block to be exit.PropertyRequired. to specify the Property type of block to be exit.SubRequired. to specify the Sub type of block to be exit.

Remarks

  • The Exit Do statement provides a way to exit a Do...Loop statement. It can be used only inside a Do...Loop statement. Exit Do transfers control to the statement following the Loop statement. When used within nested Do...Loop statements, Exit Do transfers control to the loop that is one nested level above the loop where it occurs.
  • The Exit For statement provides a way to exit a For loop. It can be used only in a For...Next or For Each...Next loop. Exit For transfers control to the statement following the Next statement. When used within nested For loops, Exit For exits the current loop.
  • The Exit Function statement provides a way to exit the Function procedure immediately in which it appears. Execution continues with the statement following the statement that called the Function.
  • The Exit Property statement provides a way to exit the Property procedure Immediately in which it appears. Execution continues with the statement following the statement that called the Property procedure.
  • The Exit Sub statement provides a way to exit the Sub procedure Immediately in which it appears. Execution continues with the statement following the statement that called the Sub.

Requirement

1

Examples

Examples of Exit Statement

ASP VbScript Command:
<script runat="server" language="VBScript">
Dim vars,strs,cmda:varx=0
cmda=array("p")
Dim ucnt,tmp,i:ucnt=UBound(cmda):If var=1 Then:tmp="":Else:tmp="<b>vars</b>":End If:For i=0 to ucnt:tmp=tmp&"<b>"&rmv_ctrl(cmda(i))&", TypeName</b>":Next:Response.Write "Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /internet/users/sideblog/default.asp<br />"&"<i>"&tmp&"</i>"
Function dsp_x:Dim tmp_a,tmp_b,i:If varx=0  Then:Execute vars:End If:If var=1 Then:tmp_a="":Else:tmp_a=rmv_ctrl(vars):End If:For i=0 to ucnt:tmp_b=cmd_b(cmda(i)):if i/2=fix(i/2) Then:tmp_b="<b>"&tmp_b&"</b>":End If:tmp_a=tmp_a&tmp_b:Next:Response.Write "<i>"&tmp_a&"</i>":End Function
Function rmv_ctrl(blk_str):Select Case blk_str:Case chr(0):blk_str="NUL":Case chr(1):blk_str="SOH":Case chr(2):blk_str="STX":Case chr(3):blk_str="ETX":Case chr(4):blk_str="EOT":Case chr(5):blk_str="ENQ":Case chr(6):blk_str="ACK":Case chr(7):blk_str="BEL":Case chr(8):blk_str="BS":Case chr(9):blk_str="HT":Case chr(10):blk_str="LF":Case chr(11):blk_str="VT":Case chr(12):blk_str="FF":Case chr(13):blk_str="CR":Case chr(14):blk_str="SO":Case chr(15):blk_str="SI":Case chr(16):blk_str="DLE":Case chr(17):blk_str="DC1":Case chr(18):blk_str="DC2":Case chr(19):blk_str="DC3":Case chr(20):blk_str="DC4":Case chr(21):blk_str="NAK":Case chr(22):blk_str="SYN":Case chr(23):blk_str="ETB":Case chr(24):blk_str="CAN":Case chr(25):blk_str="EM":Case chr(26):blk_str="SUB":Case chr(27):blk_str="ESC":Case chr(28):blk_str="FS":Case chr(29):blk_str="GS":Case chr(30):blk_str="RS":Case chr(31):blk_str="US":Case chr(127):blk_str="DEL":End Select:rmv_ctrl=blk_str:If IsNull(blk_str) OR IsEmpty(Blk_str) OR blk_str="" OR IsNumeric(Blk_str) Then:Else:rmv_ctrl=Replace(Replace(Replace(Replace(Replace(blk_str,"&","&amp;"),"  "," &nbsp;"),"""","&quot;"),"<","&lt;"),">","&gt;"): End If :End Function
Function cmd_b(blk_str):cmd_b="["&cmd_x(blk_str)&"], "&cmd_x("TypeName("&blk_str&")"):End Function
Function cmd_x(blk_str):On Error Resume Next:Dim xans, tmp:xans="":tmp="":execute "xans="&blk_str:If Err.Number <> 0  Then:xans=cmd_x("TypeName("&blk_str&")"):Select Case xans:Case 9::Case Else:xans="error":End Select:End If:If IsArray(xans)=False Then:cmd_x=rmv_ctrl(xans): Else:tmp=lst_arry(xans):cmd_x=trim(tmp):End If:End Function
Function lst_arry(blk_str):Dim tmp,i,q:q="""":tmp="":For i=0 to UBound(blk_str):if VarType(blk_str(i))>1 And VarType(blk_str(i))<6 Then:q="'":End If:tmp=tmp&" "&q&rmv_ctrl(blk_str(i))&q:Next:lst_arry=trim(tmp):End Function

vars="For i=1 to 3:p=i:Exit For:Next":dsp_x
vars="i=4:Do While i<10:p=i+1:Exit Do:Loop":dsp_x
vars="Sub sub1:i=3:p=i:Exit Sub:p=9:End Sub:sub1":dsp_x
vars="Function sub1:i=7:p=i:Exit Function:p=9:End Function:sub1":dsp_x
'vars="Class xclass:Private a:Private b:Private Sub Class_Initialize:a = """":b = 0:End Sub:Public Property Get xa:xa = a:End Property:Public Property Let xa(stra):a = stra:End Property:Public Property Get xb:xb = b:End Property:Public Sub Incb(numb):b=b+numb:End Sub:End Class:set d=New xclass":dsp_x
vars="Class xclass:Public Property Get xa:xa=9:Exit Property:xa=1:End Property:End Class:set d=New xclass:p=d.xa":dsp_x
</script>
HTML Web Page In-line Output:
Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /internet/users/sideblog/default.asp
varsp, TypeNameFor i=1 to 3:p=i:Exit For:Next[1], Integeri=4:Do While i<10:p=i+1:Exit Do:Loop[5], IntegerSub sub1:i=3:p=i:Exit Sub:p=9:End Sub:sub1[3], IntegerFunction sub1:i=7:p=i:Exit Function:p=9:End Function:sub1[7], IntegerClass xclass:Public Property Get xa:xa=9:Exit Property:xa=1:End Property:End Class:set d=New xclass:p=d.xa[9], Integer

With Statement

last updated 11/24/2017

to execute a series of statements on a single object.

Syntax

With object
   statements
End With

Argument

WithRequired. to indicate the start of With.objectRequired. to specify the name of an object or a function that returns an object.statementsRequired. One or more statements to be executed on object.End WithRequired. to indicate the end of With.

Remarks

  • The With statement is used to perform a series of statements on a specified object without requalifying the name of the object. For example, to change a number of different properties on a single object, place the property assignment statements within the With control structure, referring to the object once instead of referring to it with each property assignment.
  • While property manipulation is an important aspect of With functionality, it is not the only use. Any legal code can be used within a With block.
  • Once a With block is entered, object can't be changed. In other words, a single With statement cannot be used to affect a number of different objects.
  • With statements can be nested by placing one With block within another. However, because members of outer With blocks are masked within the inner With blocks, a fully qualified object reference must be provided in an inner With block to any member of an object in an outer With block.
  • Never jump into or out of With blocks. If statements in a With block are executed, but either the With or End With statement is not executed, either unpredictable behavior or errors may be resulted.

Requirement

5

Examples

Examples of With Statement

ASP VbScript Command:
<script runat="server" language="VBScript">
Dim vars,strs,cmda:varx=1
cmda=array("d.xa","d.xb")
Dim ucnt,tmp,i:ucnt=UBound(cmda):If var=1 Then:tmp="":Else:tmp="<b>vars</b>":End If:For i=0 to ucnt:tmp=tmp&"<b>"&rmv_ctrl(cmda(i))&", TypeName</b>":Next:Response.Write "Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /internet/users/sideblog/default.asp<br />"&"<i>"&tmp&"</i>"
Function dsp_x:Dim tmp_a,tmp_b,i:If varx=0  Then:Execute vars:End If:If var=1 Then:tmp_a="":Else:tmp_a=rmv_ctrl(vars):End If:For i=0 to ucnt:tmp_b=cmd_b(cmda(i)):if i/2=fix(i/2) Then:tmp_b="<b>"&tmp_b&"</b>":End If:tmp_a=tmp_a&tmp_b:Next:Response.Write "<i>"&tmp_a&"</i>":End Function
Function rmv_ctrl(blk_str):Select Case blk_str:Case chr(0):blk_str="NUL":Case chr(1):blk_str="SOH":Case chr(2):blk_str="STX":Case chr(3):blk_str="ETX":Case chr(4):blk_str="EOT":Case chr(5):blk_str="ENQ":Case chr(6):blk_str="ACK":Case chr(7):blk_str="BEL":Case chr(8):blk_str="BS":Case chr(9):blk_str="HT":Case chr(10):blk_str="LF":Case chr(11):blk_str="VT":Case chr(12):blk_str="FF":Case chr(13):blk_str="CR":Case chr(14):blk_str="SO":Case chr(15):blk_str="SI":Case chr(16):blk_str="DLE":Case chr(17):blk_str="DC1":Case chr(18):blk_str="DC2":Case chr(19):blk_str="DC3":Case chr(20):blk_str="DC4":Case chr(21):blk_str="NAK":Case chr(22):blk_str="SYN":Case chr(23):blk_str="ETB":Case chr(24):blk_str="CAN":Case chr(25):blk_str="EM":Case chr(26):blk_str="SUB":Case chr(27):blk_str="ESC":Case chr(28):blk_str="FS":Case chr(29):blk_str="GS":Case chr(30):blk_str="RS":Case chr(31):blk_str="US":Case chr(127):blk_str="DEL":End Select:rmv_ctrl=blk_str:If IsNull(blk_str) OR IsEmpty(Blk_str) OR blk_str="" OR IsNumeric(Blk_str) Then:Else:rmv_ctrl=Replace(Replace(Replace(Replace(Replace(blk_str,"&","&amp;"),"  "," &nbsp;"),"""","&quot;"),"<","&lt;"),">","&gt;"): End If :End Function
Function cmd_b(blk_str):cmd_b="["&cmd_x(blk_str)&"], "&cmd_x("TypeName("&blk_str&")"):End Function
Function cmd_x(blk_str):On Error Resume Next:Dim xans, tmp:xans="":tmp="":execute "xans="&blk_str:If Err.Number <> 0  Then:xans=cmd_x("TypeName("&blk_str&")"):Select Case xans:Case 9::Case Else:xans="error":End Select:End If:If IsArray(xans)=False Then:cmd_x=rmv_ctrl(xans): Else:tmp=lst_arry(xans):cmd_x=trim(tmp):End If:End Function
Function lst_arry(blk_str):Dim tmp,i,q:q="""":tmp="":For i=0 to UBound(blk_str):if VarType(blk_str(i))>1 And VarType(blk_str(i))<6 Then:q="'":End If:tmp=tmp&" "&q&rmv_ctrl(blk_str(i))&q:Next:lst_arry=trim(tmp):End Function

vars="Class xclass:Private a:Private b:Private Sub Class_Initialize:a = """":b = 0:End Sub:Public Property Get xa:xa = a:End Property:Public Property Let xa(stra):a = stra:End Property:Public Property Get xb:xb = b:End Property:Public Sub Incb(numb):b=b+numb:End Sub:End Class:set d=New xclass":Execute vars:dsp_x
vars="With d:.xa=""stra"":.incb(3):End With":Execute vars:dsp_x
vars="With d:.xa=""strb"":.incb(1):End With":Execute vars:dsp_x
</script>
HTML Web Page In-line Output:
Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /internet/users/sideblog/default.asp
varsd.xa, TypeNamed.xb, TypeNameClass xclass:Private a:Private b:Private Sub Class_Initialize:a = "":b = 0:End Sub:Public Property Get xa:xa = a:End Property:Public Property Let xa(stra):a = stra:End Property:Public Property Get xb:xb = b:End Property:Public Sub Incb(numb):b=b+numb:End Sub:End Class:set d=New xclass[], String[0], IntegerWith d:.xa="stra":.incb(3):End With[stra], String[3], IntegerWith d:.xa="strb":.incb(1):End With[strb], String[4], Integer

Sideway BICK Blog

01/05


Copyright © 2000-2020 Sideway . All rights reserved Disclaimerslast modified on 26 January 2013