Sideway BICK BlogSideway BICK BLOG from Sideway

A Sideway to Sideway Home

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

Script, Scripting Language, VBScript elements, Server-Side VBScript GetOject, CreatObject, GetRef, LoadPicture Function

VBScript Script Engine Functions

Functions for manipulating local of engine.

GetObject Function

last updated 9/19/2017

Create a reference to an automation object from a file specified by pathname argument and/or a class of the object specified by the appname and objectype argumens of the class argument.

Syntax

GetObject([pathname][, class])
class: [appname][.objectype]

Argument

pathnameOptional. Any valid string expression used to specify full path and name of the file contining the object to retrieve.classOptional but required if pathname is omitted. Any valid string expression with syntax appname.objectype containing the Class of the object to retrieve.appnameRequired. A valid string expression used to specify the Name of the application providing the object.objectypeRequired. A valid string expression used to specify the type or class of object to create.

Returns

Returns a Variant of Object data subtype containing a reference to an instance of an automation object obtained from a file specified by pathname argument and/or a class of the object specified by the appname and objectype argumens of the class argument.

Remarks

  • GetObject function is usually used to get or access an Automation object from a file speicied by pathname and to return a reference object to the specified Automation object.
  • A Set statement is used to assign the returned reference object to a object variable.
  • When executing the VBScript Set statement, the application associated with the specified pathname is started and the corresponding object of the file specified by pathname is activated.
  • For example, if pathname "R:\a.html" is a valid location of html file, a.html, execute the VBScript 'Set obj=GetObject("R:\a.html")' will create and assign a reference HTMLDocument object obtained from the file class of "R:\a.html" to obj.The file path must exist and the file extension will then activate the class object.
  • If pathname is a zero-length string, "", GetObject function returns a new object instance of the specified classs according to the specified class argument.For example, execute the VBScript 'Set obj=GetObject("","htmlfile")' will return and assign a new instance of about:blank HTMLDocument object to obj.
  • Similarly, execute the VBScript 'Set obj=GetObject("","Scripting.FileSystemObject")' will return and assign a new object instance of class with appname "Scripting" and objectype "FileSystemObjectt object" to obj.
  • If the pathname argument is omitted, GetObject function returns a currently active object of the specified type. If no object of the specified type exists or the permission is denied, an error occurs.
  • Besides, if an object has registered itself as a single-instance object, only one instance of the object is created, no matter how many times CreateObject is executed. With a single-instance object, GetObject always returns the same instance when called with the zero-length string ("") syntax, and it causes an error if the pathname argument is omitted.
  • If an application is allowed to be activited one a part of a file, an exlamation point, !, can be added to the end of the file name and followed by the string provide the application for identifying the part of the file to be activated. For example, in a drawing application, a drawing file, SCHEMA.CAD may have multiple layers, 1, 2, and 3, The VBScript 'Set LayerObject = GetObject("R:\CAD\SCHEMA.CAD!Layer3")' can be used to activate the Layer3 of SCHEMA.CAD.
  • In general, if the object'class is not specified, The Automation process determines the application to start and the object to activate based on the file name specified by pathname. But if a file supports more than one class of object, the optional class argument must be used to specify the type of object to be activate. For example, a drawing file might also have multiple parts support three different types of objects, an Application object, a Drawing object, and a Toolbar object. The VBScript 'Set MyObject = GetObject("C:\DRAWINGS\SAMPLE.DRW", "FIGMENT.DRAWING")' can be used to activate the FIGMENT application and the DRAWING type, specifed by the appname and objectype arguments of the class argument.
  • Once an object is activated, only the corresponding properties and methods can be accessed by the assigned object variable. For example, 'MyObject.Line 9, 90', 'MyObject.InsertText 9, 100, "Hello, world."', and 'MyObject.SaveAs "C:\DRAWINGS\SAMPLE.DRW"'.
  • Use the GetObject function when there is a current instance of the object or the object to be created with a file has already been loaded. Or use the CreateObject function if there is no current instance, the object is not to be started with a file loaded.

