Solved

EQUAVELENT OF xBASE AMPERSAND (&)

Posted on 1998-05-01
5
311 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
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.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

734 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