www.91084.com

GVKun编程网logo

asp-classic – 带参数的vbscript:getref(vbs function参数)

18

此处将为大家介绍关于asp-classic–带参数的vbscript:getref的详细内容,并且为您解答有关vbsfunction参数的相关问题,此外,我们还将为您介绍关于2011-08-03Mus

此处将为大家介绍关于asp-classic – 带参数的vbscript:getref的详细内容,并且为您解答有关vbs function参数的相关问题,此外,我们还将为您介绍关于2011-08-03 Music Genre classification Scripts、ACCESS的参数化查询,附VBSCRIPT(ASP)和C#(ASP.NET)函数、ACCESS的参数化查询,附VBSCRIPT(ASP)和C#(ASP.NET)函数第1/2页、asp(vbscript)中自定义函数的默认参数实现代码的有用信息。

本文目录一览:

asp-classic – 带参数的vbscript:getref(vbs function参数)

asp-classic – 带参数的vbscript:getref(vbs function参数)

谁有经验将参数传递给使用getref调用的函数?
下面的代码只是一个例子,dons’t不工作,如何将参数传递给mySub子?

<button id="myBtn">Click me</button>

<script type="text/vbscript">
  document.getElementById("myBtn").onclick=GetRef("mySub") 

  Sub mySub(parameter)
   alert(parameter)
  End Sub
</script>

解决方法

首先看 at this article about event handling(任何人都知道更好的参考?)来获取上下文:

The code provided in the onclick attribute will be called when the
user clicks on the text enclosed in the span. This mechanism is great
for small snippets of code,but it becomes cumbersome when you have a
lot of script. This event mechanism works with both VBScript and
JScript.

What happens behind the scenes is that Internet Explorer calls into
the script engine with the script code and tells the engine to create
an anonymous function (a function with no name). Those of you who kNow
VBScript are probably wondering how it does this,since VBScript
doesn’t support anonymous functions. VBScript actually creates a
subroutine called “anonymous” containing the script and returns a
pointer to the function that is then hooked up to the event.

然后试试这个.hta:

<html>
 <!-- !! https://stackoverflow.com/questions/10741292/vbscript-getref-with-parameter
 -->
 <head>
  <title>GetRef HTA</title>
  <HTA:APPLICATION
    APPLICATIONNAME="GetRef HTA"
  >
  <SCRIPT Language="VBScript">
   Sub SetClickHandlers()
     Set bttB.onClick = GetRef("noparmsBttB")
     Set bttE.onClick = GetRef("Magic")
     Set bttF.onClick = GetRef("Magic")
   End Sub
   ' trivial handler,literally set
   Sub noparmsBttA()
     Log "noparmsBttA() called."
   End Sub
   ' trivial handler,set via GetRef
   Sub noparmsBttB()
     Log "noparmsBttB() called."
   End Sub
   ' one handler for many buttons,literally set
   Sub handleClickCD(oBtt)
     Log "handleClickCD() called; you clicked " & oBtt.id
   End Sub
   ' one handler for many buttons,set via Magic() & GetRef
   Sub handleClickEF(oBtt,dtWhen)
     Log "handleClickEF() called; you clicked " & oBtt.id & " at " & CStr(dtWhen)
   End Sub
   ' stuffed via GetRef into onClick
   Sub Magic()
     handleClickEF Me,Now
   End Sub
   Sub Log(s)
     MsgBox s,Now
   End Sub
  </SCRIPT>
 </head>
  <body onLoad="SetClickHandlers">
   <!-- literal onClick handler in html code -->
   <button id="bttA" onClick="noparmsBttA">A</button>
   <!-- no literal onClick handler,will be set by SetClickHandlers via GetRef() -->
   <button id="bttB">B</button>
   <!-- literal onClick handlers with parameter (Me,i.e. the Button) -->
   <button id="bttC" onClick="handleClickCD Me">C</button>
   <button id="bttD" onClick="handleClickCD Me">D</button>
   <!-- Two params handler via SetClickHandlers & Magic -->
   <button id="bttE">E</button>
   <button id="bttF">F</button>
 </body>
</html>

查看

>那个/如何指定没有参数的Sub来按字面意思或通过GetRef处理点击(A或B)
>你可以使用一个参数化的Sub来处理许多按钮的点击,因为引擎将文字代码放入一个匿名的Sub(没有参数)(C / D)
>你不能使用GetRef(“SubWithLotsOfParms”)来设置onClick属性 – 它需要没有参数的s Sub
>你可以让一个没有参数的命名Sub(例如Magic)做引擎匿名的工作;这个Sub然后可以与GetRef一起使用

