Search code examples
listcoldfusioncoldfusion-2016

Proper syntax for ListGetAt


I am getting a custom script error when trying to execute the following code. I might not have the proper syntax. I have googled ListGetAt examples and not able to find anything relevant. Thank you so much.

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

Solution

  • You need to check the length of the list. I don't really understand what you are trying to achieve here but here would be the equivalent code with a length check...

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