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. o.AppendToFile(lcOutput,lcFileName) |
|
ArrayToCollection |
Convert a FoxPro array to a Collection. 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 |
Updates a cursor from a collection by doing GATHER NAME MEMO for each member. An optional search expression can be provided for each item to allow updating existing records. 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 |
Creates a copy of an object by creating a brand new object and copying all properties including all nested objects from scratch. CopyObject(loInput) |
|
CopyObjectProperties |
This function copies properties between two objects in a flat manner. Child objects or arrays are copied as object references and not copied. 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. c:\temp\*.tmp ) and a timeout or expiration value. This function is useful for quick clean up of temporary files created for Web display.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 < p> paragraph tags and linebreaks to < br\> breaks. This behavior is similar to Response.WriteMemo(), but doesn't require a Response object.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 |
Executes a complete operating system command line with command arguments, using ShellExecute() command line resolution, but lets you express the command as a single command line that is the same as what you'd run from the Terminal. It also executes Application Protocols, URLs, and opens documents based on non-executable extensions.o.ExecuteCommandLine(lcCommandLine, lcFolder) |
|
Extract |
Extracts a text value between two delimiters. You can specify two ending delimiters or let the end of a line be considered an ending delimiter. o.Extract(lcString,lcStartDelim,lcEndDelim1, lcEndDelim2, llEndOk, llIncludeDelims) |
|
File2Var |
Function to read and write files to and from disk. Similar to FILETOSTR() and STRTOFILE() but it has additional features useful in busy server applications and certain application scenarios.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. 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 |
Fixes up a COM Error message by stripping off the OLE Dispatch error message in the front of the string if it's present. 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 |
Flatten a SQL command that contains CHR(13) or CHR(10) characters into a single line by stripping out the CR/LF values and replacing them with a space. 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 string.Format() function to format text strings using .NET based string formatting logic. This provides sophisticated string embedding similar to TextMerge without the overhead of textmerge.o.FormatString(lcFormat,lvVal1...lvVal10) |
|
FormatValue |
Uses the .NET ToString() formatting engine to format values to string. It'll use the current locale to display the values in the correct number and date formatting formats (ie. decimal separators, date number order for mdy, etc.).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 JUSTPATH() this method preserves the casing of the path.GetDirectoryName(lcFilePath) |
|
GetFilename |
Returns just the file name of a path. Unlike JUSTFNAME() this method leaves the case of the file intact.GetFilename(lcFilePath) |
|
GetFullPath |
Resolves a relative path to a full path but also matches the proper case of the file on disk if it exists. Essentially does what FULLPATH() does, plus casing the file as it is on disk if it exists.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 (..\file.txt or SubFolder\file.txt ) from a full path relative to a given base path.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 <a href=""> as a string.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 just now , 10 minutes ago , 2 weeks ago or 3 months ago etc.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. 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 |
Returns true or false for a boolean value. Very simple but a nice way in script pages to be explicit about what the value represents.o.JsonBool(llValue) |
|
JsonDate |
Creates an ISO 8601 JSON compatible date string including quotes. JsonDate(ldDateTime, llAssumeUtcDate) |
|
JsonString |
Creates a JSON encoded string from a FoxPro string including the wrapping quotes. o.wwUtils.JsonString(lcString) |
|
LaunchVsWebServer |
Can be used to launch the Visual Studio Web Server (webserver.webdev.exe in the .NET 2.0 Framework dir) or the Web Connection Cassini Web Server for use with the Web Connection Managed module. Cassini is similar to the Visual Studio server but can be redistributed with your applications for local Web server operation. o.LaunchVsWebServer(lcPhysical,lnPort,lcVirtual,lnType) |
|
LogString |
Appends a log string to the end of a file. The line is written with a timestamp and a CRLF at the end of the line. 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 GetFile() this function returns the file name and path in proper case and uses the latest Windows dialogs.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 PUTFILE() this function returns the filename and path in proper case of the file name selected.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 |
ShellExecute() is an API wrapper around the Windows API with the same name. Using ShellExecute() you can: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 |
Splits a string on CR and LF breaks and a particular width and returns a collection. 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. ToIsoDateString(ldDate, llIncludeTime, llNoUtc) |
|
TokenizeString |
String tokenizing function that extracts and replaces tokens found by extracting value between a start and end delimiter. The extracted values are returned in a sequential collection. 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, 2024 • Updated: 05/28/24
Comment or report problem with topic