home *** CD-ROM | disk | FTP | other *** search
- program DB_Xpl04;
- uses
- CRT,
- DOS,
- GS_KeyI,
- GS_dBFld,
- GS_dBase;
-
- var
- Health : GS_dBFld_Objt;
- DumyStr : string;
-
- procedure DisplayRecord;
- begin
- Health.FieldDisplay('FOOD','Name of Food: ',1,1);
- Health.FieldDisplay('QUANTITY','Quantity: ',1,2);
- Health.FieldDisplay('UNITTYPE','Type of Unit: ',1,3);
- Health.FieldDisplay('CALS','Calories: ',1,4);
- Health.FieldDisplay('TOT_FAT_G','Total Fat: ',1,5);
- Health.FieldDisplay('SAT_FAT_G','Saturated Fat: ',1,6);
- Health.FieldDisplay('CHOLES_MG','Cholesterol per Mg: ',1,7);
- Health.FieldDisplay('COMMENTS','Comments: ',1,8);
- end;
-
- procedure ModifyRecord;
- var
- dp,
- da : string[2];
-
- procedure AcceptRec(FieldName, FieldTitle : string; x, y : integer);
- begin
- DumyStr := Health.FieldAccept(FieldName, FieldTitle, x, y);
- if not GS_KeyI_Esc then
- Health.FieldPut(FieldName,DumyStr);
- end;
-
- begin
- AcceptRec('FOOD','Name of Food: ',1,1);
- if not GS_KeyI_Esc then AcceptRec('QUANTITY','Quantity: ',1,2);
- if not GS_KeyI_Esc then AcceptRec('UNITTYPE','Type of Unit: ',1,3);
- if not GS_KeyI_Esc then AcceptRec('CALS','Calories: ',1,4);
- if not GS_KeyI_Esc then AcceptRec('TOT_FAT_G','Total Fat: ',1,5);
- if not GS_KeyI_Esc then AcceptRec('SAT_FAT_G','Saturated Fat: ',1,6);
- if not GS_KeyI_Esc then AcceptRec('CHOLES_MG','Cholesterol per Mg: ',1,7);
- if not GS_KeyI_Esc then AcceptRec('COMMENTS','Comments: ',1,8);
- if GS_KeyI_Esc then exit;
- GoToXY(1,10);
- write('Delete Record?');
- if Health.DelFlag then dp := 'Y' else dp := 'N';
- da := Health.EditString(dp,16,10,1);
- GoToXY(1,10);
- write('':18);
- if da <> dp then
- if (da = 'Y') or (da = 'y') then Health.Delete else Health.UnDelete
- else
- Health.PutRec(Health.RecNumber);
- end;
-
- begin
- ClrScr;
- GotoXY(1,16);
- write('Press ESC to stop, any other key to continue');
- Health.Init('HEALTH');
- Health.Open;
- Health.Index('FOODNAME');
- Health.GetRec(Top_Record);
- while (not Health.File_EOF) and (not GS_KeyI_Esc) do
- begin
- DisplayRecord;
- ModifyRecord;
- Health.GetRec(Next_Record);
- end;
- Health.Close;
- end.