Forum > LCL
[solved] strange behavior with constant set
Joanna:
I'm trying to load a set of integer values into a combobox
It seems like it doesn't work correctly when set is passed as a parameter
if I try to send the set to load into combobox as a parameter it ignores the 102..105 part of set.
If i send a set [0..105] it stops loading when it gets to 31 items.
if I send [102..105] as a parameter it says its an empty set and loads nothing
If i use a locally declared set it works perfectly
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---PROCEDURE TINI_COMBOBOX.ASSIGN( CONST ASET: TINTEGERSET) ; const VALS = [0..7,102..105]; // this works ok if i use this one VAR X:INTEGER; BEGINClear; //FOR X IN VALS DO // this works perfectly // AddItem(X.ToString,NIL);FOR X IN ASET DO // this can't load the higher numbers AddItem(X.ToString,NIL);END;
anyone know what would cause such strange behavior?
using win 7
Lazarus 2.0.12 r64642 FPC 3.2.0 x86_64-win64-win32/win64
ASerge:
--- Quote from: Joanna on September 05, 2024, 07:12:34 am ---anyone know what would cause such strange behavior?
--- End quote ---
Not strange, because TIntegerSet = [0..31].
MarkMLl:
What appears to be happening is that the set type is defaulting to one with 32 elements, i.e. the same as an integer.
I'm not sure what the limitation on the number of elements in a set is these days but it won't be large. However what you want to do is set up a type with that number of elements, and then use that type explicitly when setting up a constant, passing a parameter and so on.
You might need to distill this down to a compilable test program: SOP, sorry but I shouldn't have to mention it.
MarkMLl
Joanna:
I always thought that sets had 255 elements possible with ordinal or positive integers . I never heard of 32 element set before. :o
I’m not sure how to create a larger set type it won’t let me.
dseligo:
--- Quote from: Joanna on September 05, 2024, 08:16:36 am ---I always thought that sets had 255 elements possible with ordinal or positive integers . I never heard of 32 element set before. :o
--- End quote ---
According to manual, you are right (256, not 255): https://www.freepascal.org/docs-html/3.2.0/ref/refsu16.html
Navigation
[0] Message Index
[#] Next page