I was really worrying about this one :)

Thanks!

Norman Elton

-----Original Message-----
From: Dave Watts [mailto:[EMAIL PROTECTED]]
Sent: Sunday, August 06, 2000 2:16 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE: Dynamic Variable Problems


> I am having problems with a setting a dynamic variable. I'm
> trying to set TempArray[1].GroupAccess[1] to some value. It
> is an array inside a struct, inside an array (whew!)
>
> I can execute...
>
>       <CFSET TempArray[1].GroupAccess[1] = "hi">
>
> ...just fine. But if I try...
>
>       <CFSET VarName = "TempArray[1].GroupAccess[1]">
>       <CFSET "#VarName#" = "hi">
>
> ... I get an error message saying that the variable name is illegal!

Keep in mind that the syntax you're using for setting dynamic variables is
unsupported; you should probably use the SetVariable function instead - it's
a lot less likely to accidentally disappear in future versions of CF.

Besides that, though, there's a bigger problem, which would prevent you from
using SetVariable in this case as well. That problem is that a member of an
array isn't exactly the same as a "variable" from CF's perspective. The
array itself is a variable, but if for example you attempt to check for an
array member's existence using IsDefined, you'll get an error there as well.

Instead, you could do something like this:

<cfset rs = Evaluate("ArrayAppend(TempArray[1].GroupAccess, 'hi')")>

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444

----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to