Macro get problem

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

Macro get problem

#1 Post by zolifree »

Hi Roger!

I found a problem when using GET for a database field with a macro.
This is sample program:

Code: Select all

#INCLUDE "dcdialog.ch"
#pragma Library("dclipx.lib")
PROC appsys
RETURN
PROCEDURE DBESYS
DbeLoad("FOXDBE")
DbeLoad("CDXDBE")
DbeBuild("FOXCDX","FOXDBE","CDXDBE")
RETURN
PROCEDURE main
LOCAL i, GetList[0], GetOptions,instdbf:={}
aadd(instdbf,{"field1","C",30,0})
aadd(instdbf,{"field2","C",30,0})
aadd(instdbf,{"field3","C",30,0})
dbcreate("testdbf.dbf",instdbf)
use testdbf new exclusive
if lastrec()=0
 append blank
endif
wget1="testdbf->field1"
wget2="testdbf->field2"
wget3="testdbf->field3"

@ 1, 1 DCSAY "Get 1" GET &wget1
@ 2, 1 DCSAY "Get 2" GET &wget2
@ 3, 1 DCSAY "Get 3" GET &wget3

DCREAD GUI addbuttons enterexit TITLE 'Macro GET Test' 

dcmsgbox field1,field2,field3
RETURN
In exp 267 it is impossible to change the data in gets, but in exp 265 works well.

I found the source of the problem in _dcgetbx.prg
In FUNCTION DC_GetAnchorCB(....

Code: Select all

        RETURN {|x,y,z|GetSetAliased(x,y,z,uVar,cAlias)}               <<<< Remove this line

/*      <<<< Remove this line

       RETURN  {|x,y,z,l| ;
                 IIF(Valtype(y)=='O' .AND. IsMemberVar(y,'DATAALIAS'), ;
                 y:dataAlias := cAlias,nil), ;
                 IIf( x==nil .OR. uVar==x, uVar, ;
                 (l:=!(cAlias)->(RecNo())$(cAlias)->(dbRLockList()), ;
                 IIF(l,(cAlias)->(dbRLock()),nil), ;
                 uVar:=x, ;
                 IIF(l,(cAlias)->(dbRUnlock()),nil)))}
*/    <<<< Remove this line
If I remove the 3 (<<<<<) lines from the code, the problem disappears.
It restore this part of the code to the exp 266 version.

I think it is not the best solution, because there was a reason why You changed it, and it can cause other problems I am not aware now.

Best regards,
Zoltan

User avatar
rdonnay
Site Admin
Posts: 4775
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Macro get problem

#2 Post by rdonnay »

I recently fixed a similar problem for another customer with the following code change:

Code: Select all

STATIC FUNCTION GetSetAliased( x, y, z, uVar, cAlias )

LOCAL lNeedsLock

IF Valtype(y)=='O' .AND. IsMemberVar(y,'DATAALIAS')
  y:dataAlias := cAlias
ENDIF

lNeedsLock :=!(cAlias)->(RecNo())$(cAlias)->(dbRLockList()) .AND. x # nil .AND. x # uVar
IF lNeedsLock
  (cAlias)->(dbRLock())
ENDIF

IF x==nil .OR. uVar == x
 // uVar := uVar
ELSE
  uVar := x
ENDIF
IF lNeedsLock
  (cAlias)->(dbRUnlock())
ENDIF

RETURN uVar
The eXpress train is coming - and it has more cars.

zolifree
Posts: 35
Joined: Sun Sep 19, 2010 6:55 am

Re: Macro get problem

#3 Post by zolifree »

I tried it and not working, the result is same as before.
Try testing with my test program.

User avatar
rdonnay
Site Admin
Posts: 4775
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Macro get problem

#4 Post by rdonnay »

I need a test program.
The eXpress train is coming - and it has more cars.

zolifree
Posts: 35
Joined: Sun Sep 19, 2010 6:55 am

Re: Macro get problem

#5 Post by zolifree »

It is in my first post.
The first code part is a standalone test program.
This is it:

Code: Select all

#INCLUDE "dcdialog.ch"
#pragma Library("dclipx.lib")
PROC appsys
RETURN
PROCEDURE DBESYS
DbeLoad("FOXDBE")
DbeLoad("CDXDBE")
DbeBuild("FOXCDX","FOXDBE","CDXDBE")
RETURN
PROCEDURE main
LOCAL i, GetList[0], GetOptions,instdbf:={}
aadd(instdbf,{"field1","C",30,0})
aadd(instdbf,{"field2","C",30,0})
aadd(instdbf,{"field3","C",30,0})
if !file("testdbf.dbf")
 dbcreate("testdbf.dbf",instdbf)
endif
use testdbf new exclusive
if lastrec()=0
 append blank
endif
wget1="testdbf->field1"
wget2="testdbf->field2"
wget3="testdbf->field3"

@ 1, 1 DCSAY "Get 1" GET &wget1
@ 2, 1 DCSAY "Get 2" GET &wget2
@ 3, 1 DCSAY "Get 3" GET &wget3

DCREAD GUI addbuttons enterexit TITLE 'Macro GET Test' 

dcmsgbox field1,field2,field3
RETURN

User avatar
rdonnay
Site Admin
Posts: 4775
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Macro get problem

#6 Post by rdonnay »

Your sample program works fine with my current version of _DCGETBX.PRG
Attachments
_dcgetbx.zip
(88.13 KiB) Downloaded 495 times
The eXpress train is coming - and it has more cars.

zolifree
Posts: 35
Joined: Sun Sep 19, 2010 6:55 am

Re: Macro get problem

#7 Post by zolifree »

I tried to use this, but still not working here.
Try with the original dclipx.dll as it is after installing it.
I attached a zip file with the dclipx.dll and the test program.

When You write something in the gets, after the enter key the changes disappears in the edit box.
Attachments
test.zip
(2.85 MiB) Downloaded 514 times

User avatar
rdonnay
Site Admin
Posts: 4775
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Macro get problem

#8 Post by rdonnay »

This file works
Attachments
dclipx.zip
(2.95 MiB) Downloaded 483 times
The eXpress train is coming - and it has more cars.

zolifree
Posts: 35
Joined: Sun Sep 19, 2010 6:55 am

Re: Macro get problem

#9 Post by zolifree »

Yes it is working, but I need the source code too.
A made some customizations in the source code for my needs, so I need the source to be able to make my own dclipx.dll

User avatar
rdonnay
Site Admin
Posts: 4775
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Macro get problem

#10 Post by rdonnay »

Yes it is working, but I need the source code too.
I gave you the source code in a previous response to this thread. It is in _DCGETBX.PRG.

Copy it to your \exp20\source\dclipx folder and run build20.bat to rebuild dclipx.dll
The eXpress train is coming - and it has more cars.

Post Reply