Hi,
I was writing a little generic table sort event block in a frame (I wrote one in another century) and I thought I’ll store the sort order in the header button variable.
That’s when the trouble started.
So the buttonfield (table header button) has a data type of integer4 and declared = true in properties.
But if I try to set it I get a compiler error:
field(seeds).CurRow = 1;
seeds.d_no_hdr = AS_ASC;
^
%% Error at line 43 in script for framesource SoundexCheck
E_W40110 An assignment statement had incompatible types between the field
or column being assigned to (on the left-hand side) and the expression
or field or column value being assigned (on the right-hand side.)
Data types all look good to the debugger….
…and SetFieldValue works as expected….(returns ER_OK)
But GetFieldValue() does not.
I set the buttonfield’s variable to 42 through the debugger and got this clue in the trace:
Are data values for header buttons “not supported” or have I found some inconsistency?
Cheers
Adrian
-------------------------------------------
PS
I made simple frame with a button on it with this script as a test case, but it made me understand the table/array parent is complicating matters in ways that the debug trace error showed.
GetFieldValue continues to fail though:
initialize()=
declare
enddeclare
{
setmeifucan_btn = 42;// This compiles – being part of the table is complicating things.
Field(setmeifucan_btn).SetFieldValue(value = 42); //This works
}
on click setmeifucan_btn=
declare
val = i4 not null;
enddeclare
begin
message 'This gives: ' + varchar(setmeifucan_btn); //This works
if Field(setmeifucan_btn).GetFieldValue(value = byref(val)) = ER_OK then // This does not
message 'Got : ' +varchar(val);
else
message 'Got nowt :' +varchar(val);//We get to here.
endif;
end;
I am going to use ClientData and an integer object for the header buttons, which may be what I did last century but I have forgotton.
Like this :
on childclick t1,
on childclick t2,
on childclick t3 =
declare
tbl = tablefield default null;
arr = arrayobject default null;
sort = i4 not null;
col = varchar(256) not null;
enddeclare
begin
tbl = CurFrame.TriggerField.WhichTableField();
tbl.GetFieldValue(value = byref(arr));
if CurFrame.TriggerField.ClientData is null then
CurFrame.TriggerField.ClientData = IntegerObject.Create();
endif;
sort = IntegerObject(CurFrame.TriggerField.ClientData).Value;
if sort = AS_DESC then
sort = AS_ASC;
else
sort = AS_DESC;
endif;
col = replace(txt = CurFrame.TriggerField.name, target = '_hdr', replacement = '');
arr.Sort(:col = sort);
IntegerObject(CurFrame.TriggerField.ClientData).Value = sort;
end;