Requirement

5,2

Examples

Examples of GetObject function

ASP VbScript Command:
<script runat="server" language="VBScript">
Dim vars,strs,cmda,var:var=0
cmda=array("strs","obj1")
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="strs=""htmlfile"":strs1=""\"":Set obj1=GetObject(strs1,strs)":dsp_x
vars="strs=""htmlfile"":strs1="""":Set obj1=GetObject(strs1,strs)":dsp_x
vars="strs=""Scripting.FileSystemObject"":strs1="""":Set obj1=GetObject(strs1,strs)":dsp_x
vars="strs=""/index.htm"":Set obj1=GetObject(Server.MapPath(""/index.htm""))":dsp_x
vars="strs=""WinNT:"":Set obj1=GetObject(strs)":dsp_x
vars="strs=""winmgmts:"":Set obj1=GetObject(strs)":dsp_x
vars="strs=""LDAP:"":Set obj1=GetObject(strs)":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
varsstrs, TypeNameobj1, TypeNamestrs="htmlfile":strs1="\":Set obj1=GetObject(strs1,strs)[htmlfile], String[[object]], HTMLDocumentstrs="htmlfile":strs1="":Set obj1=GetObject(strs1,strs)[htmlfile], String[[object]], HTMLDocumentstrs="Scripting.FileSystemObject":strs1="":Set obj1=GetObject(strs1,strs)[Scripting.FileSystemObject], String[FileSystemObject], FileSystemObjectstrs="/index.htm":Set obj1=GetObject(Server.MapPath("/index.htm"))[/index.htm], String[[object]], HTMLDocumentstrs="WinNT:":Set obj1=GetObject(strs)[WinNT:], String[Object], Objectstrs="winmgmts:":Set obj1=GetObject(strs)[winmgmts:], String[SWbemServicesEx], SWbemServicesExstrs="LDAP:":Set obj1=GetObject(strs)[LDAP:], String[Object], Object

CreateObject Function

last updated 9/17/2017

Create a reference to an automation object specified by servername and typename arguments of the object on a location according to the location argument.

Syntax

CreateObject(servername.typename[, location])

Argument

servernameRequired. Any valid string expression used to specify the name of the application providing the object.typenameRequired. Any valid string expression used to specify the type or class of the object to create.locationOptional. Any valid string expression used to specify the name of the network server where the object is to be created.

Returns

Returns a Variant of Object data subtype containing a reference to a new instance of the automation object obtained by specifying the servername and typename arguments of the object on a location according to the location argument.

Remarks

  • CreateObject function is usually used to get or access an Automation object speicied by the servername and typename of the object and to return a new instance of reference object to the specified Automation object.
  • Since CreateObject function can be specified by servername and typename arguments, Automation servers always provide at least one type of object.
  • For example, a word-processing application may provide an application object, a document object, and a toolbar object.
  • A Set statement is used to assign the returned reference object to a object variable.
  • Properties and methods of the new object can then be accessed through the object variable.
  • For example, the VBScript 'Set ExcelSheet = CreateObject("Excel.Sheet")' first starts the application, Excel, to create the Microsoft Excel spreadsheet object, Sheet. A reference to the object is also created and assigns to the object variable, ExcelSheet, once the object is created. Properties and method of the new object can be accessed using the object variable, ExcelSheet, and other Excel objects, including the Application object and the ActiveSheet.Cells collection.
  • For example, 'ExcelSheet.Application.Visible = True' to make Excel visible through the Application object. 'ExcelSheet.ActiveSheet.Cells(1,1).Value = "This is column A, row 1"' to place some text in the first cell of the sheet. 'ExcelSheet.SaveAs "C:\DOCS\TEST.XLS"' to save the sheet. 'ExcelSheet.Application.Quit' to close Excel with the Quit method on the Application object. 'Set ExcelSheet = Nothing' to release the object variable.
  • Creating an object on a remote server can only be accomplished when Internet security is turned off. An object can be created on a remote networked computer by passing the name of the computer to the servername argument of CreateObject. That name is the same as the machine name portion of a share name. For a network share named "\\myserver\public", the servername is "myserver". In addition, servername can be specified using DNS format or an IP address. For example, the VBScript 'Set XLApp = CreateObject("Excel.Application", "MyServer")' is used to assign a new instance of Automation object, Excel.Application running on a remote network computer named "myserver" to object variable,XLApp.
  • An error occurs if the specified remote server does not exist or cannot be found.

