suve
Warning: Illegal string offset 'doublequoteopening' in /usr/home/svgames/domains/svgames.pl/public_html/dokuwiki/inc/parser/xhtml.php on line 766 Warning: Illegal string offset 'doublequoteclosing' in /usr/home/svgames/domains/svgames.pl/public_html/dokuwiki/inc/parser/xhtml.php on line 774 Warning: Illegal string offset 'doublequoteopening' in /usr/home/svgames/domains/svgames.pl/public_html/dokuwiki/inc/parser/xhtml.php on line 766 Warning: Illegal string offset 'doublequoteclosing' in /usr/home/svgames/domains/svgames.pl/public_html/dokuwiki/inc/parser/xhtml.php on line 774 Warning: Illegal string offset 'doublequoteopening' in /usr/home/svgames/domains/svgames.pl/public_html/dokuwiki/inc/parser/xhtml.php on line 766 Warning: Illegal string offset 'doublequoteclosing' in /usr/home/svgames/domains/svgames.pl/public_html/dokuwiki/inc/parser/xhtml.php on line 774

awful: function: f-reset

Available since rev.36 (v.0.5.0).

Declaration

file :f-reset ( string $PATH )

Summary

Opens a file on the disk in read mode and returns a handle allowing to perform subsequent operations on the file. The file should be later closed with a call to :f-close.

If PATH does not exist (read), is not readable, or some other kind of error occurs, the returned filehandle will have its pmodep flag set to pinvalidp. The simplest way to check if a file has been opened successfully is to cast it to bool - any invalid (or closed) handle will cast to FALSE.

Can be seen as a shorthand way of performing a :f-open $PATH sprp call (actually, in interpreter innards, both do the same).

Example

# :f-reset example
:set &file :f-reset s'example.txt'
!if :not $file
    :writeln s'Unable to read from file!'
    :exit
!fi
 
:writeln :f-getln $file
:f-close $file

wikistrona zmodyfikowana 2014/0611/1016