Computing.Net > Forums > Programming > Reading space from a empty file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Reading space from a empty file

Reply to Message Icon

Name: Gods
Date: October 20, 2009 at 06:05:15 Pacific
OS: Windows XP
CPU/Ram: 2.992 GHz / 1021 MB
Product: Dell / Optiplex gx270
Subcategory: Batch
Comment:

I have an file which may be empy , I try to read the file and when the file is empty it says "Echo is off" . Y does this happen ? and can we get a space or null out of this so that it would be easy fr me to compare'



Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: October 20, 2009 at 06:39:02 Pacific
Reply:

Hi.

> I have an file which may be empy , I try to read the file

How do you read it?

> and when the file is empty it says "Echo is off" .

It's not the empty file that says that. It's the echo command.

> Y does this happen ?

I presume that you read each line of the file (or maybe just the first line) into a variable, and then you echo it like this:

echo %line%

If line is not defined (or if it is defined to be one or more spaces or tabs) then the above command is seen as just this:

echo

And the echo command on its own just tells you whether you have echo set to on or off. To fix this, use:

if defined line echo.%line%

So, if line is undefined, nothing happens. If line is just spaces/tabs, it prints a blank line. If it contains printable characters, it prints them. The dot (.) after echo is treated as a delimiter and not printed.

> and can we get a space or null out of this so that it would be easy fr me to compare'

Sorry, can you rephrase. Space or null out of what? Compare with what?


0
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Reading space from a empty file

C : Reading from a file www.computing.net/answers/programming/c-reading-from-a-file/4682.html

%var% from a txt file vbs www.computing.net/answers/programming/var-from-a-txt-file-vbs-/14365.html

Reading data from a sound card www.computing.net/answers/programming/reading-data-from-a-sound-card/15506.html