0
votes

I am currently working on an old program written in Visual Foxpro 9, and is the first time I am facing this language. In the program there is a file called start.prg in wich are present all the procedure that will be called from the rest of the files. In particular, there are some procedures that initialize the connection with .dbf files, here one example:

 procedure a 
 select 1 
 use parkoft exclusive 
 // some actions with parkoft

Reading on the web, I found that visual foxpro has some commands similar to sql. So, what I thought, was that the Select was the field to select. But in this start.prg, there are around 100 procedures similar to the described above. But every procedure has a select N, with N progressive. The last procedure:

 procedure last
 select 50 
 use vendxcli shared 
 // actions 

In particular, I noted that when 2 procedure are with the same select N, the command use is referred to the same .dbf file (select 50 -> use vendxcli). This make me think that the N has something to do with the tables.

So, I created a dbf file. I added the file in the .pjx and I wrote another procedure into start.prg:

 procedure Nuova
 select 99 
 use oldsell wxclusive 
 // actions with oldsell 

But the program, when I use this procedure, takes data from other existing tables. What did I wrong ? What means the select N command?

If you need some other informations to help me, please ask everything you need.

1
SELECT chooses a work area (basically a file handle). It has nothing to do with the SQL SELECT statement. SELECT 1 means select work area one, and use parkoft exclusive means top open the parkoft database for exclusive use (non-shared) in that work area.Ken White
@Ken White it means that if I select work area 99 (as I do) it should be an empty work area and is not the reason of the conflict. Or I should choose the next free work area? (51 in this case)Stefano Miceli
I don't know anything more about your code or the conflict. You asked What means the select N command?, and I explained it.Ken White
When you select work area 99, it doesn't mesan it should be an empty area. It could be empty, if not, then you are closing the already open cursor there and opening a new one. This type of Select N usage is a very dangerous one and never recommended. If your intention is to select an "empty" area, then use SELECT 0. 0 means, select the first work area that is empty. Instead of work area numbers, use aliases to refer to work areas to be safe.Cetin Basoz
@Cetin Basoz right now I found "Use Table in 0". Does this command make something similar to what you said? (Alias -> Table, Work area -> first empty)Stefano Miceli

1 Answers

1
votes

"Yes, 'use tableName in 0' is a shortcut for 'Select 0' followed by use 'tableName'."

Almost, but not quite.

SELECT 0

USE tableName

... makes tableName the selected table, while

USE tableName IN 0

... does not change the currently selected work area.