d2k forms 5.0: Creating multiple items at runtime [message #83335] |
Fri, 26 September 2003 01:06 |
bluebyte
Messages: 25 Registered: September 2003
|
Junior Member |
|
|
hi all!
there are 2 number_input items on my form.lets call them num_from & num_to.these have corresponding columns in a table.while doin the data entry, the user shall decide on the no. of sets of the 2 items he/she requires.
eg: if the user wants 2 sets, my form should be able to create num_from1/num_to1, num_from2/num_to2 at runtime.
*the no. of sets 'n' shall be determined at runtime*.
how to implement this?something on the lines of index
arrays used in VB...
pls reply asap.
thnx n regards,
ganga
|
|
|
Re: d2k forms 5.0: Creating multiple items at runtime [message #83336 is a reply to message #83335] |
Fri, 26 September 2003 03:54 |
magnetic
Messages: 324 Registered: January 2003
|
Senior Member |
|
|
its easy.
just create lots of text-items in a block.
name them f1,f2..fn.
set the properties to displayed false.
now open your canvas and place the fields on position 0 [[all above eachother]]
now, while running the form, you know how many sets the user want.
create a procedure that will loop to show as many
fields as the input parameter for the sets.
in the procedure, you will also set the x,y positions of the fields.
a poor example: [[ you should examin with x,y positions depending on item width and heigth..]]
user wants 3 sets:
go block ('B');
first item;
l_item:=the name of the first item [[name_in(:system.cursor_item); or get_item_property(name of the item);]]
while v_sets <> input_value loop
set item property(l_item,displayed,true);
set item property(l_item,position,x,y);
l_x:=l_x+ 10;
l_y:=l_y+10;
v_sets:=v_sets+1;
next_item;
l_item:=the name of the next item [[name_in(:system.cursor_item); or get_item_property(name of the item);]]
..
.
end loop;
result should be like:
f1 f2
f3 f4
f5 f6
f1,3,5 --> x pos = 0 ,y pos = 0,5,10
f2,4,6 --> x pos = 10 ,y pos = 0,5,10
its all about dynamically displaying items and put them on the right x,y positions!!
dont forget to set the item_properties to displayed false before you run the above stament. otherwise the items will stay displayed when you run it for the second [[and above]] time in the same session....
good luck.
|
|
|
Re: d2k forms 5.0: Creating multiple items at runtime [message #83340 is a reply to message #83336] |
Fri, 26 September 2003 08:41 |
bluebyte
Messages: 25 Registered: September 2003
|
Junior Member |
|
|
hi magnetic!
thnx for the technique...
i hav written a db package which holds a procedure
to insert records from this form into a certain table A.
if the user selects 3 sets, that implies 3 records hav to be inserted into table A...one for each set.
wot should be the form code to support such a procedure?
iam sending item values as parameters to the procedure.
this implies that i should be calling this procedure thrice.
how to loop thro' the block to extract the item values
in case the user input is not known?
(i was thinking of using create_record forms built-in...when the user hits enter key after giving the number in num_to field, the trigger will create new set ...by using this technique, it is not necessary for the user to explicitly state how many sets are required...it is only a matter of hitting enter key if
he/she wants another set.)
thnx n regards,
ganga
|
|
|
Re: d2k forms 5.0: Creating multiple items at runtime [message #83364 is a reply to message #83340] |
Tue, 30 September 2003 08:12 |
magnetic
Messages: 324 Registered: January 2003
|
Senior Member |
|
|
your goal is not clear enuff but iwill try to give a hint about your problem with the next example
suppose table A with structure
col1
col2
fileds on forms:
f1 f2
f3 f4
f5 f6
variables:
inputnum=3 [[user wants 3 sets, doenst matter tho]]
v_last number;
all items are on block A
go block ('A');
last_item; navigation to the last item on the block
v2:=last_item;
first_item; navigation to the first item on the block
while not :system.cursor_item=v2 loop
t1=name_in(:system.cursor_item);
next_item;
t2=name_in(:system.cursor_item);
insert into A values(t1,t2);
next_item;
t1:=''; empty the variables for the next set
t2:='';
end loop;
commit_form;
|
|
|
|
|