Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

EQUAVELENT OF xBASE AMPERSAND (&)

Posted on 1998-05-01
5
Medium Priority
?
315 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
  • 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 150 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Suggested Courses

824 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