Re: out of memory, even tho remembered nothing!

new topic     » goto parent     » topic index » view thread      » older message » newer message
useless_ said...

But that's my point in that last post, testing for junk being a SEQUENCE doesn't work. EOF is defined as a CONSTANT, and those are defined as OBJECTs, ergo gets() does not return an ATOM.

I suspect that you have misunderstood the concept of OBJECT. The gets function returns an object. When that object contains a sequence, it's the read data and when that object contains an atom it signifies end-of-file. The CONSTANT called EOF is defined as an OBJECT with the ATOM value of -1. OBJECTs are containers that can contain either atoms or sequences.

The code you posted as not working will not work if 'junk' is defined as a sequence variable, but if defined as an object then it will work. The following should be working correctly ...

include std/console.e 
object junk 
junk = gets(readfile) 
while sequence(junk) do 
  size += length(junk) 
  display(size) --> simplier than ... puts(1,sprintf("%d",size)&"\r") 
  junk = gets(readfile) 
end while 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu