Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 908335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:42:05+00:00 2026-05-15T16:42:05+00:00

I am an engineer and not a software programmer, so please excuse my ignorance.

  • 0

I am an engineer and not a software programmer, so please excuse my ignorance.

I have written a Delphi(7SE) program to read “real” datatype from a USB port connected to two digital thermometers.

I have completed this much of the program.

What I have not completed as yet is explained by the following:

I wish to save this “real” data to a Binary File(s). A text file would be fine as well, but i’m concerned about having a big data file.

I also wish to read this data back from the Binary/Text File to display the data using my Delphi application.

I don’t think this would be too difficult. I currently save my data in .CSV format.

The twist here is that the binary file should contain data from different sessions initiated by the user of my application.

So when I click on say, a button called “ historical” data, a new window/form would pop up that would show different session times that I had started & stopped from earlier times. Then a session would be selected and data then retrieved for displaying.

Can this be done in one binary files or would you have to use 2 files: one for the “real” data and another which indexes the different session times?

My requirement for this way of saving binary data is that I would not have to keep typing in filenames and therefore keeping track of many data files.

For example a thermo.hst(historical data) and a thermo.idx (index file) file would contain all the information such as actual temp data, time of read data, session start & end times etc.

Any useful pointers and hopefully code with as much detail would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T16:42:06+00:00Added an answer on May 15, 2026 at 4:42 pm

    I hope this sample code isn’t too late to be helpful.

    (I’ve added this as another answer from me so that I can cleanly list the code. If this or my previous post answers your question, please click the answer icon so I get reputation points!)

    Below is some rough code that shows how to read the sections in an ini file and find the largest filename. I confirmed it compiles and seems to return valid values, but you’ll need confirm it does what you need. It’s more to show you the idea…

    Note that if your data filenames have an extension, you’ll have add code to remove the extension in my sample code using something like: FileName := ChangeFileExt(Filename, ”).

      // Call with an open inifile.  Returns the name of the next filename, or '' if trouble
      Function GetNextFileName( const IniFile: TInifile):String;
      const
        BASE_FILENAME = 'File.'; // sections in the ini file will be [File.1], [File.2], ... [File.100], etc.
      var
        Sections: TStringList;
        NumericPartAsString: String;
        NumericPartAsInteger: Integer;
        ListIndex: Integer;
        LargestFileNumberSeenSoFar: Integer;
      begin
        Result := '';
        Sections := TStringList.Create;
        IniFile.ReadSections(Sections); // fills StringList with the names of all sections in the ini file
        if( Sections.Count = 0) then
          Result := BASE_FILENAME + '1'
        else
          begin  // find largest extension
            LargestFileNumberSeenSoFar := -1;
            ListIndex := 0;
            while ListIndex <= (Sections.Count - 1) do  // for every string (which is also a filename) in the string list:
              begin
                NumericPartAsString := StringReplace(Sections.Strings[ListIndex], BASE_FILENAME, '', []); // remove base filename
                if (NumericPartAsString <> '') then
                  begin
                    NumericPartAsInteger := StrToIntDef(NumericPartAsString, -1);
                    if (NumericPartAsInteger > LargestFileNumberSeenSoFar) then
                      LargestFileNumberSeenSoFar := NumericPartAsInteger;
                  end;
                inc(ListIndex);
              end;
            if (LargestFileNumberSeenSoFar > -1) then
              Result := BASE_FILENAME + IntToStr(LargestFileNumberSeenSoFar + 1);
          end;
        Sections.Free;
      end; { GetNextFileName }
    
      procedure TForm1.Button1Click(Sender: TObject);
      var
        IniFile: TInifile;
        NewFileName: String;
      begin
        IniFile := TInifile.Create('c:\junk\ini.ini');
        NewFileName := GetNextFileName(Inifile);
        if (NewFileName = '') then
          ShowMessage('Error finding new filename')
        else
          ShowMessage('New filename is ' + NewFileName);
        IniFile.Free;
      end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.