Recent

Author Topic: File Handling In Pascal Binary Files Wiki Needs Work  (Read 7193 times)

flywire

  • Jr. Member
  • **
  • Posts: 85
File Handling In Pascal Binary Files Wiki Needs Work
« on: March 05, 2015, 12:35:18 pm »
I have been making the file handling examples in the tutorial executable but the Binary Files need a bit of work: http://wiki.freepascal.org/File_Handling_In_Pascal#Binary_files

The first one falls over at the seek and I don't understand the intended functionality.

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: File Handling In Pascal Binary Files Wiki Needs Work
« Reply #1 on: March 05, 2015, 01:07:39 pm »
The code fragment is useless:
- the seek should not be there
- the buffer is written with random data (garbage)
So the title of this topic is well chosen ;)
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

Leledumbo

  • Hero Member
  • *****
  • Posts: 8739
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: File Handling In Pascal Binary Files Wiki Needs Work
« Reply #2 on: March 05, 2015, 01:10:46 pm »
The code fragment is useless:
- the seek should not be there
- the buffer is written with random data (garbage)
So the title of this topic is well chosen ;)
Mind fixing it?

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: File Handling In Pascal Binary Files Wiki Needs Work
« Reply #3 on: March 05, 2015, 04:18:36 pm »
Mind fixing it?
I assumed flywire was already on top of it  ::)
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

flywire

  • Jr. Member
  • **
  • Posts: 85
Re: File Handling In Pascal Binary Files Wiki Needs Work
« Reply #4 on: March 05, 2015, 08:05:11 pm »
Mind fixing it?

I have made extensive changes to this tutorial page but I can't understand this section so hopefully someone else can step it.

Bart

  • Hero Member
  • *****
  • Posts: 5232
    • Bart en Mariska's Webstek
Re: File Handling In Pascal Binary Files Wiki Needs Work
« Reply #5 on: March 05, 2015, 08:54:01 pm »
Made some changes.

Bart

flywire

  • Jr. Member
  • **
  • Posts: 85
Re: File Handling In Pascal Binary Files Wiki Needs Work
« Reply #6 on: March 06, 2015, 10:25:06 am »
These tutorials are a good resource but I would like to promote a bit of discussion on who the audience is for them? If it is newbies, and I can't see why it shouldn't be, then I think that the tutorials still assume too much. The Run-Time Library (RTL): Reference guide does a good job with plenty of executable examples.  For example, how does the user know which units have to be added to the uses clause? (I normally run them and do a search on the errors.) I would be useful to list them in the tutorial, and sysutils is not going to do it. Yes, I accept that changes are my responsibility too.

I tested the first two binary files examples and they work fine - good work fellas. The third one falls over at the end of 'FileStream := TFileStream.Create;'. Beats me - it works OK in the FileCopy example below. Thinking about it though, this not a very useful example and should probably be deleted and the FileCopy adjusted so that it works with large files.

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: File Handling In Pascal Binary Files Wiki Needs Work
« Reply #7 on: March 06, 2015, 10:37:49 am »
These tutorials are a good resource but I would like to promote a bit of discussion on who the audience is for them? If it is newbies, and I can't see why it shouldn't be, then I think that the tutorials still assume too much.
In this case the reviewed examples are clear enough.
It would be a waste of time to explain basic language elements on every page.
BTW (rhetorical question): what is the definition of newbies?

As for the units usage: I agree.
A code fragment that makes use of a specific class that requires a uses line, should make mention of that.
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11260
  • FPC developer.
Re: File Handling In Pascal Binary Files Wiki Needs Work
« Reply #8 on: March 06, 2015, 01:24:07 pm »
   For example, how does the user know which units have to be added to the uses clause? (I normally run them and do a search on the errors.)

Press "F1" on the symbol with help installed?

eny

  • Hero Member
  • *****
  • Posts: 1634
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

flywire

  • Jr. Member
  • **
  • Posts: 85
Re: File Handling In Pascal Binary Files Wiki Needs Work
« Reply #10 on: March 08, 2015, 12:35:11 am »
Done.

Just ran program ReadBinaryDataInMemoryForAppend because I need to.

Code: [Select]
    // Write some arbitrary data to the memory stream
    msApp.WriteByte(68);
    msApp.WriteAnsiString('Some extra text');
    msApp.WriteDWord(671202);

When I first looked at the result in Hex I thought it was screwed up but then I realised that this demo is really informative, especially in little endian. Well done.

 

TinyPortal © 2005-2018