
wwUtils is actually a UDF function library, not a class. This class provides lots of utility functions frequently used in the Web Connection framework and in typical applications. I use this library in every app I build.
Note this is a function library rather than a class, so there's no object to create first. Just SET PROCEDURE and call the functions.
Class Members
Member | Description | |
---|---|---|
![]() |
AParseString |
Parses a delimited string into an array by passing a delimiter to be used to split the string. AParseString(@laResult, lcString, lcDelimiter) |
![]() |
AppendToFile |
Appends a raw string to the end of a file. The string is written as is without a linefeed. This function uses low level file functions to attempt to write to the output file. The operation is very efficient. If you want to use this for logging look at LogString() instead. o.AppendToFile(lcOutput,lcFileName) |
![]() |
ArrayToCollection |
o.ArrayToCollection(@laArray,lnMode) |
![]() |
CacheFile |
This method works like FILETOSTR() or FILE2VAR() to return the content of a file. The first time the file is read it's read from disk and then cached in a cursor. Subsequent requests for the same file (based on path + filename) retrieve the file from the cursor rather than from disk. CacheFile(lcFileName,lnRefreshSeconds) |
![]() |
CharToBin |
Converts a DWORD value in binary string form back into a numeric value. CharToBin(tcWord) |
![]() |
CollectionToArray |
Converts a collection to an array.
o.CollectionToArray(@laItems, loCollection) |
![]() |
CollectionToCursor |
CollectionToCursor(loCollection, lcAlias, lcSearchExpression) |
![]() |
ContentTypeFromExtension |
Returns a content type for a given extension. For example, PDF returns applications/pdf, DOC returns application/ms-word etc. ContentTypeFromExtension(lcExtension) |
![]() |
CopyObject |
CopyObject(loInput) |
![]() |
CopyObjectProperties |
CopyObjectProperties(loSource,loTarget, lnObjectStructureObject, llDontParseObjects, lcPropertyExclusionList) |
![]() |
CopyTree |
Copies a directory tree including subdirectories from one location to another. o.CopyTree(lcSourceFilePath, lcTargetPath) |
![]() |
CursorToCollection |
Easily creates a Collection from a FoxPro cursor. Creates either a FoxPro Collection or a wwCollection instance. CursorToCollection(lcAlias,lnMode) |
![]() |
CursorToObjectArray |
Creates an array of objects of the currently open cursor. The result is an object that has two properties the count and the array of objects that contain the records. The object has properties for each field value (except general fields) CursorToObjectArray() |
![]() |
DCOMCnfgServer |
Configures security rights for a Local Server (EXE server) COM object. Provides similar functionality that DCOMCNFG provides for setting the Impersonation Level of a component. Be sure to also set the DCOMLaunchPermissions. o.DCOMCnfgServer(lcProgId, lcRunAs, lcPassword) |
![]() |
DCOMLaunchPermissions |
Sets the Launch and Access permissions of a DCOM server. o.DCOMLaunchPermissions(lcProgid,lcusername) |
![]() |
DecodeHtml |
Decodes an Html encoded string removing basic HTML entities. o.DecodeHtml(lcEncodedHtml) |
![]() |
DeleteFiles |
Deletes files given a wildcard path spec (ie. o.DeleteFiles(lcFileSpec, lnTimeout) |
![]() |
DeleteTree |
Deletes files based on a path and file spec, recursively down the folder hiearchy. Optionally also allows removal of empty folders effectively deleting entire folder hiearchy. o.wwUtils.DeleteTree(lcSourcePath, lcFileSpec, llDontRemoveEmptyFolders) |
![]() |
DetokenizeString |
Detokenizes a string tokenized with TokenizeString() by replacing embedded token placeholders with token strings stored in a collection. o.DetokenizeString(lcString,loTokens,lcDelimiter) |
![]() |
DisplayMemo |
This method formats a memo field for minimal HTML presentation by simply converting multiple linebreaks to o.DisplayMemo(lcText) |
![]() |
EncodeHtml |
This method fixes up HTML for display. Takes HTML and XML tags and converts them to HTML displayable characters (< for < for example). o.EncodeHtml(lcHTML) |
![]() |
EndsWith |
Checks to see if a given string ends with a given substring. EndsWith(lcSourceString,lcCompare,llCaseInsensitive) |
![]() |
ExecuteCommandLine |
o.ExecuteCommandLine(lcCommandLine, lcFolder) |
![]() |
Extract |
o.Extract(lcString,lcStartDelim,lcEndDelim1, lcEndDelim2, llEndOk, llIncludeDelims) |
![]() |
File2Var |
o.File2Var(tcFileName, tcString, tlSharedWriteMode, tlWriteAsUtf8) |
![]() |
FileAttributes |
Returns the file attributes of a given file. The list of attributes is returned as a single string that contains all the attributes that apply. For example to check for Read Only flag you might do:
o.FileAttributes(lcFilename) |
![]() |
FileSize |
Returns the size of a file on disk. FileSize(lcFileName) |
![]() |
FileTime |
Returns the file's last udpate DateTime value. FileTime(lcFileName) |
![]() |
FixComErrorMessage |
o.FixComErrorMessage(lcErrorMsg) |
![]() |
FixPreTags |
Fixes <PRE></PRE> blocks in HTML pages so that they display properly and can be cut and pasted as code. Replaces <p> and <br> tags with real carriage returns. o.FixPreTags(lcHTML) |
![]() |
FlattenSql |
o.wwUtils.FlattenSql(lcSql) |
![]() |
ForceTableRefresh |
Refreshes a table's read buffers, by explicitly moving the record pointer. This causes VFP to re-read buffers from disk, to ensure data is not coming from the data refresh cache in VFP. o.ForceTableRefresh(lcAlias) |
![]() |
FormatString |
Uses the .NET o.FormatString(lcFormat,lvVal1...lvVal10) |
![]() |
FormatValue |
o.FormatDate(ltDate,lcFormatString) |
![]() |
FromIsoDateString |
Converts a date in ISO 8601 format to a FoxPro date or time (if time values are specified). Input date format is 2012-10-08 which is used in HTML5 input type=date controls. o.FromIsoDateString(lcDate) |
![]() |
GetAppStartPath |
Returns the FoxPro start path of the *APPLICATION* under all startmodes supported by VFP. o.GetAppStartPath() |
![]() |
GetAttribute |
Retrieves the content of an attribute in an XML or HTML element.
o.GetAttribute(lcElementXml,lcAttribute) |
![]() |
GetDirectoryName |
Returns just the path portion of a given file. Unlike GetDirectoryName(lcFilePath) |
![]() |
GetFilename |
Returns just the file name of a path. Unlike GetFilename(lcFilePath) |
![]() |
GetFullPath |
GetFullPath(lcFile) |
![]() |
GetPassword |
Pops up a VFP Form Inputbox asking for a password. The password is hidden with a password mask. o.GetPassword() |
![]() |
GetRegExObject |
Creates an instance of the VBScript.RegExp object and caches this instance in a PUBLIC variable reference. If already loaded the existing instance is returned. GetRegExObject() |
![]() |
GetRelativePath |
Returns a relative path ( Similar to o.GetRelativePath(lcFolder,lcBasePath) |
![]() |
GetUniqueId |
Creates a unique ID based off of a partial GUID string. Result string can be between 15 and 32 characters with 32 characters representing an entire GUID (guaranteed unique across all devices). o.GetUniqueId(lnSize) |
![]() |
GetURLEncodedKey |
Retrieves a 'parameter' from a URL Encoded string such as a QueryString or POST buffer. o.GetURLEncodedKey(tcURLString, lcKey) |
![]() |
GetUrlEncodedValues |
Returns a wwNameValueCollection of all keys and values contained in a UrlEncoded string of key values. o.GetUrlEncodedValues(lcVars,lcPrefix) |
![]() |
GetWords |
Takes an input string and breaks it out into a collection of words separated by spaces or line breaks. o.GetWords(lcText) |
![]() |
GoUrl |
ShellExecute wrapper that starts any associated program or URL. You can launch URLs, mailto: links, as well as any file like .txt, doc,.ini etc. If an association exists GoUrl() will launch the associated application with the specified document. o.GoUrl(tcUrl, tcAction) |
![]() |
GravatarLink |
Creates a Gravatar link based on an email address. o.GravatarLink(lcEmail,lnSize,lcDefaultUrl,lcRating) |
![]() |
Href |
Creates an HTML anchor tag like o.wwUtils.Href(lcLink, lcText, lcAttributes) |
![]() |
HTMLColor |
Converts an RGB color value to an HTML color value. o.HTMLColor(lnRGBColor) |
![]() |
HumanizedDate |
Displays a date in colloquial English text like o.HumanizedDate(ltDate) |
![]() |
InputForm |
Creates a simple VFP form input box. o.InputForm(lcValue,lcMessage,lcCaption,lnFormWidth, lnFieldWidth,lcFormat,lcCancelValue) |
![]() |
IsAdmin |
Determines if the current user is running in a Windows Administrative context. o.wwUtils.IsAdmin() |
![]() |
IsCOMObject |
Checks to see if a COM object exists in the registry. o.IsCOMObject(lcProgId, @lcClassId, @lcClassDescript) |
![]() |
IsDir |
Checks to see if a directory exists. Unlike Directory() this method works on Windows 2000. o.IsDir(lcPath) |
![]() |
IsDotNet |
Returns whether .Net is installed. Also can return the latest installed version and directory of the .Net framework. o.IsDotNet(@lcVersion,@lcPath) |
![]() |
IsDotnetCore |
Determines if .NET Core Runtime is installed and gives the latest version that's available. o.IsDotnetCore("@lcFrameworkPath, @lcVersion) |
![]() |
IsNullOrEmpty |
Determines whether a value is NULL or empty. The empty check only checks basic types (strings, number, dates logicals), not objects or arrays. IsNullOrEmpty(lvValue) |
![]() |
IsNumber |
Determines whether the value is either a numeric number, or a text based string that only contains numbers and decimal and thousands separators. o.IsNumber(lvNumber) |
![]() |
IsWinnt |
Checks to see if app is running under Windows NT. o.IsWinnt(llReturnVersionNumber) |
![]() |
JsonBool |
o.JsonBool(llValue) |
![]() |
JsonDate |
Creates an ISO 8601 JSON compatible date string including quotes. Produces a date in the following format: "2014-12-19T04:25:33Z" JsonDate(ldDateTime, llAssumeUtcDate) |
![]() |
JsonString |
o.wwUtils.JsonString(lcString) |
![]() |
LaunchVsWebServer |
o.LaunchVsWebServer(lcPhysical,lnPort,lcVirtual,lnType) |
![]() |
LogString |
LogString(lcOutput,lcFileName) |
![]() |
LongPath |
Returns a properly upper and lower cased operating system file name from a full or relative filename or path. Returns files and paths in proper case and converts short filenames to long. LongPath(lcFileName, llCheckFileExists) |
![]() |
MailLink |
Creates an email link on a Web page that is not easily harvested by breaking up the Url. o.MailLink(lcEmail,lcText,lcSubject,lcMessage) |
![]() |
MergeText |
This function provides an evaluation engine for FoxPro expressions and code blocks in a template/script page. Default syntax format uses ASP style tags (<% %>), but can work with any set of delimiters. o.MergeText(tcString,tcDelimiter, tcDelimiter2, llNoASPSyntax) |
![]() |
MergeTextFromFile |
Like MergeText except the content is loaded from a file. o.wwUtils.MergeTextFromFile(tcFile, tlCacheTemplate, tcDelimiter,tcDelimiter2,llNoAspSyntax) |
![]() |
MimeDateTime |
Converts DateTime values to Mime strings or Mime Date strings to DateTime values. MimeDateTime(lvDateTime) |
![]() |
NoEmptyDate |
Returns a fixed date time value from an empty FoxPro date. o.NoEmptyDate(ltDateTime,ltEmptyDateValue) |
![]() |
OpenExclusive |
Opens a table exclusively if possible. o.OpenExclusive(lcTable, lcAlias) |
![]() |
OpenFileDialog |
Open file dialog that prompts for a file name. Unlike OpenFileDialog(lcFolder, lcCaption, lcTitle, lcExtensions, llCheckIfFileExists) |
![]() |
Path |
Adds or deletes items from the Visual FoxPro path string. o.Path(pcPath,pcMethod) |
![]() |
PropertyDump |
Dumps all of an objects properties to a string separated by Carriage Returns. Note Long strings will be truncated at 80 characters. o.PropertyDump(loObject) |
![]() |
RegisterDotNetComponent |
Registers a .NET Component for COM operation by calling regasm /codebase. o.RegisterDotNetComponent(lcDotNetDLL, lcProgId,@lcError) |
![]() |
RegisterOleServer |
Registers an OLE server or OCX control o.RegisterOleServer(lcServerPath, llUnRegister, llSilent) |
![]() |
RemoveUrlEncodedKey |
Removes a single key from a URL encoded string such a query string or form variable collection. o.RemoveUrlEncodedKey(lcQuery,lcKey) |
![]() |
RenderAspScript |
Allows quick rendering of an ASP style script page that contains embedded <% %> tags for FoxPro script expressions and code blocks. Runs as a full FoxPro program. o.RenderAspScript(lcTemplate,lnMode,llIsString,llUseHttpResponse) |
![]() |
ReplaceText |
This function is a combination of STREXTRACT() and STRTRAN() that allows you to search for a string between a pair of delimiters and then replace that string with another value. Replaces the text between the matches. ReplaceText(lcSource,lcStart,lcEnd,lcReplace) |
![]() |
ReplaceTextAndDelimiters |
This function is a combination of STREXTRACT() and STRTRAN() that allows you to search for a string between a pair of delimiters and then replace that string with another value. Replaces the full matched text including the delimiters. ReplaceTextAndDelimiters(lcSource,lcStart,lcEnd,lcReplace,llAll) |
![]() |
SafeCommand |
Evaluates a single FoxPro command dynamically and wraps it into a TRY/CATCH block. Uses a macro (&) operation to execute the command so anything you can do with & operation is valid with the exception of LOCAL and THIS scoped variables. o.SafeCommand(lcVfpCommand,lcErrorDisplay) |
![]() |
SafeEval |
Evaluates a FoxPro expression without blowing up by wrapping the EVALUATE() operation into an internal TRY/CATCH block. o.SafeEval(lcEvalString,lvErrorResult) |
![]() |
SanitizeHtml |
A rudimentary HTML Sanitizer that removes scriptable content from HTML. You can use this to clean up user captured HTML and rendered Markdown to avoid XSS attacks. o.wwUtils.SanitizeHtml(lcHtml,lcHtmlTagBlacklist) |
![]() |
SaveFileDialog |
Displays a Save File Dialog that can be used to prompt for files to save. Unlike SaveFileDialog(lcFolder,lcTitle, lcDefaultExt,lcExtensions, llPromptForOverwrite) |
![]() |
SetAcl |
Sets the Access Control List on a file resource by running the CACLS utility. SetAcl(lcPath,lcAccount,lcAccess,llInherit,llReplace) |
![]() |
SetUrlEncodedKey |
Adds or updates a query string value for a given key with the provided value. o.SetUrlEncodedKey(lcQuery, lcKey, lcValue) |
![]() |
ShellExecute |
o.ShellExecute(tcUrl, tcAction, tcDirectory, tcParameters) |
![]() |
ShortDate |
Creates a short date in the format of: Oct. 8 or Jun. 10. o.ShortDate(ltTime,lnMode) |
![]() |
ShortPath |
Converts a Long Windows filename into a short 8.3 compliant path/filename. Use API so this is a valid 8.3 safe file path as recorded by the Operating System. o.ShortPath(lcPath) |
![]() |
ShortTime |
Retuns a short time string that shows like 07:52am. o.ShortTime(ltTime) |
![]() |
ShowHTML |
Displays an HTML string in the browser for quick viewing. o.ShowHTML(lcHTML, lcFile, loWebBrowser) |
![]() |
ShowText |
Shows a text string and displays it in Notepad (or other configured editor) o.ShowText(lcHTML, lcFile, loWebBrowser) |
![]() |
ShowXML |
Displays an XML string in a Web browser for quick viewing. o.ShowXML(lcXML, lcFile, loWebBrowser) |
![]() |
SplitString |
o.SplitString(lcString,lnLineLen,lnFlags,lcParseChar) |
![]() |
StartsWith |
Checks to see if a base string starts with another string's characters. StartsWith(lcSourceString,lcCompare,llCaseInsensitive) |
![]() |
StringFormat |
Function that replaces a format string with placeholder values passed as parameters using C-Style Format strings. This function is useful for quick embedding of strings that is more compact and efficient than using TEXTMERGE expressions on generating short text strings. o.StringFormat |
![]() |
StripHTML |
Removes HTML tags from the passed text and converts it to plain text. Note formatting is totally removed! o.StripHTML(lcHTMLText, lcLTag, lcRTag) |
![]() |
StripUtf8Bom |
Removes a UTF-8 BOM marker from a UTF-8 encoded file. o.StripUtf8Bom(lcFile) |
![]() |
TimeToCStrict |
Creates a VFP strict date string that can be used in literal SQL strings. Simplifies creating dynamic SQL statements that are date safe. Optional pass the llSQL flag as .T. to have a SQL Server compatible date string returned. o.TimeToCStrict(ltTime, llSQL) |
![]() |
ToIsoDateString |
Converts a FoxPro date or date time or string value to ISO 8601 format: 2012-10-08 or 2014-10-01T16:55:12Z. Dates can be created with or without UTC time offsets. This function is useful for converting dates to the format required by HTML5 input type=date controls which can only display dates using the standard ISO formatting. ToIsoDateString(ldDate, llIncludeTime, llNoUtc) |
![]() |
TokenizeString |
o.TokenizeString(@lcSource,lcStart,lcEnd,lcDelimiter) |
![]() |
TrimWhiteSpace |
Trims whitespace of the end of a string using a pre-set of characters that you optionally provide. By default CHR(13), CHR(10), Spaces and Tabs are cleared. o.TrimWhiteSpace(lcString,lcStripChars) |
![]() |
URLDecode |
URLDecodes a URLEncoded text string to normal text. o.URLDecode(lcText) |
![]() |
URLEncode |
Encodes a string in URL encoded format for use on URL strings or when creating a POST buffer. o.URLEncode(tcValue) |
![]() |
WrCursor |
Creates a Writable cursor from a SELECTed cursor by creating a copy with a new name. o.WrCursor(pcNewName) |
Requirements
Assembly: wwUtils.prg© West Wind Technologies, 1996-2022 • Updated: 02/02/17
Comment or report problem with topic