baaninfo
29th October 2009, 12:07
Hi,
which sections are allowed to use the function mark.occ in LN?
I want to mark a detail in an overview session after zoom from another session.
Export, import and zoom seems to be ok, because the selected detail is the first after zooming to the overview session - but this detail is not marked.
zoom.from.all:
on.entry:
import("var1", var1)
var2 = var1
select maintable
mark.occ(1)
Warning: 4GL-FUNCTION 'mark.occ' not allowed in section 'on.entry'
Any idea?
Thanks for any suggestions...
george7a
29th October 2009, 12:16
Hi,
In this manual (http://www.baanboard.com/programmers_manual_baanerp_help_functions_form_and_form_field_operations_mark_occ)it says:You can use this function only in 4GL scripts, and only in choice and form sections of those scripts. You cannot use it in programs of type 4.
However, in the LN manual that I have, this comment is not there.
- George
baaninfo
29th October 2009, 12:46
I found this restriction, too. But if the mark.occ for example is in form.all, before.form, the result is the same (without warning). It is interesting to see, that actual.occ starts with 1 and after mark.occ(3) it remains 1...
Which choice section could be the right?
Or is there a specific include needed?
Thanks for all help...
NPRao
29th October 2009, 22:09
Refer to the latest LN programmer's manual:
Improved Record selection Cookbook
Introduction
When moving a UI script from a Tools Interface Version (TIV) level below TIV 1075 to TIV 1075 or higher, rework might be needed because the 4GL engine uses a new record selection mechanism. Rework may be needed when one of the following variables or functions is used:
marked doesn't work anymore
unmarked doesn't work anymore
mark.table only reflects the state of records that are visible in the window. Note that with TIV higher than 1075 there can also be records selected that are not visible, but are scrolled out of the window.
mark.occ() behavior has changed, see mark.occ()
So in case the above variables are not used, no rework is needed. There are a couple of scenarios in which the above variables are used. The most important ones are mentioned below.
Use mark.occ to append records to selection
When you want mark.occ() to append a record to the selection, specify true for the second argument of mark.occ . E.g.:
mark.occ( 1, true)
The behavior has changed because in most cases the application expects that only one record is selected after a find.data and a mark.occ. An example of such a construction is:
execute(find.data)
mark.occ( 1)
Transfer selection to print/processing session
In different ways selections are transfered to child sessions for processing or printing. In all cases mark.table is used. In most cases this construction can easily be replaced by the use of do.parent.selection() in the child session.
Do a check in choice.mark.occur
There were three ways to check whether a record is selected in the after.choice section of the mark.occur event and act on that:
choice.mark.occur:
after.choice:
if mark.table(actual.occ) then
some.check()
endif
or
choice.mark.occur:
after.choice:
if marked = actual.occ then
some.check()
endif
or
choice.mark.occur:
after.choice:
if not unmarked = actual.occ then
some.check()
endif
All these constructions only work if the choice section is executed for every record that is selected. With a TIV level below 1075 this is not the case when the user selects a range of record. With a TIV level of 1075 or higher the choice section is executed once for every mark action. So it is executed once when the user selects one record, and it is executed once when the user selects range of records (e.g. by using the a shift-click). Therefore, at least when moving to a TIV level of 1075 or higher, these constructions should be rewritten to something that uses do.selection(). E.g.:
choice.mark.occur:
after.choice:
do.selection(false, some.check())
Process selected records or enable/disable commands in mark.occur section
To process selected records a construction like the following is used. The same is also used for determining the state of commands after a user selected a record.
for counter = 1 to filled.occ
if mark.table(counter) then
restore.rcd.main(counter)
do.it()
endif
endfor
In both cases the construction must be replaced by a construction that uses do.selection(). E.g.:
do.selection(false, do.it)
check whether any record is marked
In some cases the value of the variable marked is used to determine the whether there are any records selected. On these places the function sel.num.selected() must be used.
Note
Improved record selection functionality is available from Tools Interface Version (TIV)TIV 1075.
baaninfo
30th October 2009, 09:09
Hi,
now i tried the following:
form.all:
init.form:
mark.occ(3, true)
Runnning the Session with debugger shows, that after mark.occ(3, true) the variable actual.occ has the same value as before (and) and nothing is marked...
Are there any scripts in LN, which use this function?
Thanks