[Openroad-users] Deleting tabpage crashes OpenROAD

Bodo Bergmann Bodo.Bergmann at ingres.com
Thu Dec 6 20:16:59 EST 2007


After analyzing the problem with the crash
(which was caused by the TabPageArray and TabFieldsArray being not in
synch) 
I was rethinking about a better/easier solution for the problem,
which is also using supported methods AddTabPage() and DeleteTabPage()
only.
Here it the code (also based on a TabFolder with 8 TabPages - each
mapped to a UserClass object):
 
initialize()=
declare
    i=INTEGER NOT NULL;
    k=INTEGER NOT NULL;
    maxpages=INTEGER NOT NULL DEFAULT 8;
    tabf = TabFolder DEFAULT NULL;
    tabpages = ARRAY OF TabPage DEFAULT NULL;
    tabfields = ARRAY OF TabField DEFAULT NULL;
    tabpages_sav = ARRAY OF TabPage;
    tablabels_sav = ARRAY OF StringObject;
enddeclare
{
    tabf = FIELD(field1);
    tabpages = tabf.tabpagearray;
    tabfields = tabf.TabBar.tabfieldarray;
    
    // Save all the "invisible" pages and their labels
    FOR i=2 TO maxpages DO
        tabpages_sav[i-1]=tabpages[i];
        tablabels_sav[i-1].Value=tabfields[i].TextLabel;
    ENDFOR;
    // Make pages 2 to 8 invisible
    FOR i=maxpages DOWNTO 2 DO
        tabf.DeleteTabPage(pagenum=i);
    ENDFOR;
    tabf.UpdField();
}

ON CLICK add_btn =
{
    IF tabpages_sav.LastRow>0 THEN
        tabf.Addtabpage(subform = tabpages_sav[1], tabtext=
tablabels_sav[1].Value, pagenum=tabpages.LastRow+1);
        tabf.CurPageIndex = tabpages.LastRow;
        tabpages_sav.RemoveRow(rownumber=1);
        tablabels_sav.RemoveRow(rownumber=1);
    ENDIF;
}
 
ON CLICK del_btn =
{
    IF tabpages.LastRow>1 THEN
        i = tabf.CurPageIndex;
        k = tabpages_sav.LastRow+1;
        tabpages_sav[k]=tabpages[i];
        tablabels_sav[k].Value=tabfields[i].TextLabel;
        tabf.DeleteTabPage(pagenum = i);
    ENDIF;
}

Hope this helps,
Bodo.
 
Bodo Bergmann
Senior Software Engineer
OpenROAD Worldwide Development
Ingres Corp.
 

________________________________

From: openroad-users-bounces at peerlessit.com
[mailto:openroad-users-bounces at peerlessit.com] On Behalf Of Bodo
Bergmann
Sent: Wednesday, December 05, 2007 8:04 PM
To: International OpenROAD Users
Subject: Re: [Openroad-users] Deleting tabpage crashes OpenROAD


Got it working using the DeleteTabPage() method:
 
DECLARE
    ...
    maxpages=INTEGER NOT NULL DEFAULT 8;
    // Replace occurances of "8" with variable "maxpages" in previous
code samples
ENDDECLARE
 
ON CLICK del_btn =
{
    IF lastvis>1 THEN
        i=FIELD(field1).CurPageIndex;
        FIELD(field1).DeleteTabPage(pagenum = i);
        tabflds.RemoveRow(rownumber=i);
        maxpages = maxpages-1;
 
        IF i=lastvis THEN
            FIELD(field1).CurPageIndex = i-1;
        ELSE
            FIELD(field1).CurPageIndex = i;
        ENDIF;
 
        lastvis = lastvis-1;
        FIELD(field1).UpdField();
    ENDIF;
}
 
 
 
Bodo.

________________________________

From: openroad-users-bounces at peerlessit.com
[mailto:openroad-users-bounces at peerlessit.com] On Behalf Of Bodo
Bergmann
Sent: Wednesday, December 05, 2007 4:36 PM
To: International OpenROAD Users
Subject: Re: [Openroad-users] Deleting tabpage crashes OpenROAD


Frank,
 
I have no problem deleting the last of the dynamically added pages using
the following code:
 

	ON CLICK del_btn =
	{
	    i=FIELD(field1).CurPageIndex;
	    IF i=lastvis and i>1 THEN
	        lastvis = i-1;
	        FIELD(field1).CurPageIndex = lastvis;
	        tabflds_ori.RemoveRow(rownumber=i);
	        FIELD(field1).UpdField();
	    ELSE
	        MESSAGE 'You can only delete the last of the added
pages!';
	    ENDIF;
	}

I also get a crash when deleting one of the others, I'll try to find out
if there is a workaround (or fix).
 
Bodo.
 
Bodo Bergmann
Senior Software Engineer
OpenROAD Worldwide Development
Ingres Corp.
 

________________________________

From: openroad-users-bounces at peerlessit.com
[mailto:openroad-users-bounces at peerlessit.com] On Behalf Of Frank
Barratt
Sent: Wednesday, December 05, 2007 3:40 PM
To: openroad-users at peerlessit.com
Subject: [Openroad-users] Deleting tabpage crashes OpenROAD


Hi all,
 
Using code similar (and i have tried the exact code as well) to the
example (that Bodo provided) below to set up a frame with one tabfolder
containing 8 tabpages, I then needed a method of deleting a tab.
 
I have tried ALL of the following -
 
i=FIELD(field1).CurPageIndex;
 
 tabflds_ori.RemoveRow(rownumber=i);
 
or 
 
FIELD(field1).DeleteTabPage(pagenum =i);
 
or
 
 FIELD(field1).TabBar.tabfieldarray.setrowdeleted(rownum = i);
 
or
  FIELD(field1).TabBar.tabfieldarray.removerow(rownum = i);
 
All of the above work one or two times then OpenROAD crashes with the
w4gldev.exe exiting message resulting in the following in the errlog.log
 
W2MZ452Q::[II\COMSVR\984     , 00000000]: Wed Dec 05 13:27:25 2007
E_GC220B_EXP_RCV_FAIL GCA expedited receive failure: reason follows.
W2MZ452Q::[II\COMSVR\984     , 00000000]: Wed Dec 05 13:27:25 2007
E_GC0001_ASSOC_FAIL Association failure: partner abruptly released
association.
 
any help on this would be appreciated.
 
Regards
Frank.
 
initialize()=
declare
    i=INTEGER NOT NULL;
    lastvis=INTEGER NOT NULL DEFAULT 1;
    cust1 = customer DEFAULT NULL;
    tabflds_ori = ARRAY OF TabField DEFAULT NULL;
    tabflds = ARRAY OF TabField;
    tabpages = ARRAY OF TabPage DEFAULT NULL;
enddeclare
{
    tabpages = FIELD(field1).tabpagearray;
    tabflds_ori = FIELD(field1).TabBar.tabfieldarray;
    FOR i=1 TO tabflds_ori.LastRow DO
        tabflds[i] = tabflds_ori[i];
    ENDFOR;
    
    // Make pages 2 to 8 invisible
    FOR i=8 DOWNTO 2 DO
        tabpages[i].CurBias = FB_INVISIBLE;
        FIELD(field1).TabBar.tabfieldarray.RemoveRow(rownumber=i);
    ENDFOR;
    FIELD(field1).UpdField();
}
 

ON CLICK add_btn =
{
    IF lastvis<8 THEN
        lastvis = lastvis+1;
        tabpages[lastvis].CurBias = FB_CHANGEABLE;
        tabflds_ori.InsertRow(rownumber=lastvis,
rowobject=tabflds[lastvis]);
        FIELD(field1).UpdField();
        FIELD(field1).CurPageIndex = lastvis;
    ELSE
        MESSAGE 'Only 8 pages allowed';
    ENDIF;
}
 

ON CLICK check_btn =
{
    FIELD(field1).CurTabPage.GetFieldValue(value=BYREF(cust1));
    MESSAGE cust1.Name;
}

Bodo.
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.peerlessit.com/pipermail/openroad-users/attachments/20071206/b6f651de/attachment.html 


More information about the Openroad-users mailing list