View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0034805||FPC||Documentation||public||2019-01-03 14:32||2019-01-04 14:48|
|Reporter||Mark Morgan Lloyd||Assigned To||Michael Van Canneyt|
|Product Version||3.0.4||Product Build|
|Target Version||3.2.0||Fixed in Version||3.3.1|
|Summary||0034805: Example code for FindFirst()|
|Description||Either the call to FindClose() should be moved up by a line, or the spurious begin/end should be removed.|
|Tags||No tags attached.|
|Fixed in Revision||1532|
Maybe like so:
Var Info : TSearchRec;
Count : Longint = 0;
If FindFirst ('*',faAnyFile and faDirectory,Info) = 0 then
With Info do
If (Attr and faDirectory) = faDirectory then
Write('Dir : ');
Writeln ('Finished search. Found ',Count,' matches');
Maybe. However I'd suggest that it's probably best to have as few syntactic features in an example as possible, and while it would be desirable to use try-finally-end, :nn to format output and so on they muddy the water for somebody who is still working through elementary language structure.
For various reasons I've been spending a bit of time in some very old ALGOL manuals, which really do emphasise the extent to which early technical writers hadn't worked out how to document a language: as a particular example, no distinction is made between the language syntax and (what we'd call) standard library facilities.
IMO, the industry owes a big debt to Kathleen Jensen who in one slim volume showed people how it should be done.
I simply moved the findclose.
I didn't add try/finally as this particular code normally does not require it.
|2019-01-03 14:32||Mark Morgan Lloyd||New Issue|
|2019-01-03 14:32||Mark Morgan Lloyd||Status||new => assigned|
|2019-01-03 14:32||Mark Morgan Lloyd||Assigned To||=> Michael Van Canneyt|
|2019-01-03 15:48||Thaddy de Koning||Note Added: 0113129|
|2019-01-03 17:16||Mark Morgan Lloyd||Note Added: 0113132|
|2019-01-03 17:18||Mark Morgan Lloyd||Note Edited: 0113132||View Revisions|
|2019-01-04 02:27||Marco van de Voort||Relationship added||related to 0032012|
|2019-01-04 09:44||Michael Van Canneyt||Fixed in Revision||=> 1532|
|2019-01-04 09:44||Michael Van Canneyt||Note Added: 0113145|
|2019-01-04 09:44||Michael Van Canneyt||Status||assigned => resolved|
|2019-01-04 09:44||Michael Van Canneyt||Fixed in Version||=> 3.3.1|
|2019-01-04 09:44||Michael Van Canneyt||Resolution||open => fixed|
|2019-01-04 09:44||Michael Van Canneyt||Target Version||=> 3.2.0|
|2019-01-04 14:48||Mark Morgan Lloyd||Note Added: 0113156|
|2019-01-04 14:48||Mark Morgan Lloyd||Status||resolved => closed|