https://wiki.freepascal.org/index.php?title=Basic_Pascal_Tutorial/Chapter_2/Files/bg&feed=atom&action=history
Basic Pascal Tutorial/Chapter 2/Files/bg - Revision history
2024-03-28T12:45:09Z
Revision history for this page on the wiki
MediaWiki 1.35.6
https://wiki.freepascal.org/index.php?title=Basic_Pascal_Tutorial/Chapter_2/Files/bg&diff=153783&oldid=prev
Kai Burghardt: bypass language bar/categorization template redirect [cf. discussion]
2022-08-20T14:18:28Z
<p>bypass language bar/categorization template redirect [cf. <a href="/Special:PermanentLink/149778#Cluttering_of_main_name_space" title="Special:PermanentLink/149778">discussion</a>]</p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 14:18, 20 August 2022</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>{{Files}}</div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>{{<ins class="diffchange diffchange-inline">Basic Pascal Tutorial/Chapter 2/</ins>Files}}</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>{{TYNavigator|Chapter 2/Formatting output|Chapter 2/EOLN and EOF}}</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>{{TYNavigator|Chapter 2/Formatting output|Chapter 2/EOLN and EOF}}</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
</table>
Kai Burghardt
https://wiki.freepascal.org/index.php?title=Basic_Pascal_Tutorial/Chapter_2/Files/bg&diff=152748&oldid=prev
Kai Burghardt: bypass redirects [cf. discussion]
2022-08-06T00:10:48Z
<p>bypass redirects [cf. <a href="/Special:PermanentLink/149778#Cluttering_of_main_name_space" title="Special:PermanentLink/149778">discussion</a>]</p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 00:10, 6 August 2022</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>{{Files}}</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>{{Files}}</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>{{TYNavigator|<del class="diffchange diffchange-inline">Formatting_output</del>|<del class="diffchange diffchange-inline">EOLN_and_EOF</del>}}</div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>{{TYNavigator|<ins class="diffchange diffchange-inline">Chapter 2/Formatting output</ins>|<ins class="diffchange diffchange-inline">Chapter 2/EOLN and EOF</ins>}}</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Файлове ==</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Файлове ==</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l58" >Line 58:</td>
<td colspan="2" class="diff-lineno">Line 58:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></syntaxhighlight></div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></syntaxhighlight></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>{{TYNavigator|<del class="diffchange diffchange-inline">Formatting_output</del>|<del class="diffchange diffchange-inline">EOLN_and_EOF</del>}}</div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>{{TYNavigator|<ins class="diffchange diffchange-inline">Chapter 2/Formatting output</ins>|<ins class="diffchange diffchange-inline">Chapter 2/EOLN and EOF</ins>}}</div></td></tr>
</table>
Kai Burghardt
https://wiki.freepascal.org/index.php?title=Basic_Pascal_Tutorial/Chapter_2/Files/bg&diff=150049&oldid=prev
Kai Burghardt: Kai Burghardt moved page Files/bg to Basic Pascal Tutorial/Chapter 2/Files/bg: tidy up main name space: create subpage hierarchy for basic Pascal tutorial [cf. [[Special: PermaLink/149778#Cluttering o...
2022-02-03T01:53:49Z
<p>Kai Burghardt moved page <a href="/Files/bg" class="mw-redirect" title="Files/bg">Files/bg</a> to <a href="/Basic_Pascal_Tutorial/Chapter_2/Files/bg" title="Basic Pascal Tutorial/Chapter 2/Files/bg">Basic Pascal Tutorial/Chapter 2/Files/bg</a>: tidy up main name space: create subpage hierarchy for <a href="/Category:Basic_Pascal_Introduction/bg" title="Category:Basic Pascal Introduction/bg">basic Pascal tutorial</a> [cf. [[Special: PermaLink/149778#Cluttering o...</p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<tr class="diff-title" lang="en">
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 01:53, 3 February 2022</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>
Kai Burghardt
https://wiki.freepascal.org/index.php?title=Basic_Pascal_Tutorial/Chapter_2/Files/bg&diff=144682&oldid=prev
Alpinistbg at 19:38, 22 April 2021
2021-04-22T19:38:25Z
<p></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 19:38, 22 April 2021</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>{{Files}}</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>{{Files}}</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"><font size='5'>Файлове</font><br/></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>{{TYNavigator|Formatting_output|EOLN_and_EOF}}</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>{{TYNavigator|Formatting_output|EOLN_and_EOF}}</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">2D - Files </del>(author: Tao Yue, state: unchanged)</div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">== Файлове ==</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">''</ins>(author: Tao Yue, state: unchanged)<ins class="diffchange diffchange-inline">''</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Четенето от файл вместо от конзолата (клавиатурата) може да се извърши чрез: </div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Четенето от файл вместо от конзолата (клавиатурата) може да се извърши чрез: </div></td></tr>
</table>
Alpinistbg
https://wiki.freepascal.org/index.php?title=Basic_Pascal_Tutorial/Chapter_2/Files/bg&diff=144620&oldid=prev
Alpinistbg: Created page with "{{Files}} <font size='5'>Файлове</font><br/> {{TYNavigator|Formatting_output|EOLN_and_EOF}} 2D - Files (author: Tao Yue, state: unchanged) Четенето от фа..."
2021-04-21T13:16:44Z
<p>Created page with "{{Files}} <font size='5'>Файлове</font><br/> {{TYNavigator|Formatting_output|EOLN_and_EOF}} 2D - Files (author: Tao Yue, state: unchanged) Четенето от фа..."</p>
<p><b>New page</b></p><div>{{Files}}<br />
<font size='5'>Файлове</font><br/><br />
{{TYNavigator|Formatting_output|EOLN_and_EOF}}<br />
<br />
2D - Files (author: Tao Yue, state: unchanged)<br />
<br />
Четенето от файл вместо от конзолата (клавиатурата) може да се извърши чрез: <br />
<syntaxhighlight lang="pascal"><br />
read (file_variable, argument_list);<br />
write (file_variable, argument_list);<br />
</syntaxhighlight><br />
<br />
Това важи и за <tt>readln</tt> and <tt>writeln</tt>. Променливата '''file_variable''' се декларира по следния начин:<br />
<syntaxhighlight lang="pascal"><br />
var<br />
...<br />
filein, fileout : text;<br />
</syntaxhighlight> <br />
<br />
Типът <tt>text</tt> означава, че файлът е обикновен текстов файл.<br />
<br />
След декларирането на променлива за файла и преди четене от или писане в него, трябва да свържем променливата с името на файла на диска и да отворим файла. Това може да стане по един от двата начина. Обикновено: <br />
reset (file_variable, 'filename.extension');<br />
rewrite (file_variable, 'filename.extension');<br />
Процедурата <tt>reset</tt> отваря файла за четене, а <tt>rewrite</tt> отваря файла за писане. Файл отворен с <tt>reset</tt> може да се използва само с <tt>read</tt> и <tt>readln</tt>. Файл отворен с <tt>rewrite</tt> може да се използва само с <tt>write</tt> и <tt>writeln</tt>.<br />
<br />
Турбо Паскал въведе '''assign''' нотацията. Първо присвоявате име на файл на променлива, след което извиквате <tt>reset</tt> или <tt>rewrite</tt>, като използвате само променливата. <br />
<syntaxhighlight lang="pascal"><br />
assign (file_variable, 'filename.extension');<br />
reset (file_variable);<br />
</syntaxhighlight><br />
<br />
Методът за представяне на пътя и името на файла се различава в зависимост от операционната система. В Windows се използват обратни наклонени черти и букви на устройството защото произлиза от DOS (e.g. <tt>c:\directory\name.pas</tt>), докато FreeBSD, macOS и Linux използват '/' поради наследяването им от UNIX.<br />
<br />
След като приключите с файла, можете да го затворите с: <br />
<syntaxhighlight lang="pascal"><br />
close (file_variable);<br />
</syntaxhighlight><br />
<br />
Ето пример за програма, която използва файлове. Тази програма е написана за Turbo Pascal и DOS и ще създаде file2.txt с първия символ от file1.txt: <br />
<syntaxhighlight lang="pascal"><br />
program CopyOneByteFile;<br />
<br />
var<br />
mychar : char;<br />
filein, fileout : text;<br />
<br />
begin<br />
assign (filein, 'c:\file1.txt');<br />
reset (filein);<br />
assign (fileout, 'c:\file2.txt');<br />
rewrite (fileout);<br />
read (filein, mychar);<br />
write (fileout, mychar);<br />
close(filein);<br />
close(fileout)<br />
end. <br />
</syntaxhighlight><br />
<br />
{{TYNavigator|Formatting_output|EOLN_and_EOF}}</div>
Alpinistbg