isDefined and syntactically correct variable name

i am trying to validate the existance of a dynamicaly named variable but i am getting an error when i check it

isDefined("arrTracking[idx+1]['#langIdx#']")
Parameter 1 of function IsDefined which is now "arrTracking[idx+1]['en']" must be a syntactically valid variable name

suggestions on how i can fix this?

TIA
LVL 25
James RodgersWeb Applications DeveloperAsked:
Who is Participating?
 
gdemariaCommented:

isDefined("arrTracking[idx+1]['#langIdx#']")

It looks like you're testing for the existance of a structure element, not a variable.

<cfif structKeyExists(arrTracking[idx+1], langIdx)>

will test to see if langIdx is a key at that array location

<cfif (idx+1) le arrayLen(arrTracking)  and  structKeyExists(arrTracking[idx+1], langIdx)>

This will test the array location and then the struct key at that location


0
 
James RodgersWeb Applications DeveloperAuthor Commented:
iv solved teh processing issue by using a try-catch, but i would stil,like to know if i can use isDefined in some way

thanks
0
 
James RodgersWeb Applications DeveloperAuthor Commented:
thanks works perfectly!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.