WRT Salman A的回答:

如果您确实需要一条错误消息,例如:

---------------------------
Error
---------------------------
A Runtime Error has occurred.
Do you wish to Debug?

Line: 54
Error: Wrong number of arguments or invalid property assignment: 'mySub'
---------------------------
Yes   No   
---------------------------

然后你只需要添加:

Sub mySub(parameter)
     alert(parameter.toString())
   End Sub

<!-- literal onClick handler in html code -->
   <button id="bttG" onClick="mySub">G</button>

测试.hta.

WRT彼得的建议 – 保持简单是值得的:

Option Explicit
Sub WithLotsOfParms(a,b,c,d)
  WScript.Echo Join(Array(a,d))
End Sub
Dim f : Set f = GetRef("WithLotsOfParms")
WithLotsOfParms 1,2,3,4
f               1,4

输出:

cscript 01.vbs
1 2 3 4
1 2 3 4

您使用GetRef()设置的变量名称与您使用文字子/函数名称完全一样,可能已在昨天建立.

2011-08-03 Music Genre classification Scripts

2011-08-03 Music Genre classification Scripts

scripts:

(1) Batch extract all the feature sets using OpenSmile:    

perl stddirectory_smileextract.pl /home/sudan/Desktop/research/MusicGenreClassification/genres_16k_mono_wav/ emobase.conf out.arff

(2) Using bextract to do the prediction (with all the feature sets in bextract)

bextract -sv -timbral -spfe -chroma -sfm -scf -lsp -lpcc genrES10.mf -tc testdata_2.mf -w temp.arff

(3)Using bextract to do the prediction (with only the timbral feature sets in bextract)(3) 

bextract -sv -timbral genrES10.mf -tc testdata_2.mf -w temp.arff


Even though the recognition results seems better for (3) over (2),it is still not make so much sense at all.


(4) add a plain line betweent the test mf file   awk '{print $1 "\n"}' testdata_2.mf >testdata_2_double.mf

(5) USing weka's SMO to do the prediction:

 java -xms1024m weka.classifiers.functions.SMO -t /home/sudan/Desktop/research/MusicGenreClassification/features_all_temp.arff -c last -T /home/sudan/Desktop/research/MusicGenreClassification/testdata_3.arff -p 0 -o > pred.out

ACCESS的参数化查询,附VBSCRIPT(ASP)和C#(ASP.NET)函数

ACCESS的参数化查询,附VBSCRIPT(ASP)和C#(ASP.NET)函数

最近因项目需要用ACCESS做数据库开发WEB项目
看论坛上还许多人问及ACCESS被注入的安全问题
许多人解决的方法仍然是用Replace替换特殊字符,然而这样做也并没有起到太大做用
今天我就把我用ACCESS参数化查询的一些方法和经验和大家分享
希望对大家有所启发,有写的不对的地方希望高手们多多指教

ASP.NET 用OleDbCommand的new OleDbParameter创建参数货查询
ASP用Command的CreateParameter 方法创建参数化查询
(sql储存过程查询也是用这个方法建立的)

ASP.NET C#语法
----------------------------------------------------------------------------

复制代码 代码如下:

OleDbParameter parm = new OleDbParameter(Name, Type, Direction, Size, Value);
(实际上它有七重载大家具体大家可以在VS.net里面就可以看到)
参数
Name        可选,字符串,代表 Parameter 对象名称。
Type        可选,长整型值,指定 Parameter 对象数据类型。
Direction   可选,长整型值,指定 Parameter 对象类型。。
Size        可选,长整型值,指定参数值最大长度(以字符或字节数为单位)。
Value       可选,变体型,指定 Parameter 对象的值。
以下是实例,查询news表中所有tsing发表的新闻
  -------------------------------------------------------
  sql="select * from newss where username=? order by id"
 //注意查询的条件均用?号表示
  OleDbConnection conn = new OleDbConnection(connString);
  OleDbCommand cmd = new OleDbCommand(sql,conn); 
  OleDbParameter parm = new OleDbParameter("temp",OleDbType.VarChar, 50);
  //temp为Parameter对象可随便定义,OleDbType.VarChar指定为字符串,长度50
  parm.Direction = ParameterDirection.Input;
  //指定其类型输入参数
  cmd.Parameters.Add(parm);
 cmd.Parameters["temp"].Value = "tsing";
  //查询tsing,也可以写成cmd.Parameters[0]
 conn.open();
 cmd.ExecuteReader();

----------------------------------------------------------------------------
ASP VBSCRIPT语法
----------------------------------------------------------------------------

复制代码 代码如下:

Set parameter = command.CreateParameter (Name, Value)
参数同上
以下是实例,查询news表中所有tsing发表的新闻
  ------------------------------------------------------
  et conn = Server.CreateObject("Adodb.Connection")
  conn.ConnectionString = connString
  conn.open()
  set mycmd = Server.CreateObject("ADODB.Command")
  mycmd.ActiveConnection=conn
  mycmd.CommandText=sql
  mycmd.Prepared = true
  set mypar = mycmd.CreateParameter("temp",129,1,50,"tsing")
  mycmd.Parameters.Append mypar
  set myrs = mycmd.Execute

---------------------------------------------------------------------------
与上面基本相同不同的地方法是asp在对参数的表达上面不同
  129为adChar,1就是指示输入参数(是其实是默认值)
大家请参阅MICROSOFT的ADOVB.Inc:

复制代码 代码如下:

  '----   ParameterDirectionEnum   Values   ----   
  Const   adParamUnkNown   =   0   
  Const   adParamInput   =   1   
  Const   adParamOutput   =   2   
  Const   adParamInputOutput   =   3   
  Const   adParamReturnValue   =   4  
'----   DataTypeEnum   Values   ----   
  Const   adEmpty   =   0   
  Const   adtinyint   =   16   
  Const   adSmallInt   =   2   
  Const   adInteger   =   3   
  Const   adBigInt   =   20   
  Const   adUnsignedtinyint   =   17   
  Const   adUnsignedSmallInt   =   18   
  Const   adUnsignedInt   =   19   
  Const   adUnsignedBigInt   =   21   
  Const   adSingle   =   4   
  Const   adDouble   =   5   
  Const   adCurrency   =   6   
  Const   adDecimal   =   14   
  Const   adNumeric   =   131   
  Const   adBoolean   =   11   
  Const   adError   =   10   
  Const   adUserDefined   =   132   
  Const   adVariant   =   12   
  Const   adIdispatch   =   9   
  Const   adIUnkNown   =   13   
  Const   adGUID   =   72   
  Const   adDate   =   7   
  Const   adDBDate   =   133   
  Const   adDBTime   =   134   
  Const   adDBTimeStamp   =   135   
  Const   adBSTR   =   8   
  Const   adChar   =   129   
  Const   adVarChar   =   200   
  Const   adLongVarChar   =   201   
  Const   adWChar   =   130   
  Const   adVarWChar   =   202   
  Const   adLongVarWChar   =   203   
  Const   adBinary   =   128   
  Const   adVarBinary   =   204   
  Const   adLongVarBinary   =   205 

当前1/2页 12下一页阅读全文

ACCESS的参数化查询,附VBSCRIPT(ASP)和C#(ASP.NET)函数第1/2页

ACCESS的参数化查询,附VBSCRIPT(ASP)和C#(ASP.NET)函数第1/2页

ACCESS的参数化查询,附VBSCRIPT(ASP)和C#(ASP.NET)函数

最近因项目需要用ACCESS做数据库开发WEB项目
看论坛上还许多人问及ACCESS被注入的安全问题
许多人解决的方法仍然是用Replace替换特殊字符,然而这样做也并没有起到太大做用
今天我就把我用ACCESS参数化查询的一些方法和经验和大家分享
希望对大家有所启发,有写的不对的地方希望高手们多多指教

ASP.NET 用OleDbCommand的new OleDbParameter创建参数货查询
ASP用Command的CreateParameter 方法创建参数化查询
(SQL储存过程查询也是用这个方法建立的)

ASP.NET C#语法
----------------------------------------------------------------------------

代码如下:
OleDbParameter parm = new OleDbParameter(Name, Type, Direction, Size, Value);
(实际上它有七重载大家具体大家可以在VS.net里面就可以看到)
参数
Name 可选,字符串,代表 Parameter 对象名称。
Type 可选,长整型值,指定 Parameter 对象数据类型。
Direction 可选,长整型值,指定 Parameter 对象类型。。
Size 可选,长整型值,指定参数值最大长度(以字符或字节数为单位)。
Value 可选,变体型,指定 Parameter 对象的值。
以下是实例,查询news表中所有tsing发表的新闻
-------------------------------------------------------
sql="select * from newss where username=? order by id"
 //注意查询的条件均用?号表示
