Re: Need more examples ...
Chris Angelico <[email protected]>
| Newsgroups | gmane.comp.lang.pike.user |
|---|---|
| Message-ID | <CAPTjJmoJzE=HCt0XRcOFHSNYn7QVY-ZC01356JLE5V7YaSwVtg@mail.gmail.com> |
On Fri, Dec 9, 2016 at 10:33 PM, Arie van Wingerden <[email protected]> wrote: > 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??? Normally what you'll do in Pike is to start by constructing an object. In the case of Stdio.File and Stdio.FILE, it works like this: > Stdio.File("spam.pike"); (1) Result: Stdio.File("spam.pike", 0, 777 /* fd=10 */) > Stdio.File("spam.pike")->read(64); (2) Result: "int main()\n" "{\n" "\tint x = 123;\n" "\twhile (string command = Stdio.stdin." In the documentation, the constructor is create(). Once you've created the object, you'll be able to use all the methods listed in the docs. ChrisA