Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best Way to Show A Text File 3

Status
Not open for further replies.

bebbo

Programmer
Dec 5, 2000
621
GB
My program stores logs into a text file. I want the operator to be able to open this file and search for different things. However I do not want them able to edit the file. Whats the best way to do this???

Also it may be useful if they can print all/part of the contents.

Thanks
 
bebbo

Another way might be to use FILETOSTR() and show the result in an Edit box on a form.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
MODI FILE MyTextFile.txt NOEDIT

Should I use the above it works fine in a command line in Visual FoxPro. However should I use it in my form it does not show. I know I can create it in a window, how do I create the window though??? Or is a window a form. Sorry if this is a simple question. Also will that window allow search and print?

MODI FILE MyTextFile.txt NOEDIT IN WINDOW MyNewWindow


Thanks
 
OK, just located it, Define Window. Will this have a menu bar, if not how do I add a menu bar to it so they can search/print etc???

Thanks
 
Even if I run it in a define window it does not show on my form. However if I just write a small seperate program and run it within VF it does show.

Thanks
 

bebbo,

I would like return to the excellent advice given by mgagnon to this problem...you can use something like the following:

CREATE CURSOR crsTemp(textfile M)
INSERT INTO crsTemp(textfile) values(FILETOSTR("C:\somefile.txt"))
MODIFY MEMO textfile NOEDIT NOMENU IN SCREEN
USE IN SELECT("crsTemp")


Slighthaze = NULL
craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
Slighthaze

Hi, yes that works a treat. However in my program _screen.visible = .F. I know I could change it to = .T. Is there a way I can display the information in another screen and have a way to search for text??? Perhaps I can use some sort of menu. I'll have to look into that as I've never used menu's before.

Thanks to everyone for thier help!!!!

 
bebbo,

Yes you can display it with the characteristics of another window or in another window...my example put it into the SCREEN but you can certainly change that to suit your needs...

From the VFP Help on the optional parameters for the MODIFY MEMO command:

WINDOW WindowName1
Specifies a window whose characteristics the editing window takes on. For example, if the window is created with the FLOAT option of DEFINE WINDOW, the editing window can be moved. The window need not be active or visible, but it must be defined.
IN [WINDOW] WindowName2
Specifies a parent window in which the editing window is opened. The editing window doesn't assume the characteristics of the parent window and cannot be moved outside the parent window. If the parent window is moved, the editing window moves with it.
The parent window must first be defined with DEFINE WINDOW, and must be visible, to access the editing window.

© 2001 Microsoft Corporation. All rights reserved.


Slighthaze = NULL
craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
Chris,

I am not sure I understand your last post. I do see that you suggested to bebbo that MODIFY FILE could be used...with the NOEDIT clause and the ability to put it in a window. I can see where this may be the easiest solution to the problem. I was directly expanding on mgagnon's suggestion to use FILETOSTR() and showing bebbo how it could be used to dump the contents of the file to a table (temporary cursor in this case), and then use MODIFY MEMO to show the contents of the memo in a window. Putting the contents into a memo field of a temporary cursor, I believe, widens the options available for displaying the results as it could then be displayed inside of an editbox with its READONLY property set to true as was suggested by mgagnon. If I have failed to see something in this thread or not given credit where credit was due, I apologize.

Slighthaze = NULL
craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
slighthaze

The apologies are on me - I didn't read the line

INSERT INTO crsTemp(textfile) values(FILETOSTR("C:\somefile.txt"))

properly, before the line

MODIFY MEMO textfile NOEDIT NOMENU IN SCREEN

hence the comment.

Note to self, concentrate Chris... [smile]

FAQ184-2483 - answering getting answered.​
Chris [pc2]
 
Thanks to everyone, However it I put the dat into another window how would I create an option to enable the operator to search for data within the file?

Once again thanks to everyone!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top