Recent

Author Topic: Starting Project with Lazarus - Pascal  (Read 9916 times)

SephirothsHell

  • New member
  • *
  • Posts: 8
Re: Starting Project with Lazarus - Pascal
« Reply #15 on: July 22, 2014, 03:20:52 am »
Hello everybody,

I have been basically adding comments to Roland Chastain's suggestion program while investigating each command I don't understand at first. I have modified the code a little bit, created a Menu for calling each Procedure, and I'm working on modifying a record within the file.

I have not been able to do it so far, I found some examples with text files but it doesn't work the same way.

Here are some questions based Roland Chastain's example code:

1.- You calculate file size in bytes because in a typed/untyped file you cannot use "Append" like in a text file for overwriting without deleting any previously saved info but instead counting until last byte and then keep writing?

2.- Why even though there's a CONST statement for "TSex" as "M" and "F" it's only allow "Male" or "Female"?

3.- Why use a .DAT file and not a .TXT file?

4.- How could I sort records inside the file by ID number?

5.- How could I show records horizontally in order to show a list of all records in the file?

Thanks in advance!
"Reality is just a point of view"
Phillip K. Dick

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Starting Project with Lazarus - Pascal
« Reply #16 on: July 22, 2014, 05:38:41 am »
Why not using HowardPC example?

Windsurfer

  • Sr. Member
  • ****
  • Posts: 368
    • Windsurfer
Re: Starting Project with Lazarus - Pascal
« Reply #17 on: July 22, 2014, 10:07:59 am »
Don't make the mistake of using fashionable methods, just because they are fashionable.

Keep your eye on the objectives of your project. Make sure you understand the methods and that they are simple and easy to change. Use the simplest approach possible that meets the requirement.

Forty years ago, I managed to convert my first class honors degree to a lower second by becoming too interested in programming perfection. I neglected the course work because I found that easy, but had not learnt it like a parrot for the exams.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Starting Project with Lazarus - Pascal
« Reply #18 on: July 22, 2014, 03:53:13 pm »
Here is (attached) HowardPC example with some little modifications. It is very easy to understand, simple and works just fine.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Starting Project with Lazarus - Pascal
« Reply #19 on: July 22, 2014, 04:30:30 pm »
Nice one, typo.
I think replacing the line

Code: [Select]
if sgDisplay.Cells[NameCol, i] = patient.name then

with

Code: [Select]
if SameText(sgDisplay.Cells[NameCol, i], patient.name) then

would be a further improvement, catching (most) different spellings of the same name.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Starting Project with Lazarus - Pascal
« Reply #20 on: July 22, 2014, 04:53:20 pm »
Yes. It is on Mainform file, line 58.

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: Starting Project with Lazarus - Pascal
« Reply #21 on: July 22, 2014, 04:55:10 pm »
And here's hoping father and son (with the same name) don't get sick  ;D

Or:
Code: [Select]
    if SameText(sgDisplay.Cells[NameCol, i], patient.name) and
      (sgDisplay.Cells[AgeCol, sgDisplay.RowCount-1]=IntToStr(patient.age)) then

But it would be best to store the exact birthday and name and check for that.

TS did mention "ID number" being a part of the data so i guess there is a unique number already defined (so there won't be a need for the name check or only give a warning when a name is already present).
« Last Edit: July 22, 2014, 05:09:02 pm by rvk »

 

TinyPortal © 2005-2018