Community of VE/MapPoint Users and Developers
This is a discussion on problem while read NMEA.txt file within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Hello, Thank you very much for you peoples efforts in mine previous work. Please let me know about the NMEA ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| problem while read NMEA.txt file Thank you very much for you peoples efforts in mine previous work. Please let me know about the NMEA Simulator which I am working on nowadays. I want to develop a simulator which will get data from NMEA.txt file and will show on screen. Mine code is extracting data which I placed in timer and I am facing two problems . 1. when I use this Code: str = sr.ReadToEnd(); 2. When I use this Code: str = sr.ReadLine(); All i want to keep on updating continuously mine txt file data which I will use to mine application. Code:
private void timer1_Tick(object sender, EventArgs e)
{
try
{
FileStream gul = new FileStream("C:/GPS.txt.txt", FileMode.Open, FileAccess.Read, FileShare.Read);
StreamReader nasir = new StreamReader(gul);
string str = nasir.ReadLine();
//str = nasir.ReadLine();
while (str != null)
{
txtResults.Text = str;
str = nasir.ReadLine();
//str = nasir.ReadToEnd();
}
}
Hope to hear from u guys.
Regards.
nasir |
| |||
| Re: problem while read NMEA.txt file
Hi, Your code example read the file line by line by ReadLine() until the end of file is reached. since you do it in a timer event the next time the same file is completely read, so if it is updated then you also have updated information. Do I understeand you question well? If not please rephrase.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| Re: problem while read NMEA.txt file
Hi, Thanks for yours reply.Well when I use it in public Form1() Code: str = nasir.ReadLine(); Code: txtResults.Text = str; Please let me know how to do it. regards. nasir |
| |||
| Re: problem while read NMEA.txt file
Hi, I understand what you wants to do now. But there can be a problem. ReadLine() will work, but if another program updates the file it is possible that ReadLine() will forever will return null. Not sure of it, but this can be an untested situation and may change. You can however close the file, and after a timer expires open it again and read it complete. But file will always get bigger and bigger so your program will slow down in time. Also you have to count the lines to see if a new line is appended. There is also another problem. If you read the last line in the middle where the other program is updating it then you possible have only part of the line. Question: is the program that write to the file also from you as author or do you have the source ? Because then easy synchronization can be done. but let me know first.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| Re: problem while read NMEA.txt file
Hello, many thanks for yours reply. Well I got control on it. what I did as in public Code: protected FileInfo theSourceFile = null; protected StreamReader reader = null; protected string text = " "; // assigned to allow first line to be read below Code: private void timer1_Tick(object sender, EventArgs e)
{
if (text != null)
{
text = reader.ReadLine();
//Console.WriteLine(text);
txtResults.Text = text;
} Well yours question I am not going to write any file just using text file and mine software will act as simulator which keep on reading from the file to get GPGGA data and extract Lat & Lon and show it on map or you can say act as dummy don t need of any hardware. Now I will try to extract GPGGA data from the updating file and get link with map. Nasir |
| |||
| Re: problem while read NMEA.txt file
Hello, Please let me know how to read text file again, if mine present text file ends up. As for looping the reading of file I tried else, in timer but it is not restarting mine text file again. How can I get it to read the text file in a continuous loop instead of just ending at the end of the text file? Hope to hear from u guys. Regards. nasir |
| |||
| Re: problem while read NMEA.txt file
Hello, Any body have an experience of using text file as I am able to read it line by line properly in timer but i need to read it again after it has finished. I use if & else. When mine file has finished it goes to else but I don't know how I can read it back. Regards.Nasir |
| |||
| Re: problem while read NMEA.txt file
Hi, Use ReadLine() to read again. You don't tell us what the problem is.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| Re: problem while read NMEA.txt file
Hi, Thanks. When I use readline(); in timer it keeps on showing me text file line by line by using Code: protected string text = " "; // assigned to allow first line to be read below Code: An unhandled exception of type 'System.NullReferenceException' occurred in NMEA.exe Additional information: Object reference not set to an instance of an object. I want mine file to start again after it ends up. Regards. Nasir |
| |||
| Re: problem while read NMEA.txt file
Hi, ReadLine() returns null at end of file. You have to check for null pointers like this: Code: if (text != null) // do something with text
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
| ||||
| Posted By | For | Type | Date | |
| Programming MapPoint in .NET - MP2K Magazine | This thread | Refback | 04-30-2008 03:16 PM | |
| The Magazine for MapPoint - MP2K Magazine | This thread | Refback | 04-26-2008 05:03 PM | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem to open Excel file | Chiara | MapPoint 2006/2009 Discussion | 2 | 07-19-2006 06:54 AM |
| NMEA Standard | Anonymous | MapPoint 2006/2009 Discussion | 2 | 06-17-2004 01:54 PM |
| Correctly Mapping NMEA Data | Anonymous | MapPoint 2006/2009 Discussion | 1 | 03-18-2004 01:28 PM |
| nmea sentence | Anonymous | MapPoint 2006/2009 Discussion | 0 | 03-09-2004 06:36 AM |
| Import NMEA-data from a file into mappoint | Anonymous | MapPoint 2006/2009 Discussion | 2 | 11-19-2003 12:17 PM |
Ski Holidays French Alps
Ski holidays in the French Alps are a unique and exciting experience. There are a great range of resorts which are great value when you book with Holiday Hypermarket online.
Cruise Travel Agent
Book your cruise with Travel Counsellors. We are an award winning travel agent and can help plan your perfect cruise.
Jamaica Holiday
Fancy a Jamaica Holiday? Then visit dealchecker.co.uk and find out what the big deal is. Book a bargain when you book online.
Holidays to St Lucia
Holidays to St Lucia will leave you smiling. The spectacular scenery and the warmth of the locals make holidays to St Lucia unforgettable.
Tunisia
Tunisia enjoys excellent weather, golden beaches and a beautiful blue sea. Moving away from the beach you will find a country that has a rich and varied past. Discover the secrets of history yourself by exploring all the ruins.
Bargain Holidays
To plan your holidays at bargain prices, use Travel.co.uk to explore all the possibilities.
Portugal Holidays
We specialise in Portugal holidays. Visit our On The Beach website for more information.