Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ListGetAt的正确语法_List_Coldfusion_Coldfusion 2016 - Fatal编程技术网

ListGetAt的正确语法

ListGetAt的正确语法,list,coldfusion,coldfusion-2016,List,Coldfusion,Coldfusion 2016,我在尝试执行以下代码时遇到一个自定义脚本错误。我可能没有正确的语法。我在谷歌上搜索了ListGetAt示例,但找不到任何相关内容。非常感谢你 if(NOT isDefined(listGetAt(url.d,2,"/"))){ writeOutput("You're not allow to access the directory."); } url.d=“1/2”; if(未定义(listGetAt(url.d,2,“/”)){ writeOutput(“不允许您访问目录”);

我在尝试执行以下代码时遇到一个自定义脚本错误。我可能没有正确的语法。我在谷歌上搜索了
ListGetAt
示例,但找不到任何相关内容。非常感谢你

if(NOT isDefined(listGetAt(url.d,2,"/"))){
    writeOutput("You're not allow to access the directory.");
}

url.d=“1/2”;
if(未定义(listGetAt(url.d,2,“/”)){
writeOutput(“不允许您访问目录”);
}
嗨,李忠, 我认为您的url.d值没有该列表值中的第二个元素。我试图重现那个索引错误。我得到了相同的索引错误。我为您的测试目的添加了一个示例代码。请试一试。
谢谢

您需要检查列表的长度。我真的不明白你想在这里实现什么,但这里有一个长度检查的等效代码

if(NOT listLen(url.d,"/") gte 2){
    writeOutput("You're not allow to access the directory.");
}

确切的错误是什么?url.d的值是什么?您希望发生什么?我也不清楚预期的结果,但是IsDefined()可能不是这里使用的正确函数。它用于确定给定的变量名是否存在。看起来更像是在测试列表中有多少个元素。如果是这样,请参阅。还要注意,
listGetAt()
可能引发索引越界异常,例如,如果
url.d
不包含任何
/
字符(列表将只有1个元素,因此访问第2个元素会导致错误)。您好,Dan Roberts,这似乎正在工作。我正在仔细检查我的申请表以确定。我很快会和你确认的。谢谢你的回复和分享。我只是想确认一下这是否成功。非常感谢你,丹!谢谢大家!注意安全!
if(NOT listLen(url.d,"/") gte 2){
    writeOutput("You're not allow to access the directory.");
}