Silverfrost Forums

Welcome to our forums

How to undestand whar Read is complaining about

24 Mar 2011 3:23 #7963

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.

24 Mar 2011 11:20 #7964

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.

25 Mar 2011 8:34 #7967

Quoted from brucebowler 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.

25 Mar 2011 8:36 #7968

Quoted from mecej4 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?

25 Mar 2011 12:07 #7969

Quoted from BEEFHEART 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.

25 Mar 2011 6:22 #7972

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.

26 Mar 2011 9:40 #7975

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 [u:f3ff598505]numerical value [/u:f3ff598505]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

Please login to reply.