Solved

EQUAVELENT OF xBASE AMPERSAND (&)

Posted on 1998-05-01
5
313 Views
Last Modified: 2013-11-19
Using a table called DATADICT, it is possible in xBase languages to open a file without knowing the name of the file.  For example:

cFileName := DATADICT->FILENAME        {DATADICT-.FILENAME CONTAINING, SAY, "CUSTOMER.DBF"}
use &cFilename.                                       {Evaluates at runtime to:  CUSTOMER}

One responded pointed out that I could use a generic table component and simply put the filename from the data dictionary into the Table.Name property, yet I would prefer to use the table components in my data module.  In xBase syntax, I guess it would look something like this:  

var
  sTblName := string;

begin
  sTblName := datamod.tblDataDict['TABLNAME'];      {where this field contains 'tableCustomer'}
  datamod.&sTblName.Open;
end

Perhaps this is simply not possible in Object Pascal....:)

0
Comment
Question by:roncm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 1

Expert Comment

by:Greedy
ID: 1340291
I will try to pull myself back to the evil days of Clipper...Anyway depending on just what DATADICT->FILENAME is returning you would do this

I think DATADICT->FILENAME is the field filename in the table DataDict...right??? oh well that's what I will take it for

so do this

if Table1.Active then Table1.Active := False;
Table1.TableName := tbDataDict.FieldByName('FileName').AsString;
Table1.Active := True;

You will propbably also want to go into foxpro and type in this
delete all for database = sucky
pack  :)


0
 

Author Comment

by:roncm
ID: 1340292
Sorry, no help....
0
 

Author Comment

by:roncm
ID: 1340293
Edited text of question
0
 

Accepted Solution

by:
jhunt earned 50 total points
ID: 1340294
What you are trying to do is not possible in object pascal. What you have to do is:

- for each table you want to open drop a TTable component on your datamodule (comparabal to each USE clause in clipper)

- Open your datadict table

Assign the Tablename propery:
if your filename contains a path use Extractfilename(filename) to extract the real filename.
Table1.TableName := tbDataDict['FileName']

Assign the Databasename property to the directory where your table resides (comparabal to set_default in clipper)
Call the table open method or set active to true

By the way, using a macro expansion in clipper takes a lot of time. Better is: USE (FileName) SHARED ...
0
 

Author Comment

by:roncm
ID: 1340295
Not possible.  I thought so.  Thanks jhunt...


0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question