Combi-box issue

Posted by goo on 12-Mar-2019 18:24

11.7.4

Spending two hours on a simple case and right now fealing stupid.

MyTest.w

Having a combo-box formatted as integer (big mistake).

CmbTest:delimiter = “|”.

CmbTest:list-item-pairs = “somethingA” + “|” + String(203) + “|” + .......

Used the format of integer as “>>>9”

I tried to do a lookup(cmbTest:list-item-pairs,string(203),”|”), but did not get it that the integer value in the list-item-pairs had a chr(32) between | and the number, like “| 203|.... the strange thing was that if I had a number with 4 digits, it worked.

After two hours struggling, I tested with cmbTest as character, an everything was ok.

Lesson learned, only use combo-box as character.., but why letting us use it as other data-types if it do not work?

All Replies

Posted by nborshukov on 13-Mar-2019 07:30

Hi goo!

Use combo-box lookup method instead:

CmbTest:lookup(string(203))

It works fine, at least until 11.7.3

Posted by goo on 13-Mar-2019 09:00

Thanks,
I will try to reconstruct the issue, but if I have a list-item-pairs like this:
/*cmbTest:data-type har type integer, it works swell if it is like character*/
 
cmbTest:format =  “>>>>>9”.
cmbTest:delimiter = ‘|’.
cmbTest:list-item-pairs = “Test (AA)|230|Test (BB)|340|Test (CC)|2333”.
 
I would like to check if the droppdown has a specific value like (BB) in the label.
 
I would need to get the label, and check the label if it has the value in it, how would you do that?
 
I thought I would do like this:
If Index(Entry(Lookup(cmbTest:screen-value,cmbTest:list-item-pairs,cmbTest:delimiter) – 1,cmbTest:list-item-pairs,cmbTest:delimiter),”(BB)”) GT 0 then do:
  Message ‘The cmbTest contains  “(BB)” in label’ view-as alert-box.
End.
 
 
//Geir Otto
 
 
 

Posted by goo on 13-Mar-2019 10:16

Running this from a procedure, could anyone tell me why I should not get the same result for both combo-box's ? Why do I not get the same lookup for cmbInteger?

*******************************

DEF VAR cmbInteger   AS INT FORMAT ">>>>9" VIEW-AS COMBO-BOX NO-UNDO.

DEF VAR cmbCharacter AS CHARACTER VIEW-AS COMBO-BOX NO-UNDO.

DEF FRAME f cmbInteger cmbCharacter WITH SIZE 60 BY 30.

DEF VAR SearchValue AS CHAR INIT "(BB)" NO-UNDO.

ON 'value-changed':U OF cmbInteger

DO:

 cmbCharacter:SCREEN-VALUE = cmbInteger:SCREEN-VALUE.

 MESSAGE SELF:NAME

     SKIP 'INT:'  cmbInteger:LOOKUP(SELF:SCREEN-VALUE)

     SKIP lookup(cmbInteger:SCREEN-VALUE,cmbInteger:LIST-ITEM-PAIRS,cmbInteger:DELIMITER)

     SKIP 'CHAR:' cmbCharacter:LOOKUP(cmbCharacter:SCREEN-VALUE)

     SKIP lookup(cmbCharacter:SCREEN-VALUE,cmbCharacter:LIST-ITEM-PAIRS,cmbCharacter:DELIMITER)

     VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.

   RETURN.

END.

DO WITH FRAM f:

 cmbInteger:DELIMITER = '|'.

 cmbInteger:LIST-ITEM-PAIRS = "Test (AA)|230|Test (BB)|240|Test (CC)|2502".

 cmbCharacter:DELIMITER = '|'.

 cmbCharacter:LIST-ITEM-PAIRS = "Test (AA)|230|Test (BB)|240|Test (CC)|2502".

 ENABLE ALL WITH FRAME f.

END.

WAIT-FOR CLOSE OF THIS-PROCEDURE.

Posted by nborshukov on 13-Mar-2019 12:56

<<Running this from a procedure, could anyone tell me why I should not get the same result for both combo-box's ? Why do I not get the same lookup for cmbInteger?>>

Because the list-item-pairs attribute for integer combo-box contains values, formatted accordingly.

List-item-pairs for character combo-box contains values, that are not formatted at all, but also right-trimmed.

If you format value you are looking up for, i.e. change:

SKIP lookup(cmbInteger:SCREEN-VALUE,cmbInteger:LIST-ITEM-PAIRS,cmbInteger:DELIMITER)

to

SKIP lookup(string(integer(cmbInteger:SCREEN-VALUE),cmbInteger:format),cmbInteger:LIST-ITEM-PAIRS,cmbInteger:DELIMITER)

in your procedure everything works fine.

Posted by goo on 13-Mar-2019 20:52

That has to be a kind of bug? A scree-value to integer than to string? I would not thought of that ..

Sendt fra min iPhone

13. mar. 2019 kl. 13:57 skrev nborshukov <bounce-nborshukov@community.progress.com>:

Update from Progress Community
nborshukov

<<Running this from a procedure, could anyone tell me why I should not get the same result for both combo-box's ? Why do I not get the same lookup for cmbInteger?>>

Because the list-item-pairs attribute for integer combo-box contains values, formatted accordingly.

List-item-pairs for character combo-box contains values, that are not formatted at all, but also right-trimmed.

if you change:

SKIP lookup(cmbInteger:SCREEN-VALUE,cmbInteger:LIST-ITEM-PAIRS,cmbInteger:DELIMITER)

to

SKIP lookup(string(integer(cmbInteger:SCREEN-VALUE),cmbInteger:format),cmbInteger:LIST-ITEM-PAIRS,cmbInteger:DELIMITER)

in your procedure everything works fine.

View online

 

You received this notification because you subscribed to the forum.  To unsubscribe from only this thread, go here.

Flag this post as spam/abuse.

Posted by nborshukov on 14-Mar-2019 11:30

Hi goo!

I don't know whether this is a bug or not. I don't use list-item-pairs attribute to lookup for values, because, when it was introduced (somewhere in v 9.x) it did not return full list of pairs for long (don't remember how long) lists.

I'm using combo-box lookup method ant it works nice.  

Regards!

Posted by goo on 14-Mar-2019 12:44

I am trying to use the label part.. how to do that with lookup?

Posted by goo on 14-Mar-2019 13:16

Ok, so using string(cmbTest:input-value)) should be the way of doing it. Thanks...

Posted by goo on 14-Mar-2019 13:23

By the way, the problem is NOT the screen-value part, it is the LIST-ITEM-PAIRS. If you do a length of both list-item-pairs, you will see that the one for data-type integer is longer than the one for character.

So the list-item-pairs is changed when set. I wounder why that is done.....

Posted by nborshukov on 15-Mar-2019 07:09

Ho goo!

For label part the only choice is to lookup list-item-pairs attribute.

But, for value part is better to use combo-box lookup method.

If you setup combo-box as follows:

cmbInteger:Delimiter = "|".

cmbInteger:list-item-pairs = "Test (AA)|230|Test (BB)|340|Test (CC)|2333".

Then, for current selection:

SelectedPairIndex = cmbInteger:lookup(cmbInteger:screen-value) . For pair "Test (BB)|340" this returns 2 - i.e. second label-value pair.

SelectedPairLabel = entry(SelectedPairIndex * 2 - 1,cmbInteger:list-item-pairs,cmbInteger:delimiter).  This returns "Test (BB)".  

If you want to get value for given label:

PairIndex = (lookup(GivenLabel,cmbInteger:list-item-pairs,cmbInteger:Delimiter) + 1) / 2.

PairValue = cmbInteger:entry(PairIndex)..

Regards!

Posted by goo on 15-Mar-2019 08:22

Ok, so cmbInteger:lookup(cmbInteger:screen-value) is ok, but lookup(cmbInteger:screen-value,cmbInteger:list-item-pairs,cmbInteger:delimiter) will fail...because there are some extra formatting stuff in the cmbInteger:list-item-pairs.

Thanks for the code anyway :-) but I had the solution, just had to use cmbCharacter instead of cmbInteger :-) I still believe it has to be some wrong with the list-item-pairs when using combo-box as integer...

This thread is closed