jcompagner:
about the array’s
yes all arrays should be the same now so the to string of javascript or java arrays should behave and display the same so with the [10,10,10]
When do you need it without the brackets? Because a toString impl is just what it is a toString (mostly for debugging).
The brackets are absolutely disturbing. For example, we now have a query that looks like this:
… WHERE (kontakte_benutzer.uid_benutzer IN (‘[4]’) …
which is completely wrong because there should be simply a “4” and not a “[4]”.
The query comes from this (in short):
for (i = 1; i <= vAnzahlZeilen; i++)
{
vResult[i-1] = new Array(vAnzahlSpalten)
for (j = 1; j <= vAnzahlSpalten; j++)
{
vResult[i-1][j-1] = vDataSet.getValue(i, j);
}
}
return vResult;
This Array issue is getting worse the more I click around. I have, for example, a method that calls another method passing arguments in an array. The Array is constructed here:
globals.datensatzNeu('kontakte_briefe', dataset, true, null, null, 'briefNeu', new Array('\'einzelansicht\'', vGuid));
Then in globals.datensatzNeu I do
methodArgs = arguments[6]; // retrieves the Array
// and then later:
if (methodArgs)
{
var args = methodArgs.toString();
method += '(' + args + ')'
eval(method);
}
// NOW leads to method
forms.aForm.briefNeu(['einzelansicht',19])
The method that is called using eval does
var form = arguments[0];
var vGuid = arguments[1];
which NOW leads to
form = [einzelansicht,19]
vGuid = undefined
instead of
form = einzelansicht
vGuid = 19
Guys: this is hell!! We use this kind of logic all over the place. This needs to be fixed, otherwise I am thrown back one month.
as i a said..
the toString of an array is REALLY not meant for this!!
For example if you have a large number of elements (i don’t know currently how much) then you will get [x,y,z,…]
That is how a to string on an array works.
If you really want arrays to just do: x,y,z and nothing more
then you need to make youre own function that does that.
(we could make such a functions in utils.xxx or something like that)
What I want here is to turn an array into item1, item2, item3. I know there can be many items and so forth, but I know what I am doing here. It did work before and it should work now. toString should deliver the items of an array in a string just like it did before. I can fix it at this specific point using join, but I also have the problem described above, where I get ‘[4]’ instead of ‘4’.
What was the big issue that is fixed now? I need to check my code all over the place now and see what my arrays return. Arrays did behave as I expected ever since I use Servoy until today.
In which part of the first described problem do you get the brackets? Because in the sample specified, I see neither .toString() or join used (except for the last line).
that is not the case.
What is that vUidBenutzer???
What kind of data is inside that??
is it the result of the first code fragement where you do return vResult?
I think that is the case and then it is logical that you are getting the result you are getting
because vUidBenutzer is a 2 dim array.
and you hare sayint to the 2 dim array that it should join.
So what happens is that the first array that already has arrays as elements just joins the arrays it self has.
and first array just does a toString on its elements (that again are arrays) and then will make .
Why do you have multi dim array?
If you just want a list of ids why are you not concatting those to one array?
vResult = new Array();
for (i = 1; i <= vAnzahlZeilen; i++)
{
for (j = 1; j <= vAnzahlSpalten; j++)
{
vResult[vResult.length]= vDataSet.getValue(i, j);
}
}
return vResult;
before RC4 there was a difference in javascript and java arrays. So java arrays did return a toString of “[x,y]” and javascript arrays did not. Also java other behaviour was different. Now they are all the same. It should be completely transarent.
But depending on the toString imp of a array is bad behaviour for example
i could make it the other way around. But then i also have to remove all the length checks that toString does for example > 100 will not be printed.
But if we do that then the debugging arrays is a bit ugly because the strings that a big array could return would be very very big. And that is just what the toString is meant for: Debugging output.
jcompagner:
I think that is the case and then it is logical that you are getting the result you are getting
Hello Johan,
you are correct here and I see the point, that doing a join on a two dimensional Array is more a bug on our side (it just didn’t occur) than a misbehaviour. We are currently using toString() at several places, but also accept that join is a nicer alternative.
We are clicking all over the place to figure out where we still have problems and if they are (now) home made. For the moment, I withdraw my argumentation…
Still I would like to suggest to create another branch in the editor tree for storing functions that are not supposed to be used in “normal” programming. Would have prevented the hassle
We are clicking all over the place to figure out where we still have problems and if they are (now) home made. For the moment, I withdraw my argumentation…
The above was probably a figure of speech and you are also doing this but the ‘find’ within the editor works great for locating wherever you use a particular function like ‘toString’.
If you disable auto save and then the users clicks on a button where you as developer enable auto save again by calling that method again (let say the user clicks the ok button) then now after that call also everything is saved. This wasn’t the case before.
When a eval functions is called it stores the evaluation code in the source variable altering that variable.
example:
line 1 var GT_FormName = elements.Find_Tab.getSelectedTabFormName()
line 2 var GT_Controller = 'forms.' + GT_FormName + '.controller.'
line 3 eval (GT_Controller + 'loadAllRecords()')
line 4 eval (GT_Controller + 'loadOmittedRecords()')
Value of GT_Controller:
line 2 = forms.Find_Hardware.controller.
line 3 = forms.Find_Hardware.controller.loadAllRecords()
line 4 = forms.Find_Hardware.controller.loadAllRecords()loadOmittedRecords()
In RC3 the code runs correctly.
Servoy Developer
Version R2 2.2rc4-build 322
Java version 1.5.0_02-b09 (Windows 2000)