Sergey's blog

Using XmlAdapter to Create and Load Nested XML

An XmlAdapter in VFP 9.0 allows to create and load nested XML.

Using Sparse Files sample

Sparse files are only supported under Windows 2000 and later and the file must be on a volume that is NTFS 5.0 or later.

String comparison in VFP

FoxPro has two distinct parts. The SQL Data Engine that handles SQL command: SELECT, INSERT, UPDATE and DELETE and the rest that handles procedural code. There are differences in string comparison between them. The SET ANSI command controls comparison in the SQL Data Engine and the SET EXACT does the same in the procedural code.

Shallow Copy of an Object

The function below returns a shallow copy of an object based on the Empty class. Such an object can be created by SCATTER NAME or CREATEOBJECT("Empty"). A shallow copy means that any properties that hold references to other objects will be copied verbatim and as a result will be pointing to the same child objects. In other words, a shallow copy occurs when an object is copied but its contained objects are not.

Setting the Backup and Restore Privileges

The backup and restore privileges are required of all backup and restore applications. These privileges can be programmatically set, and the following example can be used to set these privileges. Based on Setting the Backup and Restore Privileges

RTF Control with inline shortcut menu

The code below shows how to implement a shortcut menu in RTF control when user types '#' character into control. It uses code from Windows API support class and Pixels and Foxels.

$SAMPLECODE$

PUBLIC oform1
oForm1=NEWOBJECT("form1")
oForm1.Show
RETURN

DEFINE CLASS form1 AS form

Returning UNC Path associated with a local device

MSDN links:

$SAMPLECODE$

* Windows API
FUNCTION LocalDevice2UNC(tcLocalName)
LOCAL lcUNCBuffer, lnLength, lcLocalName, lcRemoteName
DECLARE INTEGER WNetGetConnection IN WIN32API ;
	STRING lpLocalName, STRING @ lpRemoteName, INTEGER @ lplnLength
IF TYPE('tcLocalName') <> "C" OR EMPTY(tcLocalName) 
	ERROR 11
ENDIF

Retrieving Windows system error message

The WIN API FormatMessage function (among other things) can retrieve message definition from an already-loaded module or the system's message table. The error code usually is provided by the GetLastError WIN API function.

There's more info in Calvin Hsia's blog on how GetLastError works and why it may return incorrect results in the prior to VFP 9.0 versions:

Read POP3 Mail using Winsock

Working pop3Email class is based on the code from http://fox.wikis.com/wc.dll?Wiki~GetPopEmail by William Steinford.

Pages

Subscribe to RSS - Sergey's blog