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?
Hi goo!
Use combo-box lookup method instead:
CmbTest:lookup(string(203))
It works fine, at least until 11.7.3
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.
<<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.
That has to be a kind of bug? A scree-value to integer than to string? I would not thought of that ..
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.
You received this notification because you subscribed to the forum. To unsubscribe from only this thread, go here.
Flag this post as spam/abuse.
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!
I am trying to use the label part.. how to do that with lookup?
Ok, so using string(cmbTest:input-value)) should be the way of doing it. Thanks...
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.....
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!
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...