Database development and training for Birmingham and the midlands
Specialists in Microsoft Access and Visual Foxpro database training and development
I am happy to hear from existing clients but I am taking no new calls.
Unsupported functions in the FoxTools.Fll library
Version 2.5 of FoxPro was supplied with an external library of functions in FoxTools.Fll. Many of these, functions such as JustStem() and the other functions for manipulating file names, have been promoted into the language itself but the FoxTools library still holds some odd functions that are useful in Visual FoxPro.
This is similar to the Unix touch command in that it lets you alter the timestamp of a file. This for example, will set the timestamp to 12:30 on Christmas Day:
?FOXTOUCH("test.xls", 2010, 12, 25, 12, 30, 0)
If you type this example into FoxPro you'll see that VFP Intellisense does not recognise the functions from the Fll. The text remains black and Fox gives you no help as to what parameters are expected.
The parameters here are the name of the file followed by year, month, day, hour, minute and seconds of the timestamp. The components of the time and date must be in the appropriate ranges but you can still get some odd effects. Any date earlier than Jan 1st 1601 will be rejected with an error 0 "Function argument value, type, or count is invalid." Any date between 1601 and Jan 1st 1980 will be accepted but the Adir function will give a blank date and a strange time.
This function reduces the number of spaces in a character expression can be useful in two situations.
Removing duplicate spaces
If users have been entering data on a form with a proportional font then it's difficult for them to see whether they've entered a single or double space. The Reduce function with a single parameter will replace all multiple spaces within a string with a single space. Taking the Company field from the Northwind database as an example:
Replace All company With Reduce(company)
Removing line feeds and tabs
If you have used the FileToStr function to pull text from a file into a string variable then you might want to clean that string by removing linefeeds and tabs from it. If you add the optional second parameter to the Reduce function then it will convert every occurrence of that character into a space. As a simple example:
will give "t st" as a result.
In order to clean the string you need to remove tabs, carriage returns and linefeeds and you might think that you'd have to call Reduce three times to remove Chr(9), Chr(10) and Chr(13). An unusual feature of Reduce lets us do this in a single call. If the second parameter consists of several characters - say 'xyz' - then you might expect it to look for occurences of 'xyz' in the target string. What it actually does is to process 'x' and 'y' and 'z' separately so we can remove all three control characters in a single pass:
lcFile = FileToStr("myFile.txt")
lcTemp = Reduce(lcFile, Chr(9)+Chr(10)+Chr(13))
lcClean = Reduce(lcTemp)
In this example the first pass removes all three control characters but this might leave us with multiple spaces if there were any tabs or spaces at the beginning of a line. A second call to Reduce with a single parameter cleans these up.
This is a simple function that will check whether a string might be a valid path. Despite its age it will accept paths which include spaces. These examples will be accepted as valid:
These examples will not be accepted:
The function is not foolproof but it is a quick and easy first stage of validation.
The FoxTools library is included for backwards compatibility and none of the functions are supported by Microsoft any more. You can find some help in the Help file (FoxTools.chm) but a little experimentation will usually be needed.