OleDbConnection conn = new OleDbConnection(connString);
OleDbCommand cmd = new OleDbCommand(sql,conn);
OleDbParameter parm = new OleDbParameter("temp",OleDbType.VarChar, 50);
//temp为Parameter对象可随便定义,OleDbType.VarChar指定为字符串,长度50
parm.Direction = ParameterDirection.Input;
//指定其类型输入参数
cmd.Parameters.Add(parm);
 cmd.Parameters["temp"].Value = "tsing";
//查询tsing,也可以写成cmd.Parameters[0]
 conn.Open();
 cmd.ExecuteReader();

----------------------------------------------------------------------------
ASP VBSCRIPT语法
----------------------------------------------------------------------------

代码如下:
Set parameter = command.CreateParameter (Name, Type, Direction, Size, Value)
参数同上
以下是实例,查询news表中所有tsing发表的新闻
------------------------------------------------------
et conn = Server.CreateObject("Adodb.Connection")
conn.ConnectionString = connString
conn.open()
set mycmd = Server.CreateObject("ADODB.Command")
mycmd.ActiveConnection=conn
mycmd.CommandText=sql
mycmd.Prepared = true
set mypar = mycmd.CreateParameter("temp",129,1,50,"tsing")
mycmd.Parameters.Append mypar
set myrs = mycmd.Execute

---------------------------------------------------------------------------
与上面基本相同不同的地方法是asp在对参数的表达上面不同
129为adChar,1就是指示输入参数(是其实是默认值)
大家请参阅MICROSOFT的ADOVB.Inc:

代码如下:
''---- ParameterDirectionEnum Values ----
Const adParamUnknown = 0
Const adParamInput = 1
Const adParamOutput = 2
Const adParamInputOutput = 3
Const adParamReturnValue = 4
''---- DataTypeEnum Values ----
Const adEmpty = 0
Const adTinyInt = 16
Const adSmallInt = 2
Const adInteger = 3
Const adBigInt = 20
Const adUnsignedTinyInt = 17
Const adUnsignedSmallInt = 18
Const adUnsignedInt = 19
Const adUnsignedBigInt = 21
Const adSingle = 4
Const adDouble = 5
Const adCurrency = 6
Const adDecimal = 14
Const adNumeric = 131
Const adBoolean = 11
Const adError = 10
Const adUserDefined = 132
Const adVariant = 12
Const adIDispatch = 9
Const adIUnknown = 13
Const adGUID = 72
Const adDate = 7
Const adDBDate = 133
Const adDBTime = 134
Const adDBTimeStamp = 135
Const adBSTR = 8
Const adChar = 129
Const adVarChar = 200
Const adLongVarChar = 201
Const adWChar = 130
Const adVarWChar = 202
Const adLongVarWChar = 203
Const adBinary = 128
Const adVarBinary = 204
Const adLongVarBinary = 205

asp(vbscript)中自定义函数的默认参数实现代码

asp(vbscript)中自定义函数的默认参数实现代码

现代语言的函数中都可以带有默认参数,在vbscript系统内建的函数可以带有可选值(如常用的 split()等等),然而我们自己定义的函数中无法具有此功能.

下面提供一个方法实现可选参数的功能.

functin foo(dtype, dsize, value)
   dim a, b
   if TypeName(dtype) <> "Error" Then
       a = dtype
   else
       a = "default value"
   end if
   If TypeName(dsize) <> "Error" Then
       b = dsize
   else
       b = -1
   end if
   .
end function

如示例代码所示, foo函数中dtype, dsize均为可选函数,调用时可以传参数,也可不传参数.当不传参数的时候,逗号占位符不能丢了,即应该使用 foo(,,"myvalue") 的形式.

今天关于asp-classic – 带参数的vbscript:getrefvbs function参数的分享就到这里,希望大家有所收获,若想了解更多关于2011-08-03 Music Genre classification Scripts、ACCESS的参数化查询,附VBSCRIPT(ASP)和C#(ASP.NET)函数、ACCESS的参数化查询,附VBSCRIPT(ASP)和C#(ASP.NET)函数第1/2页、asp(vbscript)中自定义函数的默认参数实现代码等相关知识,可以在本站进行查询。

本文标签:

上一篇asp.net – 在Appharbor上的Dotless(asp.net app_data)

下一篇asp.net-mvc – 为什么Asp.net MVC4不能使用SQL Server会话状态存储的cookieless