The specified database was not found.
at: oncreate with params: array: (pair: (-database)=(jina_test)),
(pair: (-username)=(*****)), (pair: (-password)=(*****)), (pair: (-
keyfield)=(rcrdNo)), (pair: (-lockfield)=(rcrdLock)), -
at: /_config/cfg__global.inc on line: 29 at position: 32
The idea was that since I'm creating several knop_database objects
all using the same info except for table this would be easier. Is
this a limitation easy to work around or something to do with how a
ctype expects params?
Re: Using array for knop_database objects not working
At 18.44 +0100 2007-03-08, [hidden email] wrote:
>The idea was that since I'm creating several knop_database objects all using the same info except for table this would be easier. Is this a limitation easy to work around or something to do with how a ctype expects params?
Ctags (or ctype member tags) don't automatically recognize an array as a prebuilt set of parameters.
The way inlines allow this is a special case (extremely convenient - in fact much of Knop relies on that feature).
I've been thinking briefly about if this would be easy to implement, and maybe it isn't so hard.
I'm thinking to have the ctag iterate through the params, and if it comes across an array as unnamed parameter, it would merge it with the params, to "flatten" the array into the params so to speak.
It would probably also need to create locals for any named params in the array since the autocreation would not happen. Would those locals be copies or references? I don't think there's a way to figure out from the tag definition if a parameter of a custom tag has the -copy flag set or not.
Now, how to handle this in the most efficient manner? I don't think it would be wise to merge with the params while iterating it, it would probably be to pull the rug you're standing on, so maybe by working on a copy of the params array and after iterating and merging, copy the modified params copy back over the original params.
Another problem would be how to handle assignment of locals that have already been autoassigned by a normal named param (an override situation). Those would need to be de-referenced before assigned to the new value to not attempt to alter the referenced value from the original param...
Hmm, an interesting challenge...
Has anyone played with this?
-- Just chatted a bit with Kyle about this and in his view this is no easy thing, but I'll play with it anyway and see what I come up with.
Johan Sölve [FSA Member, Lasso Partner]
Web Application/Lasso/FileMaker Developer
MONTANIA SOFTWARE & SOLUTIONS
http://www.montania.se mailto:[hidden email] (spam-safe email address, replace '-' with 'a')
At 22.35 +0100 2007-03-08, Johan Solve wrote:
>Hmm, an interesting challenge...
Here's a proof of concept. Not perfect, but seems to work.
local: 'param', 'element';
// loop until we reach the last param element (the params array will possibly grow while looping)
while: loop_count < (params -> size);
#param = @(params -> (get: loop_count));
if: #param -> type =='array';
// we want to merge the array with the rest of the params
// but first we want to auto-assign locals for the keywords in the array. We will not override any existing locals.
iterate: #param, #element;
if: #element -> (isa: 'pair') && #element -> name -> (beginswith: '-') && !(local_defined: (#element->name - '-'));
// there is no point in creating references here since they will be copied when the array is merged later
local: (#element->name - '-') = (#element->value);
// merge the array into the params at the right position (this will kill any reference)
params -> (merge: #param, loop_count);
// replace the array with null so we know we can delete it later
// remove all ex arrays that we have merged into the params array
params -> (removeall: null);
// show what params we saw
return: @(params -> (join: '<br>'));