Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 06/17/24 in all areas

  1. Uwe Raabe

    Variable might not have been initialized

    Reading the code despite of its irritating formatting reveals the problem: WorkOrdersSelectedRow := WorkOrdersGrid.Selection.Top; if FWorkOrderManager.GetWorkOrderDataByIndex(WorkOrdersSelectedRow - 1, Data) then // evaluates file index FileIndex := ARow - 1; if (FileIndex < 0) or (FileIndex >= TWorkOrderData.FILE_DATA_SIZE) then Exit; FileIndex will not be initialized when the if clause fails. BTW, it also irritates that the compiler is charged guilty first.
  2. JonRobertson

    Variable might not have been initialized

    👍 I set that compiler warning (and a couple others) as an Error in every project:
  3. JonRobertson

    Using same form for adding and editing data

    That sounds like much more code than necessary to me. I have a base form with a TDataSet field named StateDataSet and a virtual method called UpdateUIState. Each derived form assigns StateDataSet during FormCreate and overrides UpdateUIState to update the UI based on various conditions, such as TDataSet.State and user security for that form/data. Both the base form and the derived user form is "aware" of the record operation (view, insert, edit) by looking at StateDataSet.State. Every form has a ValidateForm method to ensure that required fields are provided and any referring data is valid before the record is posted. I avoid writing anything to the database unnecessarily. Adding a row temporarily that will be removed if the edit is canceled is wasteful network and disk I/O as well as increasing db index and page fragmentation. Some customers now use a "cloud hosted" database server, so database read/writes also have extra latency. Doing as much as possible in memory is a huge performance gain. I find it much easier to maintain a single form (per table/record). I don't have to take the time to update two or three forms when changes are needed and ensure that the implementation is consistent across multiple forms/units. FWIW, my data edit forms have a lot of common functionality that is implemented in the base form, not just StateDataSet and UpdateUIState.
  4. Hi Everyone, My name is Tim and have been using Pascal forever (among other languages) since the 90s. For a variety of reasons I've transitioned (/transitioning) into tutoring and mentoring, and have launched a YouTube channel dedicated to all things Delphi. My first video, "Starting an Adventure with Delphi," is here - In the future, I'm planning to cover a range of topics, including: - Building modern Delphi applications for FireMonkey - Essential data structures for Delphi developers - Tips for debugging those tricky Delphi problems I'm really passionate about keeping Delphi alive and well. Whether you're a complete beginner or a seasoned developer looking to brush up your skills, I hope you'll find something valuable on my channel. Let me know what you think - especially if you have any topic suggestions!
  5. Remy Lebeau

    Quality Portal going to be moved

    In the new system: https://qp.embarcadero.com Tickets from the old system have not been migrated over (yet?). Nope, but you can order by issue number, which are presumably sequential (or close to it). Nope. There are no "boards" in the new system. What I find funny is that I have filed 7 new tickets in the new system, but when I search for tickets "Where I am a participant", nothing shows up, but tickets "Created by me" do.
  6. Missing documentation category? Right when we assumed it was the first thing on a developer's mind 😉 Thank you @Jim McKeeth Looking forward to the follow-up!
  7. Die Holländer

    Variable might not have been initialized

    Like DelphiLint (shameless promotion..) advise you to do..
  8. Rollo62

    Variable might not have been initialized

    Yees, thats a nasty bug. Thats why I had choosen long time ago, to always add a proper scope around even the simplest lines. if FWorkOrderManager.GetWorkOrderDataByIndex(WorkOrdersSelectedRow - 1, Data) then begin // evaluates file index FileIndex := ARow - 1; end; IMHO that increases readability and avoid a lot of such hard to see errors. You're lucky here, that the compiler throwed a warning 🙂
  9. I've added HelpNDoc to the overall list of the survey https://forms.gle/xuFWpSrE5TDdordNA I somehow missed the documentation category, so I'll need to do a follow up, but still good to go out and vote for it overall.
  10. JonRobertson

    Using same form for adding and editing data

    I wouldn't use a separate flag unless necessary. If you are using a TDataSet descendent, you can look at the State property to determine whether the record is being inserted (State = dsInsert) or edited (State = dsEdit). If it is necessary to call Post in code, you can use if ds.State in dsEditModes to determine if the current record needs to be posted.
  11. I have a strange warning in compilation with Sydney 10.4.1 that I just can't understand: procedure TWorkOrderListFrame.WorkOrderFilesGridDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var R: TRect; C: TColor; Value: string; Canvas: TCanvas; PenColor: TColor; BrushColor: TColor; FileIndex: Integer; Data: TWorkOrderData; BackgroundColor: TColor; WorkOrdersSelectedRow: Integer; begin // avoids any change at header row if ARow = 0 then Exit; // checks and gets work order data WorkOrdersSelectedRow := WorkOrdersGrid.Selection.Top; if FWorkOrderManager.GetWorkOrderDataByIndex(WorkOrdersSelectedRow - 1, Data) then // evaluates file index FileIndex := ARow - 1; if (FileIndex < 0) or (FileIndex >= TWorkOrderData.FILE_DATA_SIZE) then Exit; if Data.FileData[FileIndex].FileName = '' then Exit; // recovers canvas Canvas := WorkOrderFilesGrid.Canvas; [dcc64 Warning] osWorkOrderListFrame.pas(946): W1036 Variable 'FileIndex' might not have been initialized The line with the warning is: if (FileIndex < 0) or (FileIndex >= TWorkOrderData.FILE_DATA_SIZE) then Exit; but FileIndex is set just the line above.... Any idea ?
×