View previous topic :: View next topic |
Author |
Message |
colt1954
Joined: 21 Dec 2010 Posts: 81
|
Posted: Thu Mar 24, 2011 4:23 pm Post subject: How to undestand whar Read is complaining about |
|
|
I am trying to read a data file, some lines I need to miss out etc, the programe on execute comes back with error 52 invalid character in field with error message below. But it does not give the code line number that I recognize where its complaining, I did try the step into approach but it just comes up with similar error codes etc plus other listing that that I do not understand etc...
00401000 MAIN [+179d]
Any ideas how to better get to the bottom of such problems...if only it would tell me the line number the read error occurs, like it does when the compiler complains. |
|
Back to top |
|
|
brucebowler Guest
|
Posted: Thu Mar 24, 2011 5:48 pm Post subject: |
|
|
A semi painful/brute force way would be to write out the data after you read it. If there are multiple places you read the file, it also helps to write out some indication of which read it is. |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Fri Mar 25, 2011 12:20 am Post subject: Re: How to undestand whar Read is complaining about |
|
|
To obtain line number information upon program abort, you have to enable it by compiling and linking with /debug or other debug options. You can also set up /debug as a default option, if you wish.
Please read the documentation in the help files. |
|
Back to top |
|
|
colt1954
Joined: 21 Dec 2010 Posts: 81
|
Posted: Fri Mar 25, 2011 9:34 am Post subject: Re: |
|
|
brucebowler wrote: | A semi painful/brute force way would be to write out the data after you read it. If there are multiple places you read the file, it also helps to write out some indication of which read it is. |
Bruce I always do this, its the only way I can develop a program...trouble is its bombing out without writing out anything since it perhaps does not even reach that far. |
|
Back to top |
|
|
colt1954
Joined: 21 Dec 2010 Posts: 81
|
Posted: Fri Mar 25, 2011 9:36 am Post subject: Re: How to undestand whar Read is complaining about |
|
|
mecej4 wrote: | To obtain line number information upon program abort, you have to enable it by compiling and linking with /debug or other debug options. You can also set up /debug as a default option, if you wish.
Please read the documentation in the help files. |
If I understand you correctly I do of course compile with debug etc...it compiles and links ok hence it runs...its after that the read problems start as I tried to indicate in my first post...maybe I have misunderstood you? |
|
Back to top |
|
|
brucebowler Guest
|
Posted: Fri Mar 25, 2011 1:01 pm Post subject: Re: |
|
|
BEEFHEART wrote: | brucebowler wrote: | A semi painful/brute force way would be to write out the data after you read it. If there are multiple places you read the file, it also helps to write out some indication of which read it is. |
Bruce I always do this, its the only way I can develop a program...trouble is its bombing out without writing out anything since it perhaps does not even reach that far. |
In that case, I'd say it's bombing on the very first read. |
|
Back to top |
|
|
sparge
Joined: 11 Apr 2005 Posts: 371
|
Posted: Fri Mar 25, 2011 1:07 pm Post subject: Re: How to undestand whar Read is complaining about |
|
|
BEEFHEART wrote: | Any ideas how to better get to the bottom of such problems |
Remember there are standard keyword arguments that can be used in READ statements to assist graceful recovery from error conditions. |
|
Back to top |
|
|
JohnHorspool
Joined: 26 Sep 2005 Posts: 270 Location: Gloucestershire UK
|
Posted: Fri Mar 25, 2011 7:22 pm Post subject: |
|
|
You could try reading each line of data as character string and then do an internal read on the string, writing each string to the screen before the internal read. _________________ John Horspool
Roshaz Software Ltd.
Gloucestershire |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Sat Mar 26, 2011 10:40 am Post subject: |
|
|
Bruce may well be right that it is the very first read that is the problem.
Quite possibly, your data file contains an invisible character that is invalid in the context. The first time I faced this was getting on for 30 years ago, when my word-processor (Wordstar) had a "non-document" mode (OK for Fortran) and a "document" mode that wasn't.
What you have to do is to read that line of data into (say) a CHARACTER array or variable. That must work, as all characters are valid in this format. If you print it out, you will just get an invisible character again - you'll never see it. However, if you print the numerical value of each character, getting it by using ICHAR, then you will be able to print out the number.
From memory, the invisible characters are most of the ones numbered less than 32. From memory I can't remember if 127 or greater is a problem too.
If your datafile was written unformatted and you try to read it with formats, you will also be in trouble. It is possible you have the problem right the way through your file, or it could be simply one character at the start, or somewhere in between.
Eddie |
|
Back to top |
|
|
|