Re: HRB V/S LIB
Posted: Thu Apr 13, 2017 3:19 pm
Hello Luis, That won't change much? Now you will have to install new HRB instead of EXE?
Serge
Serge
Exclusive forum for HMG, a Free / Open Source xBase WIN32/64 Bits / GUI Development System
http://www.hmgforum.com/
if I understand you solved the problem of synchronization / update of new versionsI use a BAT file to start up my programs. In this batch file 2 programs are executed. The first program just looks in a MySQL table if a new version of the main program is avaiable. If so the old main program is renamed and a new copy is downloaded. Then the second program is started which by then maybe the latest version. Of course MySQL / libmysql.dll is required but this works perfect. From my place I upload the EXE and choose to whom it may serve.
Code: Select all
#include "hmg.ch"
FUNCTION MAIN()
/*************/
PARAMETERS xPOS
// CHECK xPOS !!
// GET xDB_HOST,xDB_USER,xDB_PW,xDB_NAME
IF SQL_Connect(xDB_HOST,xDB_USER,xDB_PW,xDB_NAME) == Nil
// CONTINUE
QUIT
ENDIF
NEW_VERSION()
SQL_Disconnect()
RETURN
FUNCTION NEW_VERSION()
/******************/
cQuery1 := " SELECT EXE_FILE "
cQuery1 += " FROM NEW_VERSION "
cQuery1 += " WHERE FILE = 'ZZZ' "
cQuery1 += " AND STATUS = 'N' "
cQuery1 += " AND POS = '" + xPOS + "' "
cSQL := cQuery1
cQuery1 := dbo:Query( cQuery1 )
IF cQuery1:NetErr()
? PROCNAME(), '010', cQuery1:Error() , cSQL
RETURN
ENDIF
NIEUW := FALSE
IF cQuery1:LastRec() == 0
RETURN
ELSE
aCurRow := cQuery1:GetRow(1)
cEXE := aCurRow:fieldGet(1)
IF EMPTY(cEXE)
RETURN
ELSE
// COPY TO ..
dDATUM = DTOC(DATE())
dDATUM = STRTRAN(dDATUM,"/","")
dDATUM = STRTRAN(dDATUM,"-","")
nVOLG = 1
DO WHILE .T.
cOLDFILE = "&XSTAT_PATH\ZZZ" + dDATUM + ALLTRIM(STR(nVOLG,3,0)) + ".EXE"
IF !FILE(cOLDFILE)
EXIT
ENDIF
nVOLG++
ENDDO
IF FRENAME("&XSTAT_PATH\ZZZ.EXE", cOLDFILE) == -1
QUIT
ENDIF
NIEUW := Buff_To_File(cEXE, "&XSTAT_PATH\ZZZ.EXE")
IF !NIEUW
? 'Kopieeren nieuwe ZZZ is fout' , 'OK'
// RESTORE PREV VERSION
IF FRENAME(cOLDFILE, "&XSTAT_PATH\ZZZ.EXE" ) == -1
QUIT
ENDIF
RETURN
ENDIF
ENDIF
ENDIF
IF NIEUW
IF FRENAME("&XSTAT_PATH\ZZZ.EXE", cOLDFILE) == -1
QUIT
ENDIF
cQuery1 := " UPDATE NEW_VERSION "
cQuery1 := " SET STATUS = 'X' "
cQuery1 += " WHERE FILE = 'ZZZ' "
cQuery1 += " AND STATUS = 'N' "
cQuery1 += " AND POS = '" + xPOS + "' "
cSQL := cQuery1
cQuery1 := dbo:Query( cQuery1 )
IF cQuery1:NetErr() // hier fout
? PROCNAME(), '013', cQuery1:Error() , cSQL
RETURN
ENDIF
ENDIF
RETURN
FUNCTION Buff_To_File(cBuff, cNEW_FILE)
/*************************************/
LOCAL fh, nLen
fh := FCREATE(cNEW_FILE,0)
IF fh > - 1
nLen := FWRITE(fh, cBuff)
FCLOSE(fh)
IF nLen == LEN(cBuff)
RETURN .T.
ELSE
RETURN .F.
ENDIF
ENDIF
RETURN .F.
Code: Select all
cEXE_File := File_To_Buff( LclFile0 )
cQuery1 := " INSERT INTO NEW_VERSION "
etc...
FUNCTION File_To_Buff(cFile)
/*******************************************************************************************************************/
local cBuff:="", fh, nLen
local lRetVal:=.f.
local cFile_in := cFile
fh := FOPEN(cFile_in,0)
IF fh > -1
// determine length of file
nLen := FSEEK(fh, 0, 2)
IF nLen > 0
//move file pointer back to begin of file
FSEEK(fh, 0, 0)
cBuff := SPACE(nLen)
FREAD(fh, @cBuff, nLen)
// escapes
cBuff := STRTRAN(cBuff, CHR(92), "\\")
cBuff := STRTRAN(cBuff, CHR(0), "\0")
cBuff := STRTRAN(cBuff, CHR(39), "\'")
cBuff := STRTRAN(cBuff, CHR(34), '\"')
ENDIF
ELSE
cBuff := "OFF"
ENDIF
FCLOSE(fh)
RETURN(cBuff)