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

  • SEARCH
  • Home
  • 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 6866043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:07:50+00:00 2026-05-27T03:07:50+00:00

I have some tabular data: Foo Bar ————- fooes 42 bars 666 … So,

  • 0

I have some tabular data:

Foo       Bar
-------------
fooes     42
bars      666 
...

So, I declare the entity structure:

type TFoo = record
  Foo: string;
  Bar: Integer
end;

and the table of entities:

const FOOES = array [M..N] of TFoo = (
  // Have to specify the field names for each record...
  (Foo: 'fooes'; Bar:  42),
  (Foo: 'bars';  Bar: 666)
  { so on }
);

As you see, this looks quite verbose and redundant, and it is because I initialize all of the fields for all of the records. And there is a lot of editing if I copy tabular data prepared elsewhere. I’d prefer to not enumerate all of the fields and stick to the more laconic C style, that is, constants only. And here comes the record constructor…

Can record constructors help me in this case?

Here’s an example in C. You’ll notice that we don’t have to specify the field names in each declaration:

#include <stdio.h>

typedef struct {
        char    foo[10];
        int     bar;
} foo;

int main(void) {
        /* Look here */
        foo FOOES[2] = {{"foo", 42}, {"bar", 666}};
        int i = 0;
        for (; i < 2; i++) {
                printf("%s\t%d\n", FOOES[i].foo, FOOES[i].bar);
        }
        return 0;
}
  • 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-27T03:07:51+00:00Added an answer on May 27, 2026 at 3:07 am

    If you want it done in source then what you have already typed is your answer. You could, of course, put the data in separate arrays and initialize them that way, but that can make your code look messy.

    You could also store them in an text file (Foo=Bar format) and read them into a TStringList at run-time (SL.LoadFromFile()). But even with a sorted TStringList it will be far less efficient (MyVariable := SL.Values['Foo1']; for example).

    There are a million ways to solve this problem outside of source code. Taking it from the other direction, put the data into Excel and create an Excel macro to build the source and put it into the clipboard to paste into your PAS file. This wouldn’t be too difficult and probably easier than formatting the Delphi code within the IDE.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web-site that generates some simple tabular data as html tables, many
Have some data in a sybase image type column that I want to use
I have some tabular data which has a lot of fields in it, and
I have to display some tabular data where there is a maximum of 3
I have some tabular data with some functionality to view details that fires off
Say you have some tabular data you want to display, as well as allow
I have some tabular data. In the last column, I have 2 divs, one
I have a table in html with some tabular data. The thing is that
We have some input data that sometimes appears with &nbsp characters on the end.
I have some kind of test data and want to create a unit test

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.