arrays – ASP经典中的数组合并
发布时间:2020-12-16 07:02:51 所属栏目:asp.Net 来源:网络整理
导读:我正在为ASP classic工作一个array_merge函数.我有什么似乎工作,直到一个(或两个)参数是空的或不是数组.这是我到目前为止所拥有的: function array_merge(left,right) dim total_size dim i dim merged ' Convert "left" to an array if not isArray(left)
我正在为ASP classic工作一个array_merge函数.我有什么似乎工作,直到一个(或两个)参数是空的或不是数组.这是我到目前为止所拥有的:
function array_merge(left,right) dim total_size dim i dim merged ' Convert "left" to an array if not isArray(left) then left = Array(left) end if ' Convert "right" to an array if not isArray(right) then right = Array(right) end if ' Start with "left" and add the elements of "right" right_size = ubound(right) total_size = ubound(left) + right_size + 1 merged = left redim preserve merged(total_size) for i = 0 to ubound(right) merged(right_size + i + 1) = right(i) next ' Return value array_merge = merged end function 我收到错误: Error Type: Microsoft VBScript runtime (0x800A01B6) Object doesn't support this property or method: 'merged' /_inc/nav/left-nav.inc,line 21 从合并的行(right_size i 1)= right(i).关于我哪里出错的任何智慧? 解决方法
LittleBobbyTables是对的,你应该改变参数.
我认为根据您的输入,对象的额外检查可以解决您的问题 function array_merge(left,right) dim right_size dim total_size dim i dim merged ''// Convert "left" to an array if not isArray(left) then left = Array(left) end if ''// Convert "right" to an array if not isArray(right) then right = Array(right) end if ''// Start with "left" and add the elements of "right" right_size = ubound(right) total_size = ubound(left) + right_size + 1 merged = array() redim merged(total_size) dim counter : counter = 0 for i = lbound(left) to ubound(left) if isobject(left(i))then set merged(counter) = left(i) else merged(counter) = left(i) end if counter=counter+1 next for i = lbound(right) to ubound(right) if isobject(right(i))then set merged(counter) = right(i) else merged(counter) = right(i) end if next ''// Return value array_merge = merged end function 一些测试代码: dim a: a=100 dim b: b=200 dim c: set c=nothing dim d: set d=nothing dim e: set e=server.createobject("scripting.filesystemobject") dim f: set f=server.createobject("scripting.filesystemobject") dim x,y,z,zz x = array_merge(a,b) y = array_merge(c,d) z = array_merge(e,f) zz = array_merge(a,e) response.write x(0) response.write x(1) ''// Accessing Nothing Values throw Error ''//response.write y(0) ''//response.write y(1) response.write z(0).GetExtensionName("test.doc") response.write z(1).GetExtensionName("test.doc") response.write zz(0) response.write zz(1).GetExtensionName("test.doc") (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 搜索elmah错误日志文件(也许在1000年代)
- RegisterServices中的NinjectWebCommon绑定在WebApi中不适用
- ASP.NET 強制設定開啟或是關閉相容性檢視
- 在ASP.NET中托管时找不到端点
- asp.net-mvc – WCF Web Api作为asp.net mvc 3应用程序的子
- asp.net – 在代码GZipping中的IIS压缩?
- asp.net-core – 我为什么要选择带有.Net核心的ASP.NET Cor
- ASP.NET WebApi使用Swagger做接口文档
- asp.net-mvc – 如何从ActionExecuting过滤器中获取路由值?
- asp.net – 我今天应该使用什么DOCTYPE?
推荐文章
站长推荐
- asp.net-mvc – 我必须附加什么进程才能使用IIS
- asp.net-web-api – 带有OWIN OAuth承载令牌的We
- asp.net – jQuery无法在我的主机上运行?
- asp.net-mvc – 如何在Require.js中引用捆绑的js
- asp.net-core – 为什么在我的ASP.NET Core 1.0(
- asp.net-mvc – 当我尝试在我的asp.net mvc中导入
- asp.net – 从源代码管理中排除app.config?
- asp.net – 使PDF显示内联而不是单独的Acrobat R
- asp.net-mvc – 可以使用“Bundle.Include”(在A
- asp.net-mvc – 在ASP.NET MVC应用程序中进行分页
热点阅读