Just a quick utility,
I had been making menu changes for some time today (it's hard to
get back to working in vfp after a spot of time lately using c#) - just
scoping out what I though would be a logical menu structure for a small app
I am creating - it occurred to me that every time genmenux runs - it does a
poor job of formatting it's own label of the files that it is running
through - they tend to run off the form to the right (font related,
formatting related,..).
So, it seems that here is a spot for an improvement to a very, very old
utility - that is just a nice to have. Seems a small picky thing - but I
needed a break anyway <g>.
I looked around for a way to limit the characters displayed (but still have
informative information) - but didn't see any generic utilities. I wrote the
following (fnCompactPath) - which in the next day or two I will use to
adjust the display in genmenux (I will post the adjustment if folks are
interested)...
Anyway, it is generic enough to use anywhere you want to display a file
path - but in a limited number of characters or Pixels (some testing will
work out the numbers).
See the following
Cheers,
John C. Gunvaldson
San Diego, CA
ProMatrix MVP
*-- =========================================================
*-- The following is a working example for the function call to
fnCompactPath. Worked
*-- once for me <s>....
*-- =========================================================
*-- working definitions
#define CRLF chr(13)+chr(10)
#define SAMPLE_PATH "c:\path1\path2\path3\path4\path5\sample.txt"
#define MAX_PATH_PIXELS 145
*-- example call
local lcPath as String, lcResults as String
lcPath = SAMPLE_PATH
lcResults = ""
lcResults = fnCompactPath(lcPath,MAX_PATH_PIXELS)
*-- results
messagebox("The following path: " + CRLF ;
+ alltrim(SAMPLE_PATH) + CRLF + CRLF ;
+ "Trimmed to: " + transform(MAX_PATH_PIXELS) + " pixels" + CRLF ;
+ "Returns: " + alltrim(lcResults),64,"fnCompactPath Example")
*//==================================================
function fnCompactPath(tcPath as String, ;
tnPix as Integer) as String
*-- establish working substitutions
#define MAX_PATH_SIZE 1000
*-- establish working vars
local _lpbuffer as String, _lcstr as String, _lnret as Integer,
_lndx as Integer
store space(MAX_PATH_SIZE) to _lpbuffer
store 0 to _lnret, _lndx
store tcPath to _lcstr
store tnPix to _lndx
*-- declare shell lightweight utility call
DECLARE INTEGER PathCompactPath IN shlwapi;
INTEGER hdc,;
STRING @_lpbuffer,;
INTEGER dx
*-- make call
_lnret = PathCompactPath(0,@_lcstr,_lndx)
*-- format based upon location of first null inserted by call -
probably other ways to do this
_lcstr = alltrim(substr(_lcstr,1,(at(chr(0),_lcstr,1)-1)))
*-- return
return (_lcstr)
endfunc
*//==================================================