Can anyone recommend some material available on how to convert my present app (not networkable) to a network version.
Using clipper 5.2e Harbour and FWH
Thanks
/* LOGICAL NETUSE( CDATABASE, LOPENMODE, NSECONDS )
CHARACTER CDATABASE - NAME OF DATABASE
LOGICAL LOPENMODE - OPEN MODE .T. exclusive .F. shared
NUMERIC NSECONDS - NUMBER OF SECONDS TO WAIT 0 forever
RETURN .T. if successful, .F. if not
SAMPLE CALL IF NETUSE( "CALLS", .F., 5 )
*/
Func NETUSE( CDATABASE, LOPENMODE, NSECONDS )
LOCAL FOREVER, RESTART, WAIT_TIME, YESNO
RESTART := .T.
FOREVER := ( NSECONDS = 0 )
YESNO := {"Yes" , "No"}
DO WHILE RESTART
WAIT_TIME := NSECONDS
DO WHILE ( FOREVER .OR. WAIT_TIME > 0 )
IF LOPENMODE
USE ( CDATABASE ) via "DBFCDX" EXCLUSIVE
ELSE
USE ( CDATABASE ) via "DBFCDX" SHARED
ENDIF
IF .NOT. NETERR()
RETURN(.T.)
ENDIF
INKEY(1)
WAIT_TIME--
ENDDO
* lock failed, ask to continue
IF MsgYesNo( "Cannot lock " + CDATABASE + ", retry ?" )
ELSE
EXIT
ENDIF
ENDDO
RETURN(.F.)
//--------------------------
/*
LOGICAL ADDREC( NWAITSECONDS )
NUMERIC NWAITSECONDS
APPEND BLANK function with user interaction if failed
RETURN .T. if successful, .F. if not
SAMPLE CALL IF ADDREC( 5 )
SAMPLE TO UNSELECTED DATABASE IF ADDRESS->(ADDREC(5))
*/
Func ADDREC( NWAITSECONDS )
LOCAL LFOREVER, WAIT_TIME, RESTART, YESNO
APPEND BLANK
IF .NOT. NETERR()
RETURN(.T.)
ENDIF
RESTART := .T.
LFOREVER := ( NWAITSECONDS = 0 )
YESNO := {"Yes", "No"}
DO WHILE RESTART
WAIT_TIME := NWAITSECONDS
DO WHILE ( LFOREVER .OR. WAIT_TIME > 0 )
APPEND BLANK
IF .NOT. NETERR()
RETURN .T.
ENDIF
INKEY(.5) // wait 1/2 second to try again
WAIT_TIME := WAIT_TIME - .5
ENDDO
* if failed ask user to continue
IF MsgYesNo( "Cannot add Record, retry ?" )
ELSE
EXIT
ENDIF
ENDDO
RETURN(.F.)
//-----------------
/*
LOGICAL RECLOCK( WAIT )
NUMERIC WAIT
RETURN .T. if successful, .F. if not
RECORD LOCK ROUTINE WITH USER INTERACTION IF LOCK FAILES
SAMPLE CALL IF RECLOCK( 5 )
*/
Func RECLOCK( NSECONDS )
LOCAL LFOREVER, RESTART, WAIT_TIME, YESNO
IF RLOCK()
RETURN (.T.) // LOCKED
ENDIF
RESTART := .T.
LFOREVER := ( NSECONDS = 0 )
YESNO := {"Yes" , "No"}
DO WHILE RESTART
WAIT_TIME := NSECONDS
DO WHILE ( LFOREVER .OR. WAIT_TIME > 0 )
IF RLOCK()
RETURN(.T.)
ENDIF
INKEY(.5)
WAIT_TIME := WAIT_TIME - .5
ENDDO
* lock failed
IF MsgYesNo( "Cannot lock Record, retry ?" )
ELSE
EXIT
ENDIF
ENDDO
RETURN( .F.)
Where do I put the functions you described.
I open 20 + data files at beginning of the program and others elsewhere.
select 1
if netuse( "Customer.dbf", .f.,5 ) // database, .t. for exclusive lock, .f. for shared, 5 for time-out
else
return(.f.)
endif
Select 2
if netuse( "Invoice.dbf", .f.,5 ) // database, .t. for exclusive lock, .f. for shared, 5 for time-out
else
return(.f.)
endif
Are the functions a one time call for each file or a many time call where are initialized?
>I open 20 + data files at beginning of the program and others elsewhere.
INIT PROCEDURE PrgInit
SET CENTURY ON
SET EPOCH TO YEAR(DATE())-98
SET DELETED ON
SET EXCLUSIVE OFF
REQUEST HB_Lang_DE
REQUEST HB_CODEPAGE_DEWIN
HB_LangSelect("DE")
HB_SetCodePage("DEWIN")
SET DATE TO GERMAN
SetHandleCount(205)
rddsetdefault( "DBFCDX" )
RETURN
use &dbfname ALIAS &mAlias SHARED NEW
Ad exclusive)
I personally change always in a prgInit procedure the exclusive mode to off.
So all databases are automatically opened shared.
How do I use an alias with netuse() ?
IF LOPENMODE
if empty(cAlias)
USE ( CDATABASE ) via "DBFCDX" EXCLUSIVE
else
USE ( CDATABASE ) ALIAS &cAlias via "DBFCDX" EXCLUSIVE
Endif
ELSE
if empty(cAlias)
USE ( CDATABASE ) via "DBFCDX" SHARED
else
USE ( CDATABASE ) ALIAS &cAlias via "DBFCDX" SHARED
ENDIF
hag wrote:Can anyone recommend some material available on how to convert my present app (not networkable) to a network version.
Using clipper 5.2e Harbour and FWH
Thanks
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 69 guests