File Handling In Pascal Binary Files Wiki Needs Work lazarus / 62-General ---------------------------------------------------------------------- flywire · 2015-03-05 11:35 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 · 2015-03-05 12:07 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 ---------------------------------------------------------------------- Leledumbo · 2015-03-05 12:10 Quote from: eny on March 05, 2015, 01:07:39 pmThe 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 · 2015-03-05 15:18 Quote from: Leledumbo on March 05, 2015, 01:10:46 pmMind fixing it? I assumed flywire was already on top of it ---------------------------------------------------------------------- flywire · 2015-03-05 19:05 Quote from: Leledumbo on March 05, 2015, 01:10:46 pmMind 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 · 2015-03-05 19:54 Made some changes. Bart ---------------------------------------------------------------------- flywire · 2015-03-06 09:25 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 · 2015-03-06 09:37 Quote from: flywire on March 06, 2015, 10:25:06 amThese 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. ---------------------------------------------------------------------- marcov · 2015-03-06 12:24 Quote from: flywire on March 06, 2015, 10:25:06 am   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 · 2015-03-06 14:09 Quote from: Leledumbo on March 05, 2015, 01:10:46 pmMind fixing it? Done. ---------------------------------------------------------------------- flywire · 2015-03-07 23:35 Quote from: eny on March 06, 2015, 03:09:48 pmDone. 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.