Manipulating Records of a Detail Block Residing on a Network by Keith Remmes Manipulating detail blocks that reside on a network often requires you to use different, and often complex, techniques to do tasks which in the usual single user environment requires little or no coding. One example of this is when you remove a record from a detail block. An example of such a routine is as follows: SUB deleterowlocal(rownum%%) SELECT FORM DROW "detailblock", rownum%% SELECT REMOVE FILE "detailfile" SELECT FORM CURRENT FORM END SUB This subroutine is called from a button next to the desired row but is outside the detail block. An example of the call is: CALL deleterowlocal(1) Pressing the button removes the record attached to row number 1. This, and following examples, assumes that the routine is being called from a command that resides within the detail block. The SELECT FORM CURRENT refreshes the link and re-populates the detail block so no blank row shows. Unfortunately, this routine is not valid for locking network-based detail records on a form. Since Superbase requires that a lock must be placed on a network-based record before manipulating it, doing a similar operation on a detail block requires a different technique. One simple solution is to do a SELECT CURRENT LOCK FILE "detailfile" before the SELECT REMOVE FILE "detailfile". However, the pointer to that record after SELECT CURRENT LOCK FILE "detailfile" does not necessarily point to the correct record, so there is a chance that the wrong record is deleted. To circumvent this problem, use the following code: SUB deleterownetwork() SELECT FORM DROW "detailblock", ROW FILE "detailfile" SET INDEX ALL SELECT CURRENT LOCK SELECT REMOVE FILE "masterfile" SELECT FORM CURRENT FORM END SUB Note that the above subroutine is valid with both the network and single user versions of Superbase. The LOCK parameter is ignored with the single user version. The most important aspect of this routine is that the SET INDEX ALL makes all the indexes point at the specified record. Therefore, SELECT CURRENT LOCK locks the correct record so that it can be manipulated. Multiple detail blocks pose an entirely different problem. Since the SELECT FORM DROW command requires the name of the detail block to work correctly, you need to use variables in place of both the detailblock and the detailfile name if you want to use the same subroutine with different detail blocks. An example of this is as follows: SUB deleterow(DBName$,DetailFile$,MasterFile$) SELECT FORM DROW DBName$, ROW FILE DetailFile$ SET INDEX ALL SELECT CURRENT LOCK SELECT REMOVE FILE MasterFile$ SELECT FORM CURRENT FORM END SUB Note that the variables, DBName$, DetailFile$, and MasterFile$, all represent items from the form and should not be changed within the above code. Instead, whenever you want to call the code, simply do something such as the following: CALL deleterow("DetailBlockName", "DetailFileName", "MasterFileName") Simply replace everything within quotation marks with the corresponding object names. By creating a subroutine such as the one above, it is much easier to take this subroutine to other applications when the same type of operation is needed. Although these subroutines illustrate the use of SELECT REMOVE to delete a desired row, many other operations can be accomplished by simply replacing the SELECT REMOVE with the operations you wish to do on that particular row. If you only plan to change the data, not to delete the record altogether, make sure that you replace the SELECT FORM CURRENT with a STORE FORM so as not to erase the changes that have been made. The command, SELECT FORM CURRENT, erases any changes made to that record and replaces it with the original version of the record.