Solved

EQUAVELENT OF xBASE AMPERSAND (&)

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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 …
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
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:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now