Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
13
Erster Beitrag:
vor 1 Jahr
Letzter Beitrag:
vor 4 Monaten
Beteiligte Autoren:
Ola, GuenterP, ccc2, Fabrice Harari, Erik Schwarz

[WD21] How to make subscripted controls work correctly?

Startbeitrag von Ola am 17.08.2016 07: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

Antworten:

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

von Ola - am 17.08.2016 11:18
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

von Fabrice Harari - am 17.08.2016 12:00
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

von Ola - am 18.08.2016 10:42
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

von ccc2 - am 19.08.2016 08:29
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

von Erik Schwarz - am 19.08.2016 16:40
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.

von GuenterP - am 19.08.2016 17:20
Hi Ola, just overwrite those numbers, it's as simple as that!

von GuenterP - am 19.08.2016 17:21
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

von ccc2 - am 20.08.2016 04:36
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

von Ola - am 23.08.2016 12:12
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!

von GuenterP - am 23.08.2016 13:47
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

von Ola - am 24.08.2016 08:41
Hi Ola,

I had my struggles with subscripted controls today!

It seems that subsripted controls are Edit Controls and Table Columns only!

For most other control types it simply doesn't work.

I recommend to name subscripted controls like MyCombo1, MyCombo2, MyCombo3 ... and access these controls by indirection like {"MyCombo"+i,indControl} instead of an index. However, one can link the controls to the elements of an array as described above.

von GuenterP - am 17.04.2017 14:38
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.