Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 271
  • Last Modified:

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
0
James Rodgers
Asked:
James Rodgers
  • 2
1 Solution
 
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
 
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:
thanks works perfectly!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now