code

VFP implementation of GetZipComment and GetZipFilesList for ZIP acrchives

VFP class below allows retrieval of a ZIP file comment or a list/count of files in the ZIP archive. It uses VFP low level file functions (LLFF) to directly read the ZIP file.

Generate GUID

UDF below generates 128-bit GUID and returns it as a string in the format 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.

MSDN:

$SAMPLECODE$

FUNCTION GenerateGUID
LOCAL lcGUID, lcStrucGUID, lnSize
lcStrucGUID = SPACE (16)
lcGUID = SPACE (78)
lnSize = LEN(lcGUID)/2

Creating directory preserving name case

MSDN:

$SAMPLECODE$

Counting lines in an ASCII file

There is more than one way to count lines in an ASCII file.

$SAMPLECODE$


* #1
CREATE CURSOR test (C(1))
APPEND FROM (lcAsciiFileName) TYPE SDF
lnRecCount = _TALLY
USE IN temp

* # 2. The line length cannot exceed 8192 bytes. Would return 1 for empty file
lnRecCount = 0
lnFH = FOPEN(lcAsciiFileName)
DO WHILE NOT FEOF(lnFH)
= FGET(lnFH, 8192)
lnRecCount = lnRecCount + 1
ENDDO

How to check if variable is Integer

FoxPro doesn't provide a direct way to check if variable is integer or how many digits it has after decimal point but it can be accomplished using PADL() function.

Copy PRG contents to Clipboard

In VFP 9.0 PRG contents will be copied to clipboard in RTF format as well, if there's no 'X' in the _Vfp.EditorOptions.

The code uses Editor functions from Foxtools.fll. See George Tasker's Extended Foxtools Help Download #9333 on UT for more info.

$SAMPLECODE$

#DEFINE FO_READONLY 0

File operations with Progressbar

It's based on the late Ed Rauh's code around SHFileOperation Win API and requires his Heap allocation class. It supports wild cards and shows standard Windows progress bar.

$SAMPLECODE$


* Copy file to different name
llSuccess = FileOpWithProgressbar("H:\TEMP\tord.dbf", "H:\TMP\TEST.dbf", "Copy")
* Copy with the same name
llSuccess = FileOpWithProgressbar("H:\TEMP\tord.dbf", "H:\TMP\", "Copy")
* Copy all dbf's

VFP 9.0 Report Features in Runtime

In order to deploy VFP 9.0 object-assisted report features in runtime, the REPORT*.APP files have to be distributed with your application and their location stored into _REPORT* system variables.
The error 'Variable _REPORTOUTPUT is not found' may be generated if they are not populated properly.

Windows API support class

The class below simplifies use of Windows API function by providing methods to convert data between VFP types and Windows API types/structures

Most of the code was borrowed from Heap allocation class (clsheap) by late Ed Rauh.

$SAMPLECODE$

DEFINE CLASS WinApiSupport AS Custom

* Converts VFP number to the Long integer
FUNCTION Num2Long(tnNum)
LOCAL lcStringl
lcString = SPACE(4)

Pages

Subscribe to RSS - code
_REPORT* system variables
File System Variable Notes