Re: Need more examples ...

Pontus Östlund <[email protected]>
Newsgroups gmane.comp.lang.pike.user
Message-ID <[email protected]>
> 9 dec. 2016 kl. 12:33 skrev Arie van Wingerden <[email protected]>:
> 
> When trying things out I find a huge module reference but a limited tutorial and manual.
> 
> E.g. I try to open a textfile for read.
> I find:
>   - Stdio.File (non-buffered)
>   - Stdio.FILE (buffered)
> However I cannot find a simple example of how to use it ...
> 
> I tried several ways to use the open() method, but then it says that neither Stdio.File nor Stdio.FILE have an open method, which is not conform the module reference.
> 
> Maybe I missed the obvious :-)
> 
> So, are there more examples available???

We could for sure be better at providing examples and tutorials. One of these days...

There are many ways to read a file:

The whole file in one sweep: 

	string s = Stdio.read_file("file.ext");

And I guess this one way of using the File object.

	Stdio.File f = Stdio.File("file.ext", "r");

or alternatively

	Stdion.File f = Stdio.File();
	f->open("file.ext", "r");

and then

	string a = f->read(1024); -> read one kb	
	string b = f->read();     -> read to end of file or stream


Hope this works.


# Pontus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.