_ClipText = FILETOSTR(lcFile)To better understand the different results, you can run this modified sample, if you are interested:
LOCAL lcFile lcFile = GETFILE("prg") * Open the VFP Editor * MODIFY COMMAND (lcFile) NOWAIT NOEDIT #DEFINE FO_READONLY 0 LOCAL ARRAY laEnv [25] LOCAL lnHandle, lnResult SET LIBRARY TO LOCFILE("FoxTools.fll") ADDITIVE * Open the VFP Editor lnHandle = _EdOpenFil(lcFile, FO_READONLY) lnResult = _EdGetEnv( lnHandle, @laEnv ) * [ 2 ] File Size * Select ALL _EdSelect(lnHandle, 0, laEnv[2]) * Copy to clipboard IF NOT _EdCopy(lnHandle) MESSAGEBOX("Couldn't Copy ") RETURN .F. ENDIF = _Wclose(lnHandle) LOCAL loIE as "InternetExplorer.Application" loIE = CREATEOBJECT("InternetExplorer.Application") #DEFINE READYSTATE_COMPLETE 4 #DEFINE MAX_TIME 30 #DEFINE OLECMDID_PASTE 13 #DEFINE OLECMDEXECOPT_DODEFAULT 0 local lcInnerHTML && HTML of the webpage local lnStarted && Seconds when started loading local lnWaiting && Seconds waiting for the document to load local lcRetVal && Return Value lnStarted = SECONDS() loIE.navigate("about:blank") * Wait till page totally loaded DO WHILE loIE.Readystate <> READYSTATE_COMPLETE or lnWaiting >= MAX_TIME lnWaiting = SECONDS() - lnStarted ENDDO * Make the page editable loIE.Document.Body.contentEditable = .T. * Paste Clipboard content loIE.ExecWB(OLECMDID_PASTE, OLECMDEXECOPT_DODEFAULT) * Retrieve the HTML lcInnerHTML = loIE.Document.Body.InnerHTML * Save to HTM file LOCAL lcDestFile, lcCommand lcDestFile = FORCEEXT(lcFile, "htm") STRTOFILE(lcInnerHTML, lcDestFile) lcCommand = "RUN /N Explorer.Exe " + lcDestFile &lcCommand RETURNThen, run the original version, and compare the different outputs:
LOCAL lcFile lcFile = GETFILE("prg") * Open the VFP Editor MODIFY COMMAND (lcFile) NOWAIT NOEDIT * Select all and Copy to Clipboard * by Sergey Berezniker LOCAL ARRAY laEnv [25] LOCAL lnHandle, lnResult SET LIBRARY TO FoxTools ADDITIVE * Get the whandle for the current window lnHandle = _WonTop() lnResult = _EdGetEnv( lnHandle, @laEnv ) * [ 2 ] File Size * [ 17 ] SelStart * [ 18 ] SelEnd * Select ALL _EdSelect(lnHandle, 0, laEnv[2]-1) * Copy to clipboard IF NOT _EdCopy(lnHandle) MESSAGEBOX("Couldn't Copy ") RETURN .F. ENDIF * Close the PRG RELEASE WINDOWS (JUSTFNAME(lcFile)) = _Wclose(lnHandle) LOCAL loIE as "InternetExplorer.Application" loIE = CREATEOBJECT("InternetExplorer.Application") #DEFINE READYSTATE_COMPLETE 4 #DEFINE MAX_TIME 30 #DEFINE OLECMDID_PASTE 13 #DEFINE OLECMDEXECOPT_DODEFAULT 0 local lcInnerHTML && HTML of the webpage local lnStarted && Seconds when started loading local lnWaiting && Seconds waiting for the document to load local lcRetVal && Return Value lnStarted = SECONDS() loIE.navigate("about:blank") * Wait till page totally loaded DO WHILE loIE.Readystate <> READYSTATE_COMPLETE or lnWaiting >= MAX_TIME lnWaiting = SECONDS() - lnStarted ENDDO * Make the page editable loIE.Document.Body.contentEditable = .T. * Paste Clipboard content loIE.ExecWB(OLECMDID_PASTE, OLECMDEXECOPT_DODEFAULT) * Retrieve the HTML lcInnerHTML = loIE.Document.Body.InnerHTML * Save to HTM file LOCAL lcDestFile, lcCommand lcDestFile = FORCEEXT(lcFile, "htm") STRTOFILE(lcInnerHTML, lcDestFile) lcCommand = "RUN /N Explorer.Exe " + lcDestFile &lcCommand RETURN