I am sending a report to a .txt file. After the program creates thie file I want to open this .txt file so the users can see the report generated. Any Ideas? Thanks in advance.
Or, maybe I didn't. You can open the file using MODIFY COMMAND, or rather, MODIFY FILE. The NOEDIT option is up to you but the user can then select File->Save As and save it wherever they want after looking at it.
The best way I have found to do this is with the ShellExecute. It is simple to use and will open the text file in whatever program is set in the file association for .txt. Or whatever file type you give it.
I have used this quite a bit and it works great. It may look a little long and drawn out but is actually fairly simple. I usually will try to indicate the original author for this kind of thing but have had this for quite some time and don't remember where I got it exactly. May have been a combination of several places. You can do your error checking on lcCallStat if needed.
_____________________________________________
Procedure execpgm
* WinApi :: ShellExecute
** Function: Opens a file in the application that it's
** associated with.
** Pass: tcFileName - Name of the file to open
** tcWorkdir - Directory where the file is located
** tcOperation - what do you want done with the file? ('Open'
** is usually all you need.)
**
** Return: -1 - You Didn't send me a file name
** 2 - Bad Association (e.g., invalid URL)
** 31 - No application association
** 29 - Failure to load application
** 30 - Application is busy
**
** Values over 32 indicate success
** and return an instance handle for
** the application started (the browser)
** There is no error handling in this Code. This is left to the
** individual programmers.
IF EMPTY(tcFileName)
RETURN -1
ENDIF
lcFileName=ALLTRIM(tcFileName)
lcWorkDir=IIF(TYPE("tcWorkDir"="C",ALLTRIM(tcWorkDir),""
lcOperation=IIF(TYPE("tcOperation"="C" AND NOT EMPTY(tcOperation),ALLTRIM(tcOperation),"Open"
*-* HINSTANCE ShellExecute(hwnd, lpszOp, lpszFile, lpszParams, lpszDir, wShowCmd)
*-*
*-* HWND hwnd - handle of parent window
*-* LPCTSTR lpszOp - address of string for operation to perform
*-* LPCTSTR lpszFile - address of string for filename
*-* LPTSTR lpszParams - address of string for executable-file parameters
*-* LPCTSTR lpszDir - address of string for default directory
*-* INT wShowCmd - whether file is shown when opened
DECLARE INTEGER ShellExecute ;
IN SHELL32.DLL ;
INTEGER nWinHandle,;
STRING cOperation,;
STRING cFileName,;
STRING cParameters,;
STRING cDirectory,;
INTEGER nShowWindow
lcCallStat = ShellExecute(0,lcOperation,lcFilename,"",lcWorkDir,1)
Look at the bottom of the post for the person you want to give a star. Click on the link that says "Click here to mark this post as a helpful or expert post!" )
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.