I've got a query that I run over a couple of dozen times; once for
each field returned by the query.  The idea is to build lists from
each set of field values, and then generate cfscript code out of it,
like so:

myField1="Y,N,Y,Y,Y,N,N";
myField2="A,A,A,B,G,A,B";

I have code that does this (below).  However, I am calling what is
essentially the same code block over and over, with the only
difference being the unique field name being passed in.  Seems this
would be perfect for a udf, but so far I can't get it to work (the
fact that this is my first attempt to write a function might have
something to do with it).  

I've gotten to the point where I can get the function to run, but
CF just laughs at me:

"Complex object types cannot be converted to simple values."

I'm a rookie at this.  Can someone spin me around and point me in
the right direction?  I'm missing something(s) dumb here.

--------------------------------------------
Matt Robertson       [EMAIL PROTECTED]
MSB Designs, Inc.  http://mysecretbase.com
--------------------------------------------

// the current working (repeated) code
LoopStep=1;
TheList="";
do {
TheList=TheList & GetFields.myField1[LoopStep] & ",";
LoopStep=LoopStep+1;
} while (LoopStep LTE GetFields.RecordCount);
if (Len(TheList)){
TheList=Left(TheList,Len(TheList)-1);
}
myCfg=myCfg & "blah=""#TheList#"";" & chr(10);

// what I'd like to be able to do:
myCfg=myCfg & "blah=""#myFunction("myField1",GetFields)#"";" & chr(10);
myCfg=myCfg & "foo=""#myFunction("myField2",GetFields)#"";" & chr(10);

// and my latest attempt at the function
function myFunction(FieldInput,query){
StuffToAdd="";
LoopStep=1;
do {
StuffToAdd=StuffToAdd & query[FieldInput][LoopStep] &
",";
LoopStep=LoopStep+1;
} while (LoopStep LTE GetFields.RecordCount);
if (Len(StuffToAdd)){
StuffToAdd=Left(StuffToAdd,Len(StuffToAdd)-1);
}
return StuffToAdd;
}
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to