Requirement

2

Examples

Examples of CreateObject function

ASP VbScript Command:
<script runat="server" language="VBScript">
Dim vars,strs,cmda,var:var=0
cmda=array("strs","obj1")
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="strs=""Scripting.Dictionary"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""Scripting.FileSystemObject"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""ADODB.Recordset"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""ADODB.Connection"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""ADODB.Command"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""ADODB.Stream"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""VBScript.RegExp"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""WScript.Shell"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""WScript.Network"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""CDO.Message"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""MicroSoft.XMLHttp"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""MicroSoft.XMLDOM"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""Microsoft.Update.Session"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""Msxml2..DOMDocument"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""Msxml2..DOMDocument.3.0"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""Msxml2..DOMDocument.4.0"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""Msxml2..DOMDocument.6.0"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""Msxml2.XMLHTTP"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""Msxml2.XMLHTTP.3.0"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""Msxml2.XMLHTTP.6.0"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""Msxml2.ServerXMLHTTP"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""Msxml2.ServerXMLHTTP.4.0"":Set obj1=CreateObject(strs)":dsp_x
vars="strs=""Msxml2.ServerXMLHTTP.6.0"":Set obj1=CreateObject(strs)":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
varsstrs, TypeNameobj1, TypeNamestrs="Scripting.Dictionary":Set obj1=CreateObject(strs)[Scripting.Dictionary], String[Dictionary], Dictionarystrs="Scripting.FileSystemObject":Set obj1=CreateObject(strs)[Scripting.FileSystemObject], String[FileSystemObject], FileSystemObjectstrs="ADODB.Recordset":Set obj1=CreateObject(strs)[ADODB.Recordset], String[], Recordsetstrs="ADODB.Connection":Set obj1=CreateObject(strs)[ADODB.Connection], String[], Connectionstrs="ADODB.Command":Set obj1=CreateObject(strs)[ADODB.Command], String[], Commandstrs="ADODB.Stream":Set obj1=CreateObject(strs)[ADODB.Stream], String[Stream], Streamstrs="VBScript.RegExp":Set obj1=CreateObject(strs)[VBScript.RegExp], String[IRegExp2], IRegExp2strs="WScript.Shell":Set obj1=CreateObject(strs)[WScript.Shell], String[IWshShell3], IWshShell3strs="WScript.Network":Set obj1=CreateObject(strs)[WScript.Network], String[IWshNetwork2], IWshNetwork2strs="CDO.Message":Set obj1=CreateObject(strs)[CDO.Message], String[IMessage], IMessagestrs="MicroSoft.XMLHttp":Set obj1=CreateObject(strs)[MicroSoft.XMLHttp], String[IServerXMLHTTPRequest2], IServerXMLHTTPRequest2strs="MicroSoft.XMLDOM":Set obj1=CreateObject(strs)[MicroSoft.XMLDOM], String[DOMDocument], DOMDocumentstrs="Microsoft.Update.Session":Set obj1=CreateObject(strs)[Microsoft.Update.Session], String[IUpdateSession3], IUpdateSession3

GetRef Function

last updated 9/19/2017

Create a reference to a procedure specified by procname argument.

Syntax

GetRef(procname)

Argument

procnameRequired. Any valid String expression used to specify the name of refered Sub of Function procedure.

Returns

Returns a Variant of Object data subtype containing a reference to a Sub of Function procedure object obtained by specifying the procname argument of the procedure.

Remarks

  • GetRef function is used to get or access a Sub or Function procedure speicied by the procname of the procedure and to return the result of the specified Sub or Function procedure.
  • In other scripting and programming languages, the functionality provided by GetRef is referred to as a function pointer for pointing to the address of a procedure to be executed when activated.
  • In fact, the GetRef function also provides a connection to bound a VBScript Sub or Function procedure as an object to any available event on a DHTML (Dynamic HTML) pages. The DHTML object model provides information about what events are available for various cobjects of the page.For example, the VBScript 'Set object.eventname = GetRef(procname)' make use of the GetRef function to get and access the reference of a Sub or Function procedure specified by procname and use the Set statement to assign the reference procedure object to an object event specified by object and event arguments.

Requirement

5

Examples

Examples of GetRef function

ASP VbScript Command:
<script runat="server" language="VBScript">
Dim vars,strs,cmda,var:var=0
cmda=array("strs","obj1")
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="strs=""cmd_b"":Set obj1=GetRef(strs)":dsp_x
vars="strs=""cmd_x"":Set obj1=GetRef(strs)":dsp_x
vars="strs=""rmv_ctrl"":Set obj1=GetRef(strs)":dsp_x
vars="strs=""lst_arry"":Set obj1=GetRef(strs)":dsp_x
vars="Function reftest():reftest=""reftestok"":End Function:strs="""":Set obj1=Nothing":Execute vars:dsp_x
vars="strs=""reftest"":obj1=TypeName(GetRef(strs))":dsp_x
vars="strs=""reftest"":Set obj1=GetRef(strs)":dsp_x
vars="strs=""reftest"":obj1=GetRef(strs)":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
varsstrs, TypeNameobj1, TypeNamestrs="cmd_b":Set obj1=GetRef(strs)[cmd_b], String[Object], Objectstrs="cmd_x":Set obj1=GetRef(strs)[cmd_x], String[Object], Objectstrs="rmv_ctrl":Set obj1=GetRef(strs)[rmv_ctrl], String[Object], Objectstrs="lst_arry":Set obj1=GetRef(strs)[lst_arry], String[Object], ObjectFunction reftest():reftest="reftestok":End Function:strs="":Set obj1=Nothing[], String[Nothing], Nothingstrs="reftest":obj1=TypeName(GetRef(strs))[reftest], String[Object], Stringstrs="reftest":Set obj1=GetRef(strs)[reftest], String[reftestok], Objectstrs="reftest":obj1=GetRef(strs)[reftest], String[reftestok], String

LoadPicture Function

last updated 9/20/2017

Create a reference to a picture object from the a file specified by picturename argument.

Syntax

LoadPicture(picturename)

Argument

picturenameRequired. Any valid string expression that is used to specify the path of the picture to be refered to.

Returns

Returns a Variant of Object data subtype containing a reference to a picture object obtained by specifying the picturename argument of a picture.

Remarks

  • ?Available only on 32-bit platforms.
  • The picturename argument is a string expression that indicates the name of the picture file to be loaded.
  • Graphics formats recognized by LoadPicture include bitmap (.bmp) files, icon (.ico) files, run-length encoded (.rle) files, metafile (.wmf) files, enhanced metafiles (.emf), GIF (.gif) files, and JPEG (.jpg) files.

Requirement

2

Examples

Examples of GetRef function

ASP VbScript Command:
<script runat="server" language="VBScript">
Dim vars,strs,cmda,var:var=0
cmda=array("strs","obj1")
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="strs="""":Set obj1=LoadPicture(Server.MapPath(""/images/favicon.ico""))":dsp_x
vars="strs=obj1.width":dsp_x
vars="strs=obj1.height":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
varsstrs, TypeNameobj1, TypeNamestrs="":Set obj1=LoadPicture(Server.MapPath("/images/favicon.ico"))[], String[131261], Picturestrs=obj1.width[159], Long[131261], Picturestrs=obj1.height[423], Long[131261], Picture

Sideway BICK Blog

07/04


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