PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [WD21] How to make subscripted controls work correctly?
[WD21] How to make subscripted controls work correctly?
Iniciado por guest, 17,ago. 2016 09:51 - 11 respuestas
Publicado el 17,agosto 2016 - 09:51
Hi all,

I added a subscripted item to a parameter file, which has one record only. The Item has 9 subscripted fields. This seems to be OK in the analysis.

Then I added the 9 subscripted controls to this file's maintenance form window, and they seem to be also OK, with the correct subscript number showing in the general tab of the nine controls.

THE PROBLEM is that in the link tab of all these controls I can only select the first subscript of the item (like Fieldname[1]), the other 8 subscripts are not shown at all in the link selection control.

When testing with different values in the subscripted controls they all are saved in the first subscript, that is, the last entry only is saved.

When I look at the file with WDMAP, all the 9 fields are there, and only the first one has a value.

So what is the trick? How can I link the subscripted controls to the subscripted item's different fields?

Best regards
Ola
Publicado el 17,agosto 2016 - 13:18
OK,

Not a big problem. I solved the linking problem the "old-fashioned" way, and it works like an old train toilet::

In the window initialization, after filetoscreen, I move the items[] to the controls[] and in the OK button, after screentofile and checking, whether the record has been changed elsewhere, before writing the record, I move the controls[] back to the file's items[]. Here the fantastic text block editing features of Windev's code editor are very handy!

Still, I'm interested to know, if there really is a "ten times faster" way:-)

best regards
Ola
Publicado el 17,agosto 2016 - 14:00
Hi Ola,

yes, there is a 10 tims faster way:

DON'T use the subscripted items.

They are here for historical reason (upward compatibility) ONLY! It is written in the help that you should NOT use them, as many NEW things will not work on them (queries, by example), and as they are NOT supported in all environment (mobile, for example)....

If you need something like that, name your variables with numbers at the end, then use indirection to loop on them if needed

Best regards
Publicado el 18,agosto 2016 - 12:42
Quote
Fabrice Harari

If you need something like that, name your variables with numbers at the end, then use indirection to loop on them if needed

Hi Fabrice,

That's exactly how I first thought to handle this problem, but then I remembered that Windev has this fine "gee-wow-whiz" feature called subscripted item, which might make the coding ten times faster, and - unfortunately - I gave it a try, just to find out, that actually it made the coding ten times slower...:rp:

Best regards
Ola
Publicado el 19,agosto 2016 - 10:29
subscripted controls is like looper and very useful in the time when you cannot use looper.


for example . you need to put 10 image template control in a window . you cannot use looper . because of that you have to manual create the control .

in time you need to assign value with same image . with subscripted you can loop through it like in looper (minimum require 3 code lines) .

but without subscripted , this mean each control is assign unique name , which mean you have to write assign one by one (minimum require 12 code line).

are you really sure will made the coding ten times slower ?

alot of time ,I wish this functions available in WM
Publicado el 19,agosto 2016 - 18:40
Hi ccc2,

if your controlnames are something like

Control1
Control2
Control3
and so on,

you can still use a loop using

{"Control" + i}

This is a very nice feature in Wd

Erik
Publicado el 19,agosto 2016 - 19:20
Hi Ola,

subscripted controls do work just fine with me. There may be things to understand ...

1 - Put the controls onto the window (e.g. Edit controls with the name OLA_EDIT)
a - Put OLA_EDIT onto the window, nothing will happen ..
b - Put another OLA_EDIT onto the window. Now the editor awakes and asks whether to create a subscripted control. You will answer Yes!
c ... put othe OLA_EDT controls on the window

2 - Edit the subscript numbers of the controls
[attachment 2133 Ashampoo_Snap_2016.08.19_19h09m56s_001_.png]

3 - Edit the link-subscripts of the controls
[attachment 2134 Ashampoo_Snap_2016.08.19_19h14m22s_002_.png]

The problem in step 2 is that the editor doesn't allow duplicate subscript numbers while editing. So, just input 9, 10 or whatever in order to get space for real subscript numbers. In step 3 duplicate links are allowed.
Publicado el 19,agosto 2016 - 19:21
Hi Ola, just overwrite those numbers, it's as simple as that!
Publicado el 20,agosto 2016 - 06:36
Quote
Erik Schwarz

Hi ccc2,





if your controlnames are something like





Control1


Control2


Control3


and so on,





you can still use a loop using





{"Control" + i}





This is a very nice feature in Wd





Erik

not working (wm) with control template calling procedure
Publicado el 23,agosto 2016 - 14:12
Hi Guenter

Many thanks for the illustrated lesson! That solved it.:spos:

For some reason I had not seen/noticed the small subscript editing control in the left lower corner of the link tab of the edit control description window. But when I changed the size of the window, the subscript edit control suddenly became visible!

Still, I must wonder aloud, why on earth is this subscript link defaulted to "1" in all the subscripted controls, and not to the same subscript number which the control already correctly has in its general tab????

Offering intelligent default values is one mark of a high quality program, and I must say that WX is lacking a lot in this respect.:(

Best regards
Ola
Publicado el 23,agosto 2016 - 15:47
Hi Ola,

it works like this for eons and I'd protest any big changes to the procedure ...

I'm happy that you found the images useful!
Publicado el 24,agosto 2016 - 10:41
Hi Guenter,

I wasn't suggesting any big changes, just a very, very small, but intelligent one; just that the item subscript's default value should be equal to the control's subscript value, and, if somebody really, really would like to change all the item subscripts to "1", (s)he should still have the possibility to do it:)

Best regards
Ola