Backup & Restore Dbf Files

You can share your experience with HMG. Share with some screenshots/project details so that others will also be benefited.

Moderator: Rathinagiri

User avatar
sudip
Posts: 1446
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India
Has thanked: 5 times
Been thanked: 1 time

Backup & Restore Dbf Files

Post by sudip » Fri May 15, 2009 1:45 pm

Hi All,

I was experimenting how to zip and unzip files with HMG.

I found that existing COMPRESS and UNCOMPRESS don't fulfill what I want.

So, I "learned" to use low level hb_ commands. Moreover I used the GetSaveFileName() and
GetOpenFileName() functions (Win32 functions if I am not wrong) here.

(Thank you Rathi. I got the "courage" from you to use low level functions.)
BackRest.jpg
BackRest.jpg (16.95 KiB) Viewed 5725 times
Please downlowd
BackRest.zip
(3.57 KiB) Downloaded 643 times
. Compile and run.

And please tell me how to upgrade this project.

It is very useful for learning HMG.

With best regards.

Sudip
With best regards,
Sudip

User avatar
esgici
Posts: 4514
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 389 times
Been thanked: 111 times
Contact:

Post by esgici » Fri May 15, 2009 2:18 pm

Hi Sudip
sudip wrote:Please download, Compile and run.
Done, but unfortunately :
...\Sudip\BackRest\MAIN.o:MAIN.c:(.data+0x1c8): undefined reference to `HB_FUN_HB_ZIPFILE'
...\Sudip\BackRest\MAIN.o:MAIN.c:(.data+0x1d8): undefined reference to `HB_FUN_HB_GETFILESINZIP'
...\Sudip\BackRest\MAIN.o:MAIN.c:(.data+0x1e8): undefined reference to `HB_FUN_HB_UNZIPFILE'
mingw32-make.exe: *** [...\Sudip\BackRest\MAIN.exe] Error 1
Finished With Errors.
What I missed ?

BTW, why you don't use CompressFiles(), UncompressFiles() functions or COMPRESS, UNCOMPRESS commands of HMG?


Regards

--

Esgici
Viva INTERNATIONAL HMG :D

User avatar
Vanguarda
Posts: 543
Joined: Wed Feb 11, 2009 10:56 am
Location: Americana - SP
Been thanked: 1 time
Contact:

Post by Vanguarda » Fri May 15, 2009 2:23 pm

Hi friends,

...\Sudip\BackRest\MAIN.o:MAIN.c:(.data+0x1c8): undefined reference to `HB_FUN_HB_ZIPFILE'
...\Sudip\BackRest\MAIN.o:MAIN.c:(.data+0x1d8): undefined reference to `HB_FUN_HB_GETFILESINZIP'
...\Sudip\BackRest\MAIN.o:MAIN.c:(.data+0x1e8): undefined reference to `HB_FUN_HB_UNZIPFILE'
mingw32-make.exe: *** [...\Sudip\BackRest\MAIN.exe] Error 1
Finished With Errors.

It occurs whit me too.

Regards,
--
Paulo Sérgio Durço (Vanguarda)


http://hmglights.wordpress.com/

User avatar
sudip
Posts: 1446
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India
Has thanked: 5 times
Been thanked: 1 time

Post by sudip » Fri May 15, 2009 2:33 pm

Hello,

Please run HMG IDE. Then go to Tools -> Preferences. Then in the External Libraries text box, please type

Code: Select all

hbziparc;hbmzip;hbzlib
I hope this will solve the problem.

With best regards.

Sudip
With best regards,
Sudip

User avatar
Rathinagiri
Posts: 5263
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 169 times
Been thanked: 172 times
Contact:

Post by Rathinagiri » Fri May 15, 2009 2:34 pm

Something is missed out here, I think.

I am using compressfiles() & uncompressfiles()
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
sudip
Posts: 1446
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India
Has thanked: 5 times
Been thanked: 1 time

Post by sudip » Fri May 15, 2009 2:38 pm

Hi Esgici,

Thank you for testing :)
esgici wrote: BTW, why you don't use CompressFiles(), UncompressFiles() functions or COMPRESS, UNCOMPRESS commands of HMG?
I tried those commands. But I can't found how to unzip into a SPECIFIC FOLDER. So, I HAD TO USE low level functions of harbour libraries. If there is an EASIER way to do it with UNCOMPRESS command, please inform me (as you know, I am in a very basic learner of HMG)

With best regards.

Sudip
With best regards,
Sudip

User avatar
sudip
Posts: 1446
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India
Has thanked: 5 times
Been thanked: 1 time

Post by sudip » Fri May 15, 2009 2:40 pm

Hi Rathi,
rathinagiri wrote:Something is missed out here, I think.

I am using compressfiles() & uncompressfiles()
Yes, 3 libraries (may be 1 is sufficient. But I have to test it)

With best regards.

Sudip
With best regards,
Sudip

User avatar
Vanguarda
Posts: 543
Joined: Wed Feb 11, 2009 10:56 am
Location: Americana - SP
Been thanked: 1 time
Contact:

Post by Vanguarda » Fri May 15, 2009 2:42 pm

Hi friend Sudip,

It working fine.

Very good you code.
you learn very good, the low level. Good luck with your tests

i know that this is only a example of low level. but for compress and make a backup, i agree with Esgici:

"BTW, why you don't use CompressFiles(), UncompressFiles() functions or COMPRESS, UNCOMPRESS commands of HMG?"

When you get a another code post for us, guy. Please go ahead with their functions and codes on the low level.
This was very good. Congratulations.



PS: Sorry my bad english
--
Paulo Sérgio Durço (Vanguarda)


http://hmglights.wordpress.com/

User avatar
sudip
Posts: 1446
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India
Has thanked: 5 times
Been thanked: 1 time

Post by sudip » Fri May 15, 2009 2:45 pm

Hi All,

I got following documentation for HB_UNZIPFILE function.

Code: Select all

HB_UNZIPFILE()

Unzip a compressed file

Syntax

    HB_UNZIPFILE( <cFile>, <bBlock>, <lWithPath>, <cPassWord>, <cPath>, 
    <cFile> | <aFile>, <pFileProgress> ) ---> lCompress 

Arguments

    <cFile> Name of the zip file to extract

    <bBlock> Code block to execute while extracting

    <lWithPath> Toggle to create directory if needed

    <cPassWord> Password to use to extract files

    <cPath> Path to extract the files to - mandatory

    <cFile> | <aFiles> A File or Array of files to extract - mandatory

    <pFileProgress> Code block for File Progress

Returns

    <lCompress> .t. if all file was successfully restored, otherwise .f.

Description

    This function restores all files contained inside the <cFile>. If the extension is omitted, .ZIP will be assumed. If a file already exists, it will be overwritten.

    If <bBlock> is used, every time the file is opened to compress it will evaluate bBlock. Parameters of bBlock are cFile and nPos.

    The <cPath> is a mandatory parameter. Set to ".\" to extract to the current directory

    If <cFile> or <aFiles> are not provided, no files will be extracted! Make sure you provide the file or files you want extracted

    If <pFileProgress> is used, an Code block is evaluated, showing the total of that file has being processed. The codeblock must be defined as follow {|nPos,nTotal| GaugeUpdate(aGauge1,(nPos/nTotal))}

Examples

      FUNCTION MAIN()

      aExtract := hb_GetFilesInZip( "TEST.ZIP" )  // extract all files in zip
      IF HB_UNZIPFILE( "TEST.ZIP",,,, ".\", aExtract )
         qout("File was successfully extracted")
      ENDIF

      aExtract := hb_GetFilesInZip( "TEST2.ZIP" )  // extract all files in zip
      IF HB_UNZIPFILE( "TEST2.ZIP", {|cFile| qout( cFile ) },,, ".\", aExtract )
         qout("File was successfully extracted")
      ENDIF
      Return Nil

Status

    Ready

Compliance

    This function is a Harbour extension

Platforms

    All

Files

    Library is hbzip.lib 
I think this function has more options than CompressFiles() function.

Please send your comments. It is essential for my journey in HMG.

With best regards.

Sudip
With best regards,
Sudip

User avatar
Rathinagiri
Posts: 5263
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 169 times
Been thanked: 172 times
Contact:

Post by Rathinagiri » Fri May 15, 2009 2:50 pm

Thanks Sudip. My way of doing.

Code: Select all

zipname := "x.zip"
fnames := array(adir("c:\folder\*.*"))
adir("c:\folder\*.*",fnames)
compressfilesarr := {}
for i := 1 to len(fnames)
   aadd(compressfilesarr,"c:\folder\"+alltrim(fnames[i]))
next i
Then we can use compress files command.

Regarding recursive sub-directories, we have to work more. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

Post Reply