IonicWind Software

Aurora Compiler => General Discussion => Topic started by: Bruce Peaslee on December 28, 2005, 11:10:12 AM

Title: File I/O
Post by: Bruce Peaslee on December 28, 2005, 11:10:12 AM
I'm getting to the point where some I/O would be useful. Maybe a short example?ÂÃ,  ÂÃ, ::)

Also, FileRequest() returns type HEAP. How does that work?

Thanks.
Title: Re: File I/O
Post by: Ionic Wind Support Team on December 28, 2005, 11:12:27 AM
See editor.src.  Uses file I/O.  Or ask a specific question ;)

HEAP is the same as string.  It is just dynamically allocated, the compiler handles it internally.
Title: Re: File I/O
Post by: Bruce Peaslee on December 28, 2005, 11:17:55 AM
Quote from: Ionic Wizard on December 28, 2005, 11:12:27 AM
See editor.src.ÂÃ,  Uses file I/O.ÂÃ,  Or ask a specific question ;)

Duh.ÂÃ,  :-[ÂÃ,  I was just studying it, too.

Quote from: Ionic Wizard on December 28, 2005, 11:12:27 AM
HEAP is the same as string.ÂÃ,  It is just dynamically allocated, the compiler handles it internally.

Got it.
Title: Re: File I/O
Post by: Parker on December 28, 2005, 06:01:59 PM
I assume that HEAP is the same as in IB, where it works like this:
pointer pMem;
pMem = AllocHeap(6);
*(string)pMem = "Hello"; // five characters plus the null
return *(string)pMem;


And then anything that uses that function, the compiler will call FreeHeap after the statement is done executing. I do wonder though, how it's different to return the type STRING rather than HEAP, what the compiler does differently.
Title: Re: File I/O
Post by: Ionic Wind Support Team on December 28, 2005, 06:15:19 PM
Use heap when the length of the returned string is an unknown at compile time.   Returning a string does the same memory management but the length of the string itself is fixed.

FileRequest can return an unlimited amount of multiple selected filenames.  A string or dstring type wouldn't work since we don't know how many files a user is going to select, and you wouldn't want a limit on that.

Title: Re: File I/O
Post by: Bruce Peaslee on December 31, 2005, 07:08:43 AM
Here's a question. How do I read/write by UDT to disk?
Title: Re: File I/O
Post by: Ionic Wind Support Team on December 31, 2005, 10:06:51 AM
write(file, udt, len(udt));
read(file, udt, len(udt));

use SEEK for positioning.

//read the 4th record
seek(file, len(udt) * 3);
reac(file, udt, len(udt);