lnSelect = SELECT() && Store alias number to variable
SELECT Systemids
SET EXACT ON
LOCATE FOR UPPER (ALLTRIM (tTablename))=UPPER (ALLTRIM (Systemids.tablename))
IF NOT FOUND ()
APPEND BLANK
LOCK()
REPLACE Systemids.tablename WITH tTablename
lIDValue=Systemids.idvalue
lIDValue=lIDValue+1
REPLACE Systemids.idvalue WITH lIDValue IN Systemids
UNLOCK IN Systemids
In this case, Systemids is the name of a table (to be more precise, it's the alias of the name of the table, but the distinction isn't important in this context).
When you say SELECT Systemids, you are telling Foxpro that the Systemids table will be the current or active table. Subsequent commands and functions will operate on that table, until you tell it otherwise.
So, for example, your LOCATE command, which searches a table for a given record, will now search the Systemids table.
What this code appears to be doing is to generate a primary key. The systemids table seems to contain values to be used as keys. When you want a new key, you search the table for the current key, add one to it, and write it back to the table. Rick has given you a fuller explanation of this in Thread1252-984297.
I hope this helps. I know VFP can be a bit confusing to start with, but persevere and it will eventually become clear.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
From the code you posted, it seems the SystemIDs Table is a table storing the last ID of each other table of the database and is used for generating primary key values. I bet somewhere later the function returns lIDValue and a call to this code is made as a default value of the primary key fields of tables in this database.
It's not specific to windows, foxpro or databases in general to call this SystemIDs, but it seems okay so far.
Having problems with it? Duplicate IDs, Error 1884: "Uniqueness of index <name> is violated." ?
I'd recommend using FLOCK() on a seperate ID-table for each table of the database. eg. "sysID_tabCustomers" as ID-Table for Table "tabCustomers". That's more reliant than LOCK on a record.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.