i’m still getting in trouble with calculated fields, probably
cause i’m trying to do more with them then they are
designed to do.
i’m in a situation now where calculations are running when
the solution is started and the initial form is displayed, and
one of the calcs has a bug in it.
as a result of this, i’m not always able to open my solution.
it just sits there with the spinning beach-ball cursor.
(the status line at the bottom of the window reads: “requesting
form data”)
sometimes, i can use the escape key to regain control,
but not always.
i’d really like to see a way to open the solution, but go directly
to design mode, just for situations like this.
in 2.1 we will introduce a recusie check.
We can’t introduce that in 2.0.3 because this has to be tested in a beta serie (to test if our test is not to ridgid)
i should probably have mentioned what i’m trying to do with
the calculation, to see if you think it’s ok…
i have a form with a tab panel;
each tab sheet of the panel allows the user to select
items to be added to the building (my client builds buildings).
they would like to hilite the tab of any sheet that adds to
the building cost.
this is actually very simple, since you’ve given us the ability
to change the tab colors.
the problem is, i don’t want to have to add code to every single
field on every tab sheet (there are hundreds) to tell the program
to hilite (or unhilite) the tabs. i’d like to do this with a calculation,
and that way the tab colors would change instantly as the user
selects or de-selects items on the tabsheet.
so i put together a calculation for each tab sheet (and put it on
the main form so it would fire).
the code in each of these calculations looks something like this:
if (PageTotal_Building!=0)
forms.QuotesMaint.elements.TabSheet.setTabFGColorAt(n,c1);
else
forms.QuotesMaint.elements.TabSheet.setTabFGColorAt(n,c2);
where:
PageTotal_Building is a calculated field that totals all the items on
the Buildings page
n is a number defined as a global
c1 & c2 are colors (strings, like ‘#0d0d0d’), also defined as globals
this code works if i put only one calc of this type on the form.
as soon as i try to do it for other tab sheets, i get the problems
reported in my initial post.
jcompagner:
what does PageTotal_Building exactly do?
it totals up various numeric fields, and a few calculations to
get the total cost of the items specified on that page.
does it call other calculations or something?
yes, but they’re pretty simple - just adding some fields together
based on conditions (if [checkbox] then return f1 else return f2)
i have to see some more to see what could go wrong in youre case.
there’s really not much more than what i’ve described.
If it is recursie then youre solution will not work anyway in 2.1 because we will throw an exeption when that happens.
do you mean ‘recursive’? if so, that shouldn’t be a problem. i have
no need to use recursion here.
so you’re saying that i should be able to call a function
like “forms.myform.elements.mytabsheet.setTabFGColorAt()”
from within a calculation? that would be wonderful if it would work.
you shouldn’t call forms in scripts. Because the behaviour you get will be undefined.
But i still don’t know what exactly goes wrong. What kind things you run against. But it can be that the calculations is triggerd much earlier then the forms ect are in place.
But using elements calls in calculatiosn is not supported.
jcompagner:
Can’t you do the same things with onRecordSelection and/or onRecordSave of a form?
i don’t believe that would help; here’s an example of what
i’d like to do:
i have a tab panel with about 10 tabs;
each tab (or sub-form) has a large number of fields,
implemented as check boxes and pop ups/drop downs.
the user adds options to the building using these items.
the client’s request is to have the tab change color if the
user has selected any of the items on that page.
if i could use a calculation to change the tab color, the calc
would fire automatically whenever the user changed anything
on the form.
if i can’t use a calculation, i’ll have to add code to every
checkbox & popup that calls a common method that changes
the tab color (if any items on that page are selected)
Robert, I agree with Johan, onRecordSelection / onRecordSave should solve your problem. Just have this method ask for the total of each tab (like your calculation) and change the appropriate tab’s color.
BTW Johan, exactly what are you referring to here:
jcompagner:
you shouldn’t call forms in scripts. Because the behaviour you get will be undefined.