Page 1 of 1
How to interrupt posting process to edit screen
Posted: Tue Sep 25, 2012 12:52 pm
by Cliff Wiernik
We are completing conversion from clipper of a dialog that batch posts cash receipt transaction.
In clipper we have the following loop
do while !eof()
allocate cash receipt
get fields
clear gets
validate receipt
if out of balance
get field
read
correct out of balance situation
save and post
endif
skip to next record
enddo
In Express++ we first build screen (used also for manual cash receipt posting)
do while !eof()
allocate cash
dc_getrefresh to update screen
do validation
if out of balance
turn on edit mode and refresh
go to first field
make changes
save record and post
end
skip to next record
enddo
The problem is that in normal edit mode we are in the event loop and it waits for us to press a key before any thing happens. In the automated processing, we are inside of the do while loop and it does not wait for us to make the changes. When we go to the set app focus, it does this but then goes to the next line of code in the loop. We don't have the intervening READ statement like in clipper. What we would like is something like a modal mode but we want to use the same dialog and memory variables that are currently on the screen.
Is something like this possible to get done.
Cliff.
Re: How to interrupt posting process to edit screen
Posted: Tue Sep 25, 2012 4:25 pm
by rdonnay
Here is a little sample program that may give you some ideas.
Code: Select all
#INCLUDE "dcdialog.CH"
FUNCTION Main()
LOCAL GetList[0], GetOptions, oDlg, lStatus := .t., nStatus
USE \exp19\data\xtest
@ 0,0 DCSAY {||XTEST->city} SIZE 30 SAYLEFTBOTTOM
@ 2,0 DCSAY 'Area Code' GET XTEST->areacode
@ 4,0 DCSAY 'Exchange' GET XTEST->exchange
@ 6,0 DCSAY 'Number' GET XTEST->number
@ 8,0 DCPUSHBUTTON CAPTION 'Done' SIZE 10,1.2 ;
ACTION {||DC_ReadGuiEvent(DCGUI_EXIT_ABORT,GetList)}
@ 8,12 DCPUSHBUTTON CAPTION 'Next' SIZE 10,1.2 ;
ACTION {||DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList)}
DCGETOPTIONS SAYWIDTH 100 SAYRIGHTBOTTOM
DCREAD GUI FIT TITLE 'Editing Data' EXIT SAVE PARENT @oDlg OPTIONS GetOptions
DO WHILE lStatus
lStatus := DC_ReadGuiEventLoop(GetList)
XTEST->(dbSkip())
DC_GetRefresh(GetList)
ENDDO
oDlg:destroy()
RETURN nil
* -----------
PROC appsys ; return
Re: How to interrupt posting process to edit screen
Posted: Tue Sep 25, 2012 7:31 pm
by Auge_Ohr
Cliff Wiernik wrote:We are completing conversion from clipper of a dialog that batch posts cash receipt transaction.
...
The problem is that in normal edit mode we are in the event loop and it waits for us to press a key before any thing happens.
how do you "allocate cash receipt" ?
the Window Way is to run 2 Thread.
when 1st Thread to "allocate cash receipt" is finsh it send a Userdef Event to 2nd Thread where you got Data to edit.
Re: How to interrupt posting process to edit screen
Posted: Wed Sep 26, 2012 7:14 am
by Cliff Wiernik
Allocation of receipt - in its simplest format, take total cash receipt, and post in this order (outstanding late charges, then unpaid interest, then to remaining principal and any excess to over payment), however, if this is a void payment, the automatic allocation is not possible and manual intervention is needed. The manual cash receipts are currently in a single thread and the automation is currently in the same thread.
To do it in 2 threads would be possible, but the problem is that all the variables are in the manual posting thread and so is the actual routines to post the transactions after allocated. I don't really want to have to duplicate the code. I just need a methodology to pause the loop and make the normal edit screen active to get the proper allocation (with the original event loop working) and then continue with the processing.
Re: How to interrupt posting process to edit screen
Posted: Wed Sep 26, 2012 7:26 am
by rdonnay
The first method I gave you operates in 1 thread.
Here's one that operates in 2 threads, as Jimmy suggested.
Code: Select all
#INCLUDE "dcdialog.CH"
#INCLUDE "appevent.CH"
#define EDIT_RECORD xbeP_User+1
FUNCTION Main()
LOCAL GetList[0], GetOptions, oDlg, lStatus := .t., nStatus, ;
lContinue := .t., oAreaCode
USE \exp19\data\xtest
DCUSEREVENT EDIT_RECORD ;
ACTION {|n|XTEST->(DbGoto(n)), ;
DC_GetRefresh(GetList), ;
SetAppFocus(oAreaCode)}
@ 0,0 DCSAY {||XTEST->city} SIZE 30 SAYLEFTBOTTOM
@ 2,0 DCSAY 'Area Code' GET XTEST->areacode GETOBJECT oAreaCode
@ 4,0 DCSAY 'Exchange' GET XTEST->exchange
@ 6,0 DCSAY 'Number' GET XTEST->number
@ 8,0 DCPUSHBUTTON CAPTION 'Done' SIZE 10,1.2 ;
ACTION {||DC_ReadGuiEvent(DCGUI_EXIT_ABORT,GetList)}
@ 8,12 DCPUSHBUTTON CAPTION 'Next' SIZE 10,1.2 ;
ACTION {||lContinue := .t.,Sleep(50)}
DCGETOPTIONS SAYWIDTH 100 SAYRIGHTBOTTOM
DCREAD GUI FIT TITLE 'Editing Data' PARENT @oDlg OPTIONS GetOptions ;
EVAL {|o|o := Thread():new(),Sleep(5),o:start({||Processing(@lContinue)})}
RETURN nil
* -----------
PROC appsys ; return
* -----------
STATIC FUNCTION Processing( lContinue )
USE \exp19\data\xtest
DO WHILE !XTEST->(Eof())
lContinue := .f.
PostAppEvent(EDIT_RECORD,XTEST->(RecNo()))
Sleep(1)
DO WHILE !lContinue
Sleep(50)
ENDDO
XTEST->(dbSkip())
ENDDO
dbCloseAll()
RETURN nil