Valid object problem

This forum is for eXpress++ general support.
Post Reply
Message
Author
zolifree
Posts: 35
Joined: Sun Sep 19, 2010 6:55 am

Valid object problem

#1 Post by zolifree »

Hi Roger!

I found an error in express++ many years ago, and I made a workaround for that.
I still find this causing errors in log files, becuse I am missed a lot when I tried to corrected all the thousands of places in the source code.

I think You can fix it, so I will not need the workaround, and express will be better.
The problem is this:
When I am browsing a dbf database, and editing a cell with celleditor, the valid codeblok's 2 first input value is wrong, when the user change to other window during editing the cell.

Example:

Code: Select all

     DCBROWSECOL DATA {||(ptetel)->mennyiseg * (ptetel)->ar *(1+IF(.f.,0,NAFASZ((ptetel)->AFASZ)/100))} HEADER "Tétel;összesen" ;
      MESSAGE tny("Az egységár és a mennyiség szorzata.") ;
      PARENT oBrowsex TOOLTIP tny("A jobb egérgombbal vagy ;az F9-el rendezheti az oszlopot.");
      EDITOR "XALTALANOS"   WIDTH 6 ;
      editprotect {||(ptetel)->(lastrec())=0.or.(ptetel)->mennyiseg=0} ;
      EVAL {|o|o:heading:lbClick := {|a,b,o1,wosubmenu|wosubmenu:=oszlopmenube(o1,wxtagtomb),woSubMenu:PopUp(o1, a, 2,XBPMENU_PU_DEFAULT + XBPMENU_PU_MOUSE_RBDOWN )} , o:dataarea:rbClick := {|a,b,o1,wosubmenu|wosubmenu:=oszlopmenube(o1,wxtagtomb),woSubMenu:PopUp(o1, a, 2,XBPMENU_PU_DEFAULT + XBPMENU_PU_MOUSE_RBDOWN )} ,o:heading:rbClick := {|a,b,o2|fejszinez(o2,obrowsex) } };
      PICTURE "99"+parpicture ;
      VALID {|mez,mez2|mez2:=objcs(mez,mez2),if(mez2==NIL,.t.,  if(.f., ;
	   FieldPut( fieldpos("ar"), val(mez2:editbuffer())/(ptetel)->mennyiseg ) ;
	  ,FieldPut( fieldpos("ar"), (val(mez2:editbuffer())/(1+val( (ptetel)->AFASZ )/100)  )/(ptetel)->mennyiseg );
        )) ,arvalid(),tetelki(),.t.}

The VALID codeblock has 2 input variable mez and mez2. When the user finishing the edit, mez2 is the editor object, and I can use the mez2:editbuffer() to do things with the entered value.
But when the user editing the cell, and switching to another window with mouse or Alt+Tab the valid process will run without pressing Enter or clicking to another objects in the window.
This is not so good, but the real problem is much bigger.
In this case the VALID codeblock's mez2 variable is a logical value, not the editor object, so, the mez2:editbuffer() will cause an error. But I found out that the first input variable has the right object instead of the second.

The workaround that I made is this function:

Code: Select all

function objcs(o,o2)  
local wret
if valtype(o2)="L"
 wret=o
else
 wret=o2
endif
return wret
As You can see this is the first command in the VALID codeblock: mez2:=objcs(mez,mez2)
This will correct the second input variable, when the user switching to other application during celledit.

I hope You can find a fix that makes the workaround unnecessary.

Zoltan

Post Reply