Hi All, A few months ago I posted some messages about converting my dBase code (in Delphi) to lazarus. I was advised that I should NOT use Dataset.RecNo but instead I should use bookmarks. Can someone please advise me how to rewrite:
with Hexx_Data_DBF.FieldDefs do Hexx_Data_DBF_RecNo := Dataset.RecNo; to use the safer method of using bookmarks??? type { Thxboard } Thxboard = class(TForm) Hexx_Data_DBF: TDbf; var TraceFile_DBF_RecNo, Hexx_Data_DBF_RecNo : integer; [...] while (not Hexx_Data_DBF.EOF) and not found do begin if (pattern_is_db_current(pattern1)) then begin save_options(pattern1); found := true; //Hexx_Data_DBF_RecNo := Hexx_Data_DBF.RecNo; with Hexx_Data_DBF.FieldDefs do Hexx_Data_DBF_RecNo := Dataset.RecNo; close_db; if trace_moves then begin open_trace_file; With Trace_File_DBF do try // ### needs changing with Trace_File_DBF.FieldDefs do Dataset.RecNo := (TraceFile_DBF_RecNo); FieldByName('record_no' ).AsInteger := Hexx_Data_DBF_RecNo; //finally except showmessage( 'An exception occured in write_updated_pattern - writing to trace file.'); close_trace_file; end; end; open_db; // ### needs changing with Hexx_Data_DBF.FieldDefs do Dataset.RecNo := (Hexx_Data_DBF_RecNo); end; // ### needs changing Hexx_Data_DBF.Next; end; [...] -- Proudly developing Quality Cross Platform Open Source Games Since 1970 with a Commodore PET 4016 with 16 KRAM http://pews-freeware-games.org (<--- brand new)
procedure Thxboard.write_updated_pattern(var pattern1: pattern_type); var found: boolean; begin found := false; if pattern_is_db_current(pattern1) then { save pattern options to db } begin save_options(pattern1); // #### how do I do this //Hexx_Data_DBF_RecNo := Hexx_Data_DBF.RecNo; With Hexx_Data_DBF.FieldDefs do Hexx_Data_DBF_RecNo := Dataset.RecNo; close_db; if trace_moves then begin open_trace_file; With Trace_File_DBF.FieldDefs do try // #### needs changing Dataset.RecNo := (TraceFile_DBF_RecNo); Trace_File_DBF.FieldByName('record_no').AsInteger := Hexx_Data_DBF_RecNo; //finally except showmessage( 'Exception occured in write_updated_pattern. Writing to trace file.' ); close_trace_file; end; end; open_db; // #### how do I do this with Hexx_Data_DBF.FieldDefs do Dataset.RecNo := (Hexx_Data_DBF_RecNo); end else { save entire pattern to db }; begin while (not Hexx_Data_DBF.EOF) and not found do begin if (pattern_is_db_current(pattern1)) then begin save_options(pattern1); found := true; //Hexx_Data_DBF_RecNo := Hexx_Data_DBF.RecNo; with Hexx_Data_DBF.FieldDefs do Hexx_Data_DBF_RecNo := Dataset.RecNo; close_db; if trace_moves then begin open_trace_file; With Trace_File_DBF do try // ### needs changing with Trace_File_DBF.FieldDefs do Dataset.RecNo := (TraceFile_DBF_RecNo); FieldByName('record_no' ).AsInteger := Hexx_Data_DBF_RecNo; //finally except showmessage( 'An exception occured in write_updated_pattern - writing to trace file.'); close_trace_file; end; end; open_db; // ### needs changing with Hexx_Data_DBF.FieldDefs do Dataset.RecNo := (Hexx_Data_DBF_RecNo); end; // ### needs changing Hexx_Data_DBF.Next; end; if not found then begin with Hexx_Data_DBF do try With Hexx_Data_DBF.FieldDefs do begin Dataset.Append; { --- add a new record --- } save_options(pattern1); FieldByName( 'this_game' ).AsInteger := pattern.this_game; FieldByName('x1_pos' ).AsString := inttostr(pattern1.x_piece[1]); FieldByName('x2_pos' ).AsString := inttostr(pattern1.x_piece[2]); FieldByName('x3_pos' ).AsString := inttostr(pattern1.x_piece[3]); FieldByName('x4_pos' ).AsString := inttostr(pattern1.x_piece[4]); FieldByName('x5_pos' ).AsString := inttostr(pattern1.x_piece[5]); FieldByName('x6_pos' ).AsString := inttostr(pattern1.x_piece[6]); FieldByName('x7_pos' ).AsString := inttostr(pattern1.x_piece[7]); FieldByName('x8_pos' ).AsString := inttostr(pattern1.x_piece[8]); FieldByName('o1_pos' ).AsString := inttostr(pattern1.o_piece[1]); FieldByName('o2_pos' ).AsString := inttostr(pattern1.o_piece[2]); FieldByName('o3_pos' ).AsString := inttostr(pattern1.o_piece[3]); FieldByName('o4_pos' ).AsString := inttostr(pattern1.o_piece[4]); FieldByName('o5_pos' ).AsString := inttostr(pattern1.o_piece[5]); FieldByName('o6_pos' ).AsString := inttostr(pattern1.o_piece[6]); FieldByName('o7_pos' ).AsString := inttostr(pattern1.o_piece[7]); FieldByName('o8_pos' ).AsString := inttostr(pattern1.o_piece[8]); //Hexx_Data_DBF_RecNo := Hexx_Data_DBF.RecNo; Hexx_Data_DBF_RecNo := Dataset.RecNo; end; //finally except showmessage( 'An exception occured in write_updated_pattern - save entire pattern to db. Not found.'); close_db; end; if trace_moves then begin open_trace_file; with Trace_File_DBF do try With Trace_File_DBF.FieldDefs do begin // ### needs changing Dataset.RecNo := (TraceFile_DBF_RecNo); FieldByName('record_no').AsInteger := Hexx_Data_DBF_RecNo; Dataset.Post; end; //finally except close_trace_file; end; end; open_db; with Hexx_Data_DBF.FieldDefs do Dataset.RecNo := (Hexx_Data_DBF_RecNo); end; // if found end; // else end; { write_updated_pattern } {---------------------------------------------------------}
-- _______________________________________________ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus