home *** CD-ROM | disk | FTP | other *** search
- /*
- ╓──────────────────────────────────────────────────────────╖
- ║ Program..: X2CLIP.PRG ║
- ║ Author...: Roger J. Donnay ║
- ║ Notice...: (c) DONNAY Software Designs 1987-1999 ║
- ║ Date.....: Apr 20, 1999 ║
- ║ Notes....: Xbase++ to Clipper Interface ║
- ╙──────────────────────────────────────────────────────────╜
-
- Note: This is part of the Clipper application
- */
-
- #INCLUDE "inkey.CH"
- #include "DCXTOC.CH"
-
- REQUEST COMIX
- REQUEST DBFCDX
- REQUEST DBFNTX
-
- EXTERN achoice,acopy,adel,adir,afields,afill,ains,ampm,strzero,;
- alltrim,ascan,asort,bin2i,bin2l,bin2w,;
- curdir,dbedit,dbfilter,descend,diskspace,doserror,;
- dbrelation,dbrselect,readinsert,setcancel,readexit,;
- errorlevel,fclose,fcreate,ferror,fopen,fread,freadstr,;
- fseek,fwrite,gete,hardcr,header,i2bin,isalpha,;
- indexext,indexord,islower,isupper,isprinter,;
- l2bin,lupdate,memoedit,memoline,memoread,memotran,;
- memowrit,mlcount,mlpos,neterr,nextkey,left,alias,;
- rat,savescreen,scroll,right,recsize,errorsys,netname,;
- setcolor,setprc,soundex,strtran,stuff,tone,memory
-
- FUNCTION DC_X2Clip( nHandle, cDefault, nTimeOut )
-
- LOCAL nSaveArea := Select(), aStructure, i, nMaxCount, ;
- nSeconds, bErrorBlock, aData
-
- Inkey(1)
-
- IF Valtype(nHandle) = 'C'
- nHandle := Val(nHandle)
- ENDIF
-
- nHandle := IIF(Valtype(nHandle)='N',nHandle,0 )
- nTimeOut := IIF(Valtype(nTimeOut)='N',nTimeOut,5 )
-
- IF !Empty(cDefault)
- Set(_SET_DEFAULT,cDefault)
- ENDIF
- CLOSE ALL
-
- IF nHandle = 0
- CLS
- ? 'This program must be passed a valid Handle.'
- ? 'It is designed for interaction with an Xbase++ program.'
- ? 'See the eXPress++ documentation for more information.'
- QUIT
- ENDIF
-
- IF !File('X2Clip.Dbf')
- aStructure := { ;
- { 'OPERATION', 'N', 2, 0 },;
- { 'DEFAULT', 'C', 100, 0 },;
- { 'PATH', 'C', 100, 0 },;
- { 'DATABASE', 'C', 100, 0 },;
- { 'INDEX', 'C', 100, 0 },;
- { 'RDD', 'C', 10, 0 },;
- { 'SHARED', 'L', 1, 0 },;
- { 'TAG', 'C', 10, 0 },;
- { 'KEY', 'C', 254, 0 },;
- { 'RECORD', 'N', 10, 0 },;
- { 'WHILE', 'C', 4000, 0 },;
- { 'FOR', 'C', 4000, 0 },;
- { 'EVERY', 'N', 12, 3 },;
- { 'DATE', 'D', 8, 0 },;
- { 'TIME', 'C', 8, 0 },;
- { 'ERRORCODE', 'N', 4, 0 },;
- { 'UNIQUE', 'L', 1, 0 },;
- { 'DESCEND', 'L', 1, 0 },;
- { 'CURRCOUNT', 'N', 10, 0 },;
- { 'MESSAGE', 'C', 254, 0 },;
- { 'DATA', 'C', 4000, 0 },;
- { 'PROGRAM', 'C', 10, 0 },;
- { 'VERBOSE', 'L', 1, 0 },;
- { 'INTERPRET', 'C', 254, 0 },;
- { 'ACTIVE', 'L', 1, 0 },;
- { 'DONE', 'L', 1, 0 },;
- { 'MAXCOUNT', 'N', 12, 0 },;
- { 'USER1', 'C', 254, 0 },;
- { 'USER2', 'C', 254, 0 },;
- { 'USER3', 'C', 254, 0 },;
- { 'USER4', 'C', 254, 0 },;
- { 'NEXT', 'N', 10, 0 },;
- { 'REST', 'L', 1, 0 },;
- { 'DELETED', 'L', 1, 0 } }
-
-
- dbCreate( 'X2Clip.DBF', aStructure, 'DBFNTX' )
- SELE 200
- USE X2Clip VIA 'DBFNTX' SHARED
- FOR i := 1 TO 50
- APPEND BLANK
- NEXT
- CLOSE
- ENDIF
-
- ? 'Opening Handle #' + Alltrim(Str(nHandle))
-
- DO WHILE Inkey(.1) # K_ESC
-
- IF !_DbSel('X2CLIP')
- SELE 200
- USE X2Clip SHARED VIA "DBFNTX"
- GO nHandle
- IF _RecLock(5)
- REPL X2CLIP->done WITH .t., ;
- X2CLIP->operation WITH XC_DONE
- COMMIT
- UNLOCK
- ENDIF
- SELE (nSaveArea)
- nSeconds := Seconds()
- ENDIF
-
- X2Clip->(dbGoTo(nHandle))
-
- SELE (nSaveArea)
- ? Alias(), X2Clip->maxcount
-
- IF !Empty(Alias()) .AND. X2Clip->maxcount < 0
- nMaxCount := RecCount()
- SELE X2Clip
- IF _RecLock(5)
- REPL X2Clip->maxcount WITH nMaxCount
- COMMIT
- UNLOCK
- ENDIF
- SELE (nSaveArea)
- nSeconds := Seconds()
- ENDIF
-
- IF X2Clip->operation = XC_EXIT
-
- SELE (nSaveArea)
- IF !Empty(Alias()) .AND. Alias() # 'X2CLIP'
- ? 'Closing ' + Alias(), X2CLIP->done, X2CLIP->active
- Inkey(1)
- ENDIF
- SELE SELECT('X2CLIP')
- IF _RecLock(5)
- REPL X2CLIP->done WITH .t., ;
- X2CLIP->active WITH .f.
- ENDIF
- CLOSE ALL
- EXIT
-
- ELSEIF X2Clip->operation = XC_OPENDATA
-
- SELE (nSaveArea)
- OpenData( nHandle, cDefault )
- nSaveArea := Select()
- Done( nHandle, cDefault )
-
- ELSEIF X2Clip->operation = XC_OPENINDEX
-
- SELE (nSaveArea)
- OpenIndex( nHandle, cDefault )
- Done( nHandle, cDefault )
-
- ELSEIF X2Clip->operation = XC_PROGRAM
-
- bErrorBlock := ErrorBlock({|e|FileError(e,X2CLIP->program,nHandle,cDefault)})
- aData := _Str2Ar(X2Clip->data)
- SELE x2clip
- IF _Reclock(5)
- REPL X2CLIP->data WITH ''
- COMMIT
- UNLOCK
- ENDIF
- SELE (nSaveArea)
- IF X2CLIP->verbose
- ? 'Calling custom program: ' + X2Clip->program
- ENDIF
- DO &(X2Clip->program) WITH aData, nHandle, cDefault
- Done( nHandle, cDefault )
- ErrorBlock(bErrorBlock)
-
- ELSEIF X2Clip->operation = XC_CREATEINDEX
-
- SELE (nSaveArea)
- CreateIndex( nHandle, cDefault )
- Done( nHandle, cDefault )
-
- ELSEIF X2Clip->operation = XC_COPYDATA
-
- SELE (nSaveArea)
- CopyData( nHandle, cDefault )
- Done( nHandle, cDefault )
-
- ELSEIF X2Clip->operation = XC_CLOSEDATA
-
- SELE (nSaveArea)
- CLOSE
- Done( nHandle, cDefault )
-
- ENDIF
-
- FT_IamIdle()
-
- ENDDO
-
- RETURN nil
-
- /* ---------------------- */
-
- STATIC FUNCTION OpenData( nHandle, cDefault )
-
- LOCAL cDatabase, cDefaultDir, bErrorBlock, nError, ;
- cSaveDefault := Set(_SET_DEFAULT), cRdd, lShared, ;
- nSaveArea, lVerbose, cSavePath := Set(_SET_PATH), cPath
-
- BEGIN SEQUENCE
-
- bErrorBlock := ErrorBlock({|e|FileError(e,cDatabase,nHandle,cDefault)})
-
- cDefaultDir := Alltrim(X2CLIP->default)
- cDatabase := Alltrim(X2CLIP->database)
- cPath := Alltrim(X2CLIP->path)
- cRdd := Alltrim(X2CLIP->rdd)
- lShared := X2CLIP->shared
- lVerbose := X2CLIP->verbose
-
- IF Empty(cDatabase)
- nError := XCERROR_NOFILENAME
- BREAK
- ENDIF
-
- IF !Empty(cDefaultDir)
- Set(_SET_DEFAULT,cDefaultDir)
- ENDIF
-
- IF !Empty(cPath)
- Set(_SET_PATH,cPath)
- ENDIF
-
- IF Empty(cRdd)
- cRdd := 'DBFNTX'
- ENDIF
-
- nError := 0
-
- SELE 0
-
- IF lShared
- IF lVerbose
- ? 'USE ' + cDatabase + ' VIA ' + cRdd + ' SHARED'
- ENDIF
- USE (cDatabase) VIA (cRdd) SHARED
- ELSE
- IF lVerbose
- ? 'USE ' + cDatabase + ' VIA ' + cRdd
- ENDIF
- USE (cDatabase) VIA (cRdd)
- ENDIF
-
- END SEQUENCE
- ErrorBlock(bErrorBlock)
- Set(_SET_DEFAULT,cSaveDefault)
- Set(_SET_PATH,cSavePath)
-
- IF nError > 0
- nSaveArea := Select()
- SELE X2Clip
- IF _RecLock(2)
- REPL X2Clip->errorcode WITH nError
- COMMIT
- UNLOCK
- ENDIF
- SELE (nSaveArea)
- ENDIF
-
- RETURN nError
-
- /* ---------------------- */
-
- STATIC FUNCTION OpenIndex( nHandle, cDefault )
-
- LOCAL cIndex, cDefaultDir, bErrorBlock, nError, lVerbose, ;
- cSaveDefault := Set(_SET_DEFAULT), nSaveArea, ;
- cTagName, cPath, cSavePath := Set(_SET_PATH)
-
- BEGIN SEQUENCE
-
- bErrorBlock := ErrorBlock({|e|FileError(e,cIndex,nHandle,cDefault)})
- cDefaultDir := Alltrim(X2CLIP->default)
- cPath := Alltrim(X2CLIP->path)
- cIndex := Alltrim(X2CLIP->index)
- cTagName := Alltrim(X2CLIP->tag)
- lVerbose := X2CLIP->verbose
-
- IF Empty(cIndex)
- nError := XCERROR_NOFILENAME
- BREAK
- ENDIF
-
- IF !Empty(cDefaultDir)
- Set(_SET_DEFAULT,cDefaultDir)
- ENDIF
-
- IF !Empty(cPath)
- Set(_SET_PATH,cPath)
- ENDIF
-
- nError := 0
-
- IF lVerbose
- ? 'SET INDEX TO ' + cIndex + 'ADDITIVE'
- ENDIF
- SET INDEX TO (cIndex) ADDITIVE
- IF !Empty(cTagName)
- OrdSetFocus(cTagName)
- ENDIF
-
- END SEQUENCE
- ErrorBlock(bErrorBlock)
- Set(_SET_DEFAULT,cSaveDefault)
- Set(_SET_PATH,cSavePath)
-
- IF nError > 0
- nSaveArea := Select()
- SELE X2Clip
- IF _RecLock(2)
- REPL X2Clip->errorcode WITH nError
- COMMIT
- UNLOCK
- ENDIF
- SELE (nSaveArea)
- ENDIF
-
- RETURN nError
-
- /* ------------------------- */
-
- STATIC FUNCTION CreateIndex( nHandle, cDefault )
-
- LOCAL cFor, cWhile, cKey, cTagName, cIndex, lUnique, lDescend, ;
- bFor, bWhile, bErrorBlock := ErrorBlock(), nError := 0, ;
- lCombined, nSaveArea, nEvery, bEval, lVerbose, nMaxCount
-
- BEGIN SEQUENCE
-
- bErrorBlock := ErrorBlock({|e|FileError(e,cIndex,nHandle,cDefault)})
-
- cFor := Alltrim(X2Clip->for)
- cWhile := Alltrim(X2Clip->while)
- cKey := Alltrim(X2Clip->key)
- cTagName := Alltrim(X2Clip->tag)
- cIndex := Alltrim(X2Clip->index)
- lDescend := X2Clip->descend
- lUnique := X2Clip->unique
- nEvery := X2Clip->every
- lVerbose := X2Clip->verbose
- IF !EMPTY(cFor)
- bFor := {|| &(cFor) }
- ELSE
- bFor := nil
- cFor := nil
- ENDIF
-
- IF Empty(cKey)
- nError := XCERROR_NOINDEXKEY
- BREAK
- ENDIF
-
- IF Empty(cIndex)
- nError := XCERROR_NOFILENAME
- BREAK
- ENDIF
-
- IF nEvery < 1 .AND. nEvery > 0
- nEvery := Int(nEvery*RecCount())
- ELSEIF nEvery = 0
- nEvery := Int(RecCount()/100)
- ENDIF
-
- bEval := {||DC_XCUpdate(RecNo(),RecCount(),1)}
-
- IF lVerbose
- ? 'Creating Index Tag ' + cTagName + ' of ' + cIndex
- ? 'Key:', cKey
- ? 'For:', cFor
- ? 'Alias:', Alias()
- ENDIF
-
- OrdCondSet( cFor, bFor,.t.,, bEval, nEvery,RecNo(),,,, lDescend )
- OrdCreate(cIndex,cTagName,cKey,{||&cKey},IIF(lUnique,.t.,nil))
-
- END SEQUENCE
- ErrorBlock(bErrorBlock)
-
- IF nError > 0
- nSaveArea := Select()
- SELE X2Clip
- IF _RecLock(2)
- REPL X2Clip->errorcode WITH nError
- COMMIT
- UNLOCK
- ENDIF
- SELE (nSaveArea)
- ENDIF
-
- RETURN nError
-
-
- /* ------------------------- */
-
- STATIC FUNCTION CopyData( nHandle, cDefault )
-
- LOCAL cFor, cWhile, cKey, cFilter, bWhile, bErrorBlock := ErrorBlock(), nError := 0, ;
- nSaveArea, lVerbose, cToFile
-
- BEGIN SEQUENCE
-
- ? 'COPYING DATA'
-
- bErrorBlock := ErrorBlock({|e|FileError(e,cIndex,nHandle,cDefault)})
-
- cFileName := Alltrim(X2Clip->database)
- cFor := Alltrim(X2Clip->for)
- cWhile := Alltrim(X2Clip->while)
- cRdd := Alltrim(X2Clip->rdd)
- lVerbose := X2Clip->verbose
- cToFile := Alltrim(X2Clip->user1)
-
- IF !Empty(cFor)
- ? cFor
- SET FILTER TO &(cFor)
- ENDIF
-
- ? cFileName
- ? cToFile
-
- COPY TO (cToFile) VIA (cRdd)
-
- END SEQUENCE
- ErrorBlock(bErrorBlock)
-
- IF nError > 0
- nSaveArea := Select()
- SELE X2Clip
- IF _RecLock(2)
- REPL X2Clip->errorcode WITH nError
- COMMIT
- UNLOCK
- ENDIF
- SELE (nSaveArea)
- ENDIF
-
- RETURN nError
-
-
- /* ----------------------- */
-
- STATIC FUNCTION Done( nHandle, cDefault )
-
- LOCAL cOldDefault := Set(_SET_DEFAULT)
-
- IF !_DbSel('X2CLIP')
- IF !Empty(cDefault)
- Set(_SET_DEFAULT,cDefault)
- ENDIF
- USE X2CLIP NEW SHARED VIA "DBFNTX"
- GO nHandle
- Set(_SET_DEFAULT,cOldDefault)
- ENDIF
-
- IF _RecLock(5)
- REPL X2CLIP->operation WITH XC_DONE, ;
- X2CLIP->done WITH .t., ;
- X2CLIP->default WITH '', ;
- X2CLIP->database WITH '', ;
- X2CLIP->index WITH '', ;
- X2CLIP->rdd WITH '', ;
- X2CLIP->shared WITH .f., ;
- X2CLIP->tag WITH '', ;
- X2CLIP->key WITH '', ;
- X2CLIP->record WITH 0, ;
- X2CLIP->date WITH CTOD(' / / '), ;
- X2CLIP->time WITH '', ;
- X2CLIP->while WITH '', ;
- X2CLIP->for WITH '', ;
- X2CLIP->errorcode WITH 0, ;
- X2CLIP->unique WITH .f., ;
- X2CLIP->descend WITH .f., ;
- X2CLIP->currcount WITH 0, ;
- X2CLIP->message WITH '', ;
- X2CLIP->program WITH '', ;
- X2CLIP->interpret WITH '', ;
- X2CLIP->maxcount WITH -1, ;
- X2CLIP->path WITH ''
- COMMIT
- UNLOCK
-
- ENDIF
-
- RETURN nil
-
- /* ------------------- */
-
- STATIC FUNCTION FileError( e, cFileName, nHandle, cDefault )
-
- LOCAL cErrorInfo, cMoreInfo, nOSCode, aError, ;
- cOldDefault := Set(_SET_DEFAULT)
-
- cErrorInfo := e:description()+' '+e:operation()+;
- IIF(!EMPTY(e:subsystem()),;
- " "+e:subsystem() + "[" + LTrim(Str(e:subCode())) + "]",'')+;
- IIF(e:OSCode()>0," OS Code["+LTrim(Str(e:OSCode()))+"]",'')
-
-
- ? cErrorInfo
-
- cMoreInfo := ''
- nOSCode := e:OSCode()
- DO CASE
- CASE nOsCode=2
- cMoreInfo := 'File not found.'
- CASE nOsCode=3
- cMoreInfo := 'Path not found.'
- CASE nOsCode=4
- cMoreInfo := 'Out of File Handles.'
- CASE nOsCode=5
- cMoreInfo := 'Access Denied.'
- CASE nOsCode=15
- cMoreInfo := 'Invalid Drive was Specified.'
- CASE nOsCode=21
- cMoreInfo := 'Drive not Ready.'
- CASE nOsCode=32
- cMoreInfo := 'Sharing Violation.'
- OTHERWISE
- nOsCode := 99
- cMoreInfo := 'Unknown'
- ENDCASE
-
- aError := { nOsCode, cFileName, cErrorInfo, cMoreInfo }
-
- IF !_DbSel('X2CLIP')
- Set(_SET_DEFAULT,cDefault)
- USE X2CLIP NEW SHARED VIA "DBFNTX"
- GO nHandle
- ENDIF
- Set(_SET_DEFAULT,cOldDefault)
- Done( nHandle )
- IF _RecLock(5)
- REPL X2CLIP->errorcode WITH nOSCode, ;
- X2CLIP->data WITH _Ar2Str(aError), ;
- X2CLIP->active WITH .f.
- COMMIT
- UNLOCK
- QUIT
- ENDIF
-
- RETURN nil
-
- /* -------------------- */
-
- FUNCTION DC_XCUpdate( nCurr, nMax, nEvery, aData )
-
- LOCAL nSaveArea
-
- nCurr := IIF( Valtype(nCurr)='N',nCurr,RecNo() )
- nMax := IIF( Valtype(nMax)='N',nMax,RecCount() )
- nEvery := Int(IIF( Valtype(nEvery)='N',nEvery,1 ))
-
- IF nCurr % nEvery # 0 .AND. nCurr < nMax
- RETURN nil
- ENDIF
-
- nSaveArea := Select()
- SELE X2Clip
- IF _RecLock(5)
- REPL X2CLIP->currcount WITH nCurr, ;
- X2CLIP->maxcount WITH nMax, ;
- X2CLIP->every WITH nEvery
- IF Valtype(aData) = 'A'
- REPL X2CLIP->data WITH _Ar2Str(aData)
- ENDIF
- COMMIT
- UNLOCK
- ENDIF
- SELE (nSaveArea)
-
- RETURN nil
-
- /* -------------------- */
-
- FUNCTION DC_XCReturn( aData )
-
- LOCAL nSaveArea := Select()
-
- SELE X2Clip
-
- IF _RecLock(5)
- REPL X2CLIP->data WITH _Ar2Str(aData)
- COMMIT
- UNLOCK
- ENDIF
- SELE (nSaveArea)
-
- RETURN nil
-
- /* -------------------- */
-
- FUNCTION DC_XCOk()
-
- RETURN !X2Clip->done
-
- /* ------------------- */
-
- STATIC FUNCTION _dbsel ( cAlias )
-
- LOCAL i
-
- cAlias := IIF(Valtype(cAlias)='C',UPPER(cAlias),'')
- IF SELECT(cAlias)>0 .AND. !(':'$cAlias)
- SELE SELECT(cAlias)
- RETURN .t.
- ENDIF
- RETURN .f.
-
- /* ------------------- */
-
- STATIC FUNCTION _reclock ( nWaitTime )
-
- LOCAL nWait
-
- nWaitTime := IIF(Valtype(nWaitTime)='N',nWaitTime,1)
- IF DBRLOCK()
- RETURN (.T.) // locked
- ENDIF
- DO WHILE .T.
- nWait := nWaitTime
- DO WHILE (nWaitTime=0 .OR. nWait>0)
- IF DBRLOCK() // locked
- RETURN (.T.)
- ENDIF
- INKEY(.5) // wait 1/2 second
- nWait := nWait - .5
- ENDDO
- RETURN .F.
- ENDDO
- RETURN (.F.) // not locked
-
- // ----------------- //
-
- STATIC FUNCTION _ar2str ( aArray, lHeader )
-
- LOCAL cArray := ''
- lHeader := IIF(Valtype(lHeader)='L',lHeader,.f.)
- IF lHeader
- cArray := CHR(1)+'Array String:'
- ENDIF
- _dcStore( aArray, @cArray )
- RETURN cArray
-
-
- // ----------------- //
-
- STATIC FUNCTION _dcStore( xThing, cArray )
- LOCAL cItem
-
- DO CASE
-
- CASE valtype( xThing ) == "A"
- _dcarray( xThing, @cArray )
-
- OTHERWISE
- cItem := _dcitem( xThing )
- IF Valtype( cItem ) = 'C'
- cArray += cItem
- ENDIF
-
- ENDCASE
- RETURN nil
-
- // ----------------- //
-
- STATIC FUNCTION _dcArray( aArray, cArray )
-
- LOCAL i, cItem, cL2bin := l2bin(len(aArray))
-
- IF CHR(26)$cL2bin
- cArray += "O"+ DC_l2Dec(len(aArray))
- ELSE
- cArray += "A"+ cL2bin
- ENDIF
- FOR i = 1 TO Len(aArray)
- cItem := _dcitem( aArray[i], @cArray )
- IF Valtype( cItem ) = 'C'
- cArray += cItem
- ENDIF
- NEXT i
- RETURN nil
-
- // ----------------- //
-
- STATIC FUNCTION _dcItem ( xItem, cArray )
-
- LOCAL cRetVal, cType := Valtype( xItem ), cL2bin
-
- DO CASE
-
- CASE cType == "C"
- cL2bin := l2bin( Len( xItem ))
- IF CHR(26)$cL2bin
- cRetVal := "M"+DC_l2Dec( len( xItem)) + xItem
- ELSE
- cRetVal := "C"+cL2bin+xItem
- ENDIF
-
- CASE cType == "N"
- IF '.'$STR(xItem)
- xItem := STR(xItem)
- cRetVal := "F"+l2Bin( len( xItem)) + xItem
- ELSE
- cL2bin := l2bin(xItem)
- IF CHR(26)$cL2bin
- cRetVal := "W"+DC_l2Dec(xItem)
- ELSE
- cRetVal := "N"+l2bin(xItem)
- ENDIF
- ENDIF
-
- CASE cType == "L"
- cRetVal := "L"+if(xItem, "T", "F")
-
- CASE cType == "U"
- cRetVal := "U"
-
- CASE cType == "D"
- cRetVal := "D"+l2bin( xItem - ctod("01/01/70") )
-
- CASE cType == "B"
- cRetVal := "B"
-
- OTHERWISE
- _dcStore( xItem, @cArray )
-
- ENDCASE
-
- RETURN cRetVal
-
-
- // ----------------- //
-
- STATIC FUNCTION _str2ar ( cString )
-
- LOCAL nPosition := 1, cArray := cString
- IF SubStr(cArray,1,14)==CHR(1)+'Array String:'
- cArray := SubStr(cString,15)
- ENDIF
- RETURN _dcGet( @nPosition, @cArray )
-
- // ----------------- //
-
- STATIC FUNCTION _dcGet ( nPosition, cArray ) // get the next thing
-
- LOCAL nLength, i, cAttrib, cRetVal
-
- // get cAttrib
- cAttrib := substr( cArray, nPosition++, 1 )
-
- DO CASE
-
- CASE cAttrib $ 'CNADF'
- nLength := bin2l( substr( cArray, nPosition, 4 ) )
- nPosition += 4
-
- DO CASE
-
- CASE cAttrib == "C"
- cRetVal := substr( cArray, nPosition, nLength )
- nPosition += nLength
-
- CASE cAttrib == "F"
- cRetVal := VAL(substr( cArray, nPosition, nLength ))
- nPosition += nLength
-
- CASE cAttrib == "N"
- cRetVal := nLength
-
- CASE cAttrib == "A"
- cRetVal := array( nLength )
- FOR i = 1 TO nLength
- cRetVal[i] := _dcget( @nPosition, @cArray )
- NEXT i
-
- CASE cAttrib == "D"
- cRetVal := ctod("01/01/70")+nLength
-
- ENDCASE
-
- CASE cAttrib = 'M'
- nLength := dc_dec2l( substr( cArray, nPosition, 12 ))
- nPosition += 12
- cRetVal := substr( cArray, nPosition, nLength )
- nPosition += nLength
-
- CASE cAttrib = 'W'
- nLength := dc_dec2l( substr( cArray, nPosition, 12 ))
- nPosition += 12
- cRetVal := nLength
-
- CASE cAttrib == "O"
- nLength := dc_dec2l( substr( cArray, nPosition, 12 ))
- nPosition += 12
- cRetVal := array( nLength )
- FOR i = 1 TO nLength
- cRetVal[i] := _dcget( @nPosition, @cArray )
- NEXT i
-
- CASE cAttrib = 'L'
- cRetVal := if( substr( cArray, nPosition++, 1 ) == "T", .t., .f. )
-
- CASE cAttrib $ 'UB'
- cRetVal := nil
-
- OTHERWISE
-
- ENDCASE
-
- RETURN cRetVal
-
- /* ------------------- */
-
- STATIC FUNCTION dc_dec2l ( cNum )
-
- RETURN VAL(Substr(cNum,1,3))*1 + ;
- VAL(Substr(cNum,4,3))*256 + ;
- VAL(Substr(cNum,7,3))*65536 + ;
- VAL(Substr(cNum,10,3))*65536*65536
-
- /* ------------------- */
-
- STATIC FUNCTION dc_l2dec ( nNum )
-
- LOCAL cVal := l2bin( nNum )
- RETURN STRTRAN(STR(ASC(SubStr(cVal,1,1)),3) + ;
- STR(ASC(SubStr(cVal,2,1)),3) + ;
- STR(ASC(SubStr(cVal,3,1)),3) + ;
- STR(ASC(SubStr(cVal,4,1)),3),' ','0')
-
- /* ---------------------- */
-
- FUNCTION XClip60( aData, nHandle )
-
- LOCAL cDefault, cDatabase, cIndex, cRdd, dDate, cAreaCode, ;
- nRecords := 0, cPath, nEvery
-
- cDefault := aData[1]
- cPath := aData[2]
- cDatabase := aData[3]
- cIndex := aData[4]
- cRdd := aData[5]
- dDate := aData[6]
- cAreaCode := aData[7]
- nEvery := aData[8]
-
- SET DEFAULT TO (cDefault)
- SET PATH TO (cPath)
- USE (cDatabase) SHARED VIA cRdd
-
- GO TOP
- DO WHILE !Eof()
- IF _FIELD->areacode == cAreaCode
- IF _RecLock(5)
- REPL _FIELD->date WITH DTOC(dDate)
- nRecords++
- COMMIT
- UNLOCK
- ENDIF
- ENDIF
- DC_XCUpdate( RecNo(), RecCount(), nEvery )
- SKIP
- ENDDO
- CLOSE
-
- DC_XCReturn( { nRecords } )
-
- RETURN nil
-
-