Getting a list of field names

I have two tables, both containing customer information, but from two different sources. So the field names don’t easily map.

I have created a “mapping” table, with 5 fields in it:
id LONG ! Autonumber
LeftFieldName STRING(50)
LeftFieldType STRING(10)
RightFieldName STRING(50)
RightFieldType STRING(10)

So when I populate this table I’d like to choose from a drop-down list. The list would be obtained by reading the structure of each table, and obtaining the field name and type. The left table is called “LeftCust” and the right table is called “RightCust”.

Where do I begin? The shorter of the two tables has 24 fields, so I could just create a text file from the dictionary for each table and type the data in by hand, but I would like to learn how to do it properly.

Any suggestions or pointers would be most welcome.

what are going to do??? what are you trying to implement at the end??? not clear

Hello Donn,

Hit me up on Skype or send an email and I’ll help you out with this.

Afterwards, I’ll post the solution here.

I feel like this is a Who, What, and Where situation. :joy:

Don

You could write a template to generate the code. Getting the Type from the DCT is easy, getting it at runtime usually repairs TUFO that is unsupported.

1 Like

Dang Carl, you’re reading my mind.

That’s exactly what I was thinking.

I think I’ll throw together a generic template for him.

You are welcome to borrow from this if you find it useful. It’s from my old mailmerge template. I’m sure there are better ways.FieldExport.zip (1.1 KB)

3 Likes

I’m going to synchronise records between the two tables, adding records to RightCust that exist in LeftCust, and updating LeftCust with new data from RightCust.

After I posted this, I realised that I’ll have to hard-code the mapping, so I don’t need the table at all. Jeff’s template code pointed me to the same conclusion. Thanks everyone.

I created a template for you.

Updated template to create a local class where you can call the local method as needed.

DonnEdwards.tpl (7.9 KB)

Result:

ScreenHunter 65

4 Likes

Thank you. This will help a great deal

Why do you need to hard code the mapping?

You could use the FieldPairsClass along with who/what

1 Like

We wrote a Class which detects at runtime the EXACT fields structure.

Thus without predefined prop:name tags.

It detects, decimal, long, ulong, string, cstring, &string, sreal and all others in Queues, Groups and Files structures from the dct.

It also tells you the exact offset and length in bytes, as well the length the clarion type is defined.

Thus no need for a template.

No need for TUFO specs either.

So, you just do:
TrueReflection.Analyze(_queue)

(prototyped in the class as analyze(*Queue _queue),proc

It detects even places in a Decimal

Very handy, because we dont use the dct anymore :slight_smile:

1 Like

That’s interesting.
Are you willing to share the code?

How are you detecting a reference
How are you getting some the finer details like decimal sizes.

1 Like