Quantcast
Channel: VFPX
Viewing all articles
Browse latest Browse all 3798

Updated Wiki: Thor TWEeT 15

$
0
0

Thor TWEeT #15: Table / Object Alias List

There have been some improvements in the handling of table aliases since the earlier TWEet onIntellisenseX: Aliases for VFP Tables.

The difficulty in what was described there is that the solutions do not go far enough.  The first example shows that IntellisenseX recognizes aliases create by USE statements:

image

But this alias is only recognized by IntellisenseX within the same procedure as the USE statement. If this table were opened in the LOAD event of a form, the alias would be available there – and in no other methods.

And the #Alias directive has the same limitation – to be of value, it must be inserted into every single method referencing the table.

The solution offered by the Table / Object Alias List is that there is a table (maintained by Thor) that containsglobal definitions of tables (or objects – but we will get to that later on).

You can add records to this table by executing Thor tool Browse Table/Object Alias List, which does exactly that – it opens a browse window where you can add records (or edit existing records), like this:

SNAGHTMLb4b90c5

Henceforward, whenever you enter “SomeAlias” and invoke IntellisenseX as you always do, by pressing the dot (or hot key), it will open table “PartsListFields”.

Note well: This is truly a global definition for “SomeAlias”. It is not relative to the current form, class, folder, project, or application, or anything else.

For the table name you can enter also enter full path or relative paths.

SNAGHTMLb54cc00

As noted earlier, you can also add entries to this table that correspond to global objects. To do this, you can enter an executable expression in the Table field. (Note the use of zero as the third parameter to NewObject, so that the INIT does not execute.)

SNAGHTMLb5afbd6

Actually, any executable expression will work, as long as the result is one of these:

  • an object
  • the alias of an open table
  • the alias of a table that Thor can open
  • an object containing an array named ‘aList’. This array may have up to three columns and the contents of the array will populate the drop down list.

In recognition of the frequency with which objects are identified in LOCAL statements, an alternative structure is provided so that you can actually copy such a LOCAL statement and paste directly into the table (re-ordered here by the Alias field)

SNAGHTMLb60f19a

Finally, there is an interesting extension available to the Alias field.  It can be used for object references, such as ‘loJob.oData’, where the oData is actually understood to be populated (at run time) by a Scatter from the Jobs table. With this usage, invoking IntellisenseX after enter loJob.oData will present the list of fields from the Jobs table.

SNAGHTMLb64809f

See also History of all Thor TWEeTs andthe Thor Forum.


Viewing all articles
Browse latest Browse all 3798

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>