Modifying Forms to Point to Data Files in a Specific Directory Superbase 2.0 stores the path and filename of each data file that is used on a form when the form is designed and saved in the Form Designer. When you open a saved form in Superbase or in the Form Designer, Superbase looks for the data files first in the directory in which the form file resides, then in the directory where the data files resided when the form was created. In some instances, particularly when distributing files to users on other machines which have different directory structures and where the form files are kept in a separate directory from the data files, it is necessary to modify the form files so that they point to the correct directory for opening data files. Here's how to modify form files so that they point to data files in a specific directory. Two methods of modifying the form Modifying a form so that it points to data files in a specific directory is fairly straightforward. You can use one of two different approaches: by changing the share mode or directory reference, or by creating a program. The first method is the simpler of the two. Select Open from the File menu, then File, and open the data files from the directory you want to use. Next, open the form for which you want to change the share mode and/or directory reference of the data files by selecting Open from File menu, then Form. Next, select Command from the Program menu and type SAVE FORM "NEWFORM" where NEWFORM is the name of your form. Now, NEWFORM points to the data files in the directory from which you currently opened the data files. In the second method, you change the directory reference of data files used in a form. This is a little more involved, but it demonstrates the usefulness of being able to save a form as a program. First, open the form in the Form Designer and save the form as a program by selecting Save as from the File menu, then Program. Then, open the program in the Superbase Program Editor, make the necessary modifications, and run the program. The program saves the form as a form file (.SBV) and the form references data files in the specified directory. For example, open the Form Designer and create a new form with one field from a single data file. For this example, use a data file called FILE1 and the field FIELD1. Choose Save from the File menu and save the form as FORM.SBV. Now, choose Save as from the File menu, then Program, and save the form program as FORMSPL.SBP. In Superbase, open the Program Editor by choosing Edit from the Program menu and open FORMSBL.SBP by choosing Open from the File menu in the Program Editor. You should have code that looks similar to the code below, without the line numbers. 1 SUB main() 2 CALL FORMSBL() 3 END SUB 4 5 SUB FORMSBL() 6 OPEN FILE SHARE ,0"C:\SB4W\SAMPLES\TEST\FILE1" 7 8 SET FORM USING 3 9 CREATE FORM "FORM",7999,10499 10 SET FORM FG 1,2 BG 0 ATTR 0,16,1,0,3,0,0 FIELD 0,0,0 11 SET FORM UL OFF BF OFF IT OFF 12 13 SET FORM ATTR 1,16,1,0,2 14 SET FORM TEXT "Courier,10,1,49,0" 15 ADD FORM 6,500,188,3334,136,FIELD1.FILE1,1 16 17 SELECT FORM FIRST :FORM 1 18 END SUB Add the following line after Line 5: CLOSE ALL Now, modify Line 6 to change the path so that it looks like the following: OPEN FILE SHARE,0"C:\DATA\FILE1" Note that the SHARE,0 may not be in your code depending on whether you are running the network version or the single user version. Next, insert the following after Line 17: SAVE FORM "FORM" This saves the form to a file named FORM.SBV. The modified program should look like the following. 1 SUB main() 2 CALL FORMSBL() 3 END SUB 4 5 SUB FORMSBL() 6 CLOSE ALL 7 OPEN FILE SHARE ,0"C:\DATA\FILE1" 8 9 SET FORM USING 3 10 CREATE FORM "FORM",7999,10499 11 SET FORM FG 1,2 BG 0 ATTR 0,16,1,0,3,0,0 FIELD 0,0,0 12 SET FORM UL OFF BF OFF IT OFF 13 14 SET FORM ATTR 1,16,1,0,2 15 SET FORM TEXT "Courier,10,1,49,0" 16 ADD FORM 6,500,188,3334,136,FIELD1.FILE1,1 17 18 SELECT FORM FIRST :FORM 1 19 SAVE FORM "FORM" 20 END SUB Choose Run from the Program menu in the Program Editor. This saves the form as FORM.SBV and the form now points to the data file in the C:\DATA directory. Now, you can move FORM.SBV to any directory and if that directory does not have FILE1 in it, the form opens FILE1 from the C:\DATA directory. If you later decide to move FILE1 to another directory, modify line 7 so that it points to the right location and Run the program again. Program: Superbase Versions: 2.0 Date: August 13, 1993 D Date: