Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Workarea?

Status
Not open for further replies.

dcomartin

Programmer
May 12, 2003
27
0
0
CA
Can someone explain to me what a "workarea" is? In the code im dealing with, I am often seeing "select 1" or "select 2". And in the language reference, it sais that SELECT, sets the current workearea. Is a workarea a record that was being worked on. So for example:

USE customer INDEX customer_name.ndx
FIND "Bob Dole"
* Some code *

GOTO 1
* Some Code *

SELECT 1 && Does this go back to the "bob dole" record?
SELECT 2 && Does this go to record 1

Is that what a "workarea" is? Or am i way off?
 
Alright here is what I figured out. You define your workeareas for each database file you open.

Example:

SELECT 1
USE customer INDEX customer_name.ndx
@0,0 SAY name && Prints "Bob Dole"

SELECT 2
USE products INDEX products_name.ndx
@1,0 SAY name && Prints "Apples"

SELECT 1 && This goes back to the customer database.
@2,0 SAY name ** Prints "Bob Dole"
 
Pretty neat, huh?

There's always a better way...
 
You got it. I always think of "workareas" as being like parking slots where I can park open databases.

The GOTO <n> command, like in your example above moves the record pointer in the currently selected database to record number <n>. Note <n> can be passed as a variable. Also GOTO TOP and GOTO BOTTOM apply as well.

Be aware that the record pointer stays put in any database that is not the currently selected one unless it is tied to the currently selected database with the SET RELATION TO command. I.e. it's just good to know that when you set the record pointer in database1 and then select database2 for use, do something, when you SELECT database1, the record pointer will be on the same record you left it on - a handy thing usually.

Have fun.
Dennis
 
Exactly, Dennis! great analogy...

DCOMARTIN, when you start to use the SET RELATION TO command, you'll special syntax to &quot;reach&quot; the &quot;related to&quot; database. Normally, you would do this: x = <fieldname> to assign the value of <fieldname> (of the current database) to the variable x. When you want to use the value of a field in the &quot;other&quot; database (the &quot;related to&quot; table) you have to do this: x = <table name or alias>-><fieldname>. The -> acts as a &quot;pointer&quot; to the other table.

Good luck and have fun!

There's always a better way...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top