On the Table:

 

New Button

On the Click Event:

HReset(Product)                                          //Clears the Record Buffer

Open(WIN_Product_Form)                                 //Update Form

TableDisplay(TABLE_ProducttaCurrentRecord)        //Reset Table

 

Modify Button

The buffer already has the correct record

 

Open(WIN_Product_Form)

TableDisplay(TABLE_Product,taCurrentSelection)

 

 

Delete Button

// Is a row selected?

IF TableSelect(TABLE_Product) = -1 THEN RETURN

 

//1: &Delete

//2: Do&n't delete

SWITCH Dialog("Do you want to delete the record?")

 // &Delete

 CASE 1

         // Delete the Product record from the table

         TableDelete(TABLE_Product)                

         // Position on the current record

         TableDisplay(TABLE_ProducttaCurrentFirst)

         

 // Do&n't delete

 CASE 2        

END

 

 

On the Update Form, OK Button

ScreenToFile()        

IF Product..NewRecord THEN

 //If HReset has been called, ..NewRecord has been set to TRue

 HAdd(Product)

ELSE

 HModify(Product)

END

Close()

 

The test code of new record can be replaced by HSave. This function is used to check whether the record is already found in the data file, and it allows you to add it or to modify it. The code above becomes:

ScreenToFile()

HSave(Product)

Close()

 

Also:

CustomerRec is Record of CUSTOMER

 

CustomerRec.LastName = "MOORE"

CustomerRec.FirstName = "Paul"

CustomerRec.City = "PARIS"

 

// Assigns the content of the CustomerRec variable in the buffer of Customer data file

CUSTOMER = CustomerRec  

 

HAdd(CUSTOMER)

 

// You have the ability to do: HAdd(CUSTOMER, CustomerRec)