PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN

fCompress (Example)
WINDEVReports and QueriesUser code (UMC) Compressing a file (WINDEV)
The following code is used to compress a file. The file to compress and the compressed file are selected by fSelect. A progress indicates the compression percentage. This progress bar will be displayed in the status bar.
// -- Click code on BTN_CompressFile
 
// Initialization code
EventNum is int
FileToCompress is string
CompressedFile is string
ResCompression is int
 
// Select the file to compress
FileToCompress = fSelect("", "", "Select the file to compress", ...
"All files (*.*)" + TAB + "*.*", "", fselOpen + fselExist)
 
// Select the compressed file
CompressedFile = fSelect("", "", "Select the compressed file", ...
"All files (*.*)" + TAB + "*.*", "", fselCreate)
 
// Call the event to display the progress bar
EventNum = Event("Dis_Compress_ProgressBar", WinInput(), compressProgressBar)
 
// Compress the file
ResCompression = fCompress(FileToCompress, CompressedFile)
 
// End of event
EndEvent(EventNum)
 
// Display an error message if the compression failed
IF ResCompression <> 0 THEN
Error(ErrorInfo(errMessage))
ELSE
  Info("The compression was performed")
END
// Local procedure Dis_Compress_ProgressBar
PROCEDURE Dis_Compress_ProgressBar(wMessage, wParam, lParam)
IF wParam < 100 THEN
ProgressBar(wParam, 100)
  // Refresh the window
  Multitask(-1)
ELSE
  // The compression is over
  ProgressBar()
END
WEBDEV - Server codeAjax Compressing a file (WEBDEV)
The following code is used to compress a file.
// -- Click code on BTN_CompressFile
// Initialization code
EventNum is int
FileToCompress is string
CompressedFile is string
ResCompression is int

// Select the file to compress
FileToCompress = "C:\MyDir\Account.doc"

// Select the compressed file
CompressedFile = "C:\MyDir\Account.do_"

// Compress the file
ResCompression = fCompress(FileToCompress, CompressedFile)

// Display an error message if the compression failed
IF ResCompression <> 0 THEN
Error(ErrorInfo(errMessage))
ELSE
Info("The compression was performed")
END
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment