en@frrom
1st March 2004, 09:15
Hi all,
I'm for the first tim eplaying around with multi-element string fields in Baan. I don't understand very well how to approach them in scripts.
Example:
- Print session
- have form field citg (item group) with 15 elements
- in program script:
field.citg:
check.input:
select tcmcs023._index1
from tcmcs023
where tcmcs023._index1 = {citg} | :citg / :citg(attr.element) / :citg(1, :attr.element) etc..
order by tcmcs023._index1
as set with 1 rows
selectdo
selectempty
message("............")
input.again()
endselect
So for every element of citg Baan will indeed enter this section, like I expected. However, I do not know how to pass on the correct 'citg' value in my query to tcmcs023.
I have already tried where tcmcs023._index1 = {:citg}, this compiles, but then at runtime I receive a fatal error: 'array not implemented'. If I just write {citg}, it will compile (!!), but no matter what the value of citg(1, attr.element) is, it will never hit the selectempty clause!!?? I also tried :citg(1, attr.element) or :citg(1, :attr.element) or even citg(attr.element), but don't get it yet...
Please assist/clarify...
Many thanks in advance,
En.
dorleta
1st March 2004, 11:04
Try of this way:
field.citg:
check.input:
select tcmcs023.*
from tcmcs023
where tcmcs023._index1 = {:citg} selectdo
selectempty
set.input.error(messcode)
or the message of this no so correct way:
message("Error Family")
set.input.error("")
endselect
jan van dillen
1st March 2004, 11:11
Hi,
You should use the variable attr.element.
field.citg:
check.input:
item.group.allowed(citg(attr.element))
function item.group.allowed(domain tcccitg i.citg)
{
select tcmcs023._index1
from tcmcs023
where tcmcs023._index1 = {:i. citg}
as set with 1 rows
selectempty
set.input.error("")
endselect
}
günther
1st March 2004, 11:22
Another way, closer to your code:
field.citg:
check.input:
select tcmcs023._index1
from tcmcs023
where tcmcs023._index1 = {:1} | <=
wherebind(1, citg(attr.element)) | <=
order by tcmcs023._index1
as set with 1 rows
selectdo
selectempty
message("............")
input.again()
endselect
en@frrom
3rd March 2004, 10:41
Thanks guys for the reply!!
The way I got it to work is by passing on the citg(1, attr.element) to a check.function, and there import it in a single element string.
Now next question:
I want to use diable.fields()/enable.fields() based on the input.
I.e. I have 15 input fields on the form (-> inp.fld(1), inp.fld(2) etc), and if inp.fld(attr.element) is empty, then:
for i = (attr.element + 1) to 15 disable.fields("inp.fld(i)").
If I write the above, then all elements from 1 to 15 will be disabled!! I tried also inp.fld(1, i) but then always the first element will be disabled. I even tried plain inp.field, then also they are all disabled.
Anyone an idea??
evesely
3rd March 2004, 15:20
Have you tried using that logic in a before.input section?
For example:
long i
...
field.inp.fld:
before.input:
for i = 1 to attr.element - 1
if isspace(inp.fld(1,i)) then
attr.input = false
break
endif
endfor
It doesn't use enable/disable, but should do what you want.
en@frrom
3rd March 2004, 15:48
Ed,
I'm not sure you understood my situation, so I will try to describe it better:
- Print session
- on form:
-- inp.fld1(15) -> 15 elements of inp.fld1
-- inp.fld2(15)
-- inp.fld3(15)
The user can select upto 15 groups of required info to be printed, yet does not have to select 15, and in most cases will not select 15. So therefor when the user leaves inp.fld1(attr.element) empty, that means he has completed input, and so I want to disable input for all remaining fields inp.fld1, inp.fld2, inp.fld3. For instance, if the user selected info on 4 elements, I.e. filled in four times the 3 input-fields, then all three input fields 5->15 will be disabled.
I just don't get it working yet. Like I said, either all of them will get disabled, or always the first one.
Kind regards,
En.
jan van dillen
3rd March 2004, 16:16
field.inp.fld:
before.input:
if attr.element > 1 then
if isspace(inp.fld(1, attr.element - 1)) then
inp.fld(1, attr.element) = ""
attr.input = false
endif
endif
NPRao
3rd March 2004, 20:04
En,
Since you are on the BaaN-5 series, you can use the disable.fields() function in this case.
Syntax
void disable.fields( [ long mode,] string field [, occurrence] [, string field [, occurrence] ... )
field [,occurrence]
This identifies the field to be disabled.
For a single-occurrence field, this is the field name. For a multioccurrence field, this can be either the field name or the field name followed by an occurrence number (depending on whether you wish to disable all occurrences of the field or only one particular occurrence).
For array fields, UTC fields, and segmented fields, you can append suffixes to the field name to indicate the particular element or segment to be disabled. If you omit these suffixes, all elements/segments are disabled.
To disable a particular element of an array field, append the element number (in parentheses) to the field name. The element number must be an integer, formatted as a string. It cannot be a variable. For example: "tfmod100.perd(10)".
To disable only the date or time element of a UTC field, append either .date or .time to the field name. For example: "ttadv300.cdat.time".
To disable a particular segment of a segmented field, append
.segment.segment_id to the field name. For example: "tiitm001.item.segment.1".