Jump to content

Gary

Members
  • Content Count

    137
  • Joined

  • Last visited

Community Reputation

18 Good

Technical Information

  • Delphi-Version
    Delphi 12 Athens

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Gary

    More Powerful Grid

    https://www.rosinsky.cz/delphi/dbgrid.html especially used with https://www.rosinsky.cz/delphi/dbactions.html
  2. Gary

    Help with TFDBatchMove fields

    A little more reading: Documentation: procedure GuessFormat(AAnalyze: TFDBatchMoveAnalyze = [taDelimSep, taHeader, taFields]); Another option is to use the Analyze property. When Analyze is not empty, the GuessFormat method is automatically called by the Execute method. taFields worked for me. Setting the property or passing in the GuessFormat parameter works the same. bmTest2.Analyze := [taFields]; // bmTest2.GuessFormat([taDelimSep]); bmTest2.Execute; If any has problems understanding what's going on maybe my mistakes will help. Firstly what is happening in the WriteValue event. I kept trying to access the Source values in the AItem Var. I looked at the event as saying the AValue var is empty, you need to get the value from the source, perform any conversions and load into AValue. Also, I had no experience with Variants, so when I continually got A/V when accessing the AItem.Source values I thought it had something to do with the way I was access the Variant. What happens and makes perfect sense after a little thought is The AValue is already loaded and the TFDBatchMove has performed the conversion, now you can determine the DataType according to what is expected in the AItem.DestinationField and any further processing can be done. In my case TFDBatchMove was trying to convert an unexpected value '--' to a Time DataType. I had to fix the problem upstream, when the GuessFormat procedure was changing the String field to Time. Wierdo12 helped with the suggestion of resetting the field type after the GuessFormat call. I think that Analyze property or GuessFormat with the taField value may not change the DataType, I was calling it with empty param. We'll see.
  3. Gary

    Help with TFDBatchMove fields

    TFDBatchMove.Analyze.Clear Does not compile. There is an AnalyzeSample Integer property that can be set -1 or 0; Things are working well without it though.
  4. Gary

    Help with TFDBatchMove fields

    @wierdo12 Those examples really helped, thanks! Adding code to the events really slowed the import down, but at least it's working. I'll take out the logging and see how it goes. I didn't realize that GuessFormat actually changed field defs. I was executing it in design mode and that's what was keeping the date field in the dfm as I would save after running in design mode. So these changes worked: Reset my fields after Guess changes them bmFleetDay.GuessFormat; txrdrFleetDayData.DataDef.Fields[13].DataType := atString; txrdrFleetDayData.DataDef.Fields[13].FieldSize := 15; txrdrFleetDayData.DataDef.Fields[26].DataType := atString; txrdrFleetDayData.DataDef.Fields[26].FieldSize := 15; { TODO : Surround with exception handler } result := bmFleetDay.Execute <> 0; procedure TdmLocations.bmFleetDayWriteValue(ASender: TObject; AItem: TFDBatchMoveMappingItem; var AValue: Variant); begin if (AItem.DestField.FieldName = 'StartTime') or (AItem.DestField.FieldName = 'ArrivalTime') then if not VarIsNull(AValue) then if AValue = '--' then begin SiMain.LogMessage(Format('Field: %s Value: %s', [AItem.DestField.FieldName, AValue])); FSkipRecord := True; end; end; Skip record procedure TdmLocations.bmFleetDayWriteRecord(ASender: TObject; var AAction: TFDBatchMoveAction); begin if FSkipRecord then begin SiMain.LogMessage('Skipping Record'); AAction := paSkip; FSkipRecord := False; end; end; I think I'll track skipped records and show user a message with count of corrupted rows Thanks again for the help
  5. Gary

    Help with TFDBatchMove fields

    I had difficulty understanding how to use the events and couldn't find any examples. I found the help to be vague even the parameters. I did find a commercial product from scalabium.com the import component has this event: Declaration property OnBeforeRecordEvent: TBeforeRecordEvent; Description This event allow to define global values for each parsed value before applying to fields. Also here you can skip some row from loading (just by your custom condition). The Fields parameter is a list of parsed field names. The Values parameter is a variant array with parsed value for each field name. To skip a row from loading just assign a False value to Accept parameter. By default the Accept is True. Looks like exactly what I need! I can just skip the offending record, even log and display how many were skipped. 50 EUR with source. I'll post how it goes. Thank you both for the help I will still experiment with your advice
  6. Gary

    Help with TFDBatchMove fields

    Yes, get crazy results if not
  7. Gary

    Help with TFDBatchMove fields

    Thank You
  8. Gary

    Help with TFDBatchMove fields

    I have found TFDBatchMove to really be troublesome, probably my ignorance, I would like to be able to control a fields import and am sure one of the properties let you do this but have been unable to find any understandable documentation or examples. It seems that everyone has their own csv import component, so the lack of some public getit project seems odd. I guess I'll have to roll my own as well
  9. I have an app that has been working fine for some time. I use a TFDBatchMove to import csv info from a GPS provider. Recently one vehicle's hardware malfunctioned and now for those 3 days the value in the 'Arrival Time' field has '--' instead of a time value. Not a big deal, I can deal with it in code, the problem is I can't get the TFDBatchMoveTextReader to let this field change to atString. I have changed it everywhere I can think of and even removed and added it back I still get this error when executing the TFDBatchMove "Bad Text value [--] format for mapping item [Arrival Time]. '--' is not a valid time. The changes I have made: TFDBatchMoveTextReader Fields Changed 'Arrival Time' to atString with FieldSize 15. TFDBatchMoveDataSetWriter is set to a Virtual table vtRawDayData. I changed it's field 'ArrivalTime' to TStringFiels Size 15, Made sure it's fieldDefs was set properly as well. csv field is 'Arrival Time' with space vtRawDatDate field is 'ArrivalTime' no space and works fine if I delete the offending rows from the csv I still get the time format error Any ideas short of deleting and redoing the whole chain of components? The offending dates are in September and each week I download the full extent of their allowable data (4 months), The oldest date is in June currently, so even though it's not a big deal to edit out those dates I have to do it each week until I get past September 7-9. Of course if it happens again I would like to already have dealt with it in the app.
  10. Gary

    MyDAC : Unknown column error

    +1 for JonRobertson & ertank I use UniDac as well and you use the "AddField" Menu selection not the "NewField" Menu. I am always forgetting to set the Options.KeepDesignConnected property as well.
  11. Gary

    Advise the component for editing tables

    @Shrinavat Looks great! Years ago I used X-Data and one thing I miss is the master Detail in grid. Looks like Steema has this, and at an affordable price. While the Rosinsky DBGrid is very capable the show stopper for me are the Dialogs that he has produced. Your end users can customize the grid at runtime as much as you can at design time. Extremely impressive.
  12. Gary

    Advise the component for editing tables

    Not Free only $70.00 and includes source Delphi and C++ Builder VCL components - DBGrid, DBTreeView, DBCheckListBox, StringGrid, HTML Label, HTML ListView (rosinsky.cz)
  13. Compare your library path for 32 and 64 bit components Tools->Options->Language->Delphi->Library
  14. From FastMM --------------------------------2023/12/28 22:32:03-------------------------------- A memory block has been leaked. The size is: 84 This block was allocated by thread 0x6A4, and the stack trace (return addresses) at the time was: 9371E6 [System.pas][System][@GetMem$qqri][4960] 938957 [System.pas][System][TObject.NewInstance][18324] 93905A [System.pas][System][@ClassCreate$qqrpvzc][19654] 9F9C30 [System.Classes.pas][System.Classes][Classes.TStringList.Create][8121] 94C231 [FastMM4.pas][FastMM4][UpdateHeaderAndFooterCheckSums$qqrp29Fastmm4.TFullDebugBlockHeader][9153] 94D214 [FastMM4.pas][FastMM4][DebugGetMem$qqri][9731] EA116F [int.PsFNCTaskDialogUIListener.pas][Int.PsFNCTaskDialogUIListener][Psfnctaskdialoguilistener.TTaskDialogParams._op_Initialize][66] 108E6E5 [PsFNCTaskDialogUIListener.pas][PsFNCTaskDialogUIListener][TPsFNCTaskDialogUIListener.SetDialogParams][32] 108E827 [PsFNCTaskDialogUIListener.pas][PsFNCTaskDialogUIListener][TPsFNCTaskDialogUIListener.ExecuteDialog][47] 108F3C9 [USender.pas][USender][TfrmSender.tbtnTaskDialogClick][77] C0CF34 [FMX.Controls.pas][FMX.Controls][Controls.TControl.GetHeight][5512] The block is currently used for an object of class: System.Classes.TStringList The allocation number is: 296325 Current memory dump of 256 bytes starting at pointer address 7E6DB770: 20 B9 9C 00 00 00 00 00 50 B9 30 7F 6C E3 1B 7F 00 00 00 00 00 00 00 00 2C 00 22 00 3D 00 0E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 8C AF 78 80 80 80 80 80 80 80 80 00 00 00 00 51 BB 6D 7E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 88 85 04 00 9F A8 93 00 3C AD 93 00 A2 CC 93 00 F2 E6 08 01 27 E8 08 01 C9 F3 08 01 34 CF C0 00 9D AB C0 00 77 D6 CB 00 F4 B2 C0 00 D4 65 E8 00 A4 06 00 00 A4 06 00 00 02 72 93 00 59 A9 93 00 28 C5 93 00 E2 D3 C0 00 39 8B 93 00 6E 89 93 00 A5 90 93 00 2E 9A CB 00 B3 57 E5 00 ED 92 93 00 45 C0 E8 00 48 00 00 00 B0 04 02 00 CB 3D A4 8E 8C 7C 0C 01 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 . . . . . P 0 l . . . . . . . . . , . " . = . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x . . . . Q m ~ . . . . . . . . . . . . . . . . . . . < . . . . ' . . . . 4 . . w . . e . . . . . . . . r . Y . ( . . 9 . n . . . . W . . E . H . . . . . . = | . . --------------------------------2023/12/28 22:32:03-------------------------------- A memory block has been leaked. The size is: 20 This block was allocated by thread 0x6A4, and the stack trace (return addresses) at the time was: 9371E6 [System.pas][System][@GetMem$qqri][4960] 93A89F [System.pas][System][@NewUnicodeString$qqri][26024] 93AD3C [System.pas][System][@UStrAsg$qqrr20System.UnicodeStringx20System.UnicodeString][26946] 9F6F30 [System.Classes.pas][System.Classes][Classes.TStrings.Create][6729] 9F9C3D [System.Classes.pas][System.Classes][Classes.TStringList.Create][8122] 94D214 [FastMM4.pas][FastMM4][DebugGetMem$qqri][9731] EA116F [int.PsFNCTaskDialogUIListener.pas][Int.PsFNCTaskDialogUIListener][Psfnctaskdialoguilistener.TTaskDialogParams._op_Initialize][66] 108E6E5 [PsFNCTaskDialogUIListener.pas][PsFNCTaskDialogUIListener][TPsFNCTaskDialogUIListener.SetDialogParams][32] 108E827 [PsFNCTaskDialogUIListener.pas][PsFNCTaskDialogUIListener][TPsFNCTaskDialogUIListener.ExecuteDialog][47] 108F3C9 [USender.pas][USender][TfrmSender.tbtnTaskDialogClick][77] C0CF34 [FMX.Controls.pas][FMX.Controls][Controls.TControl.GetHeight][5512] The block is currently used for an object of class: UnicodeString The allocation number is: 296326 Current memory dump of 256 bytes starting at pointer address 7F1BE360: B0 04 02 00 01 00 00 00 02 00 00 00 0D 00 0A 00 00 00 AA 4B E7 F7 80 80 00 00 00 00 A1 FF 1B 7F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5F BF 04 00 E6 71 93 00 57 89 93 00 5A 90 93 00 7F 21 E8 00 12 EE E8 00 31 8A E8 00 1F 40 E8 00 63 40 E8 00 6E EE E8 00 62 DF A0 00 6B 8A 93 00 A4 06 00 00 A4 06 00 00 02 72 93 00 75 89 93 00 A5 90 93 00 E5 21 E8 00 6B 8A 93 00 35 38 E8 00 02 72 93 00 75 89 93 00 A5 90 93 00 F7 10 A8 00 6B 8A 93 00 14 00 00 00 DC E2 E6 00 4C 29 7E 8F 8C 7C 0C 01 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 B3 D6 81 70 00 00 00 00 C1 E9 1B 7F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 9F BF 04 00 E6 71 93 00 57 89 93 00 5A 90 93 00 73 35 E3 00 1B 35 E3 00 51 C4 E2 00 13 C5 E2 00 3E 3F E8 00 D1 F1 E8 00 0A 3A E8 00 02 72 93 00 . . . . . . . . . . . . . . . . . K . . . . . . . . . . . . . . . . . . . . . _ . . q . W . Z . ! . . . 1 . . @ . c @ . n . b . k . . . . . . . . r . u . . ! . k . 5 8 . . r . u . . . . k . . . . . . L ) ~ | . . p . . . . . . . . . . . . . . . . . . . . . . . q . W . Z . s 5 . . 5 . Q . . . > ? . . . : . . r . --------------------------------2023/12/28 22:32:03-------------------------------- This application has leaked memory. The small block leaks are (excluding expected leaks registered by pointer): 13 - 20 bytes: UnicodeString x 1 69 - 84 bytes: System.Classes.TStringList x 1 Note: Memory leak detail is logged to a text file in the same folder as this application. To disable this memory leak check, undefine "EnableMemoryLeakReporting".
  15. Sorry copied same block twice Here is the other part procedure TPsFNCTaskDialogUIListener.SetDialogParams(Params: TTaskDialogParams); begin ClearDialog; FTaskDialog.Title := Params.Title; FTaskDialog.Instruction := Params.Instruction; FTaskDialog.Icon := TTMSFNCTaskDialogIcon(Params.Icon); FTaskDialog.Options := TTMSFNCTaskDialogOptions(params.Options); for var s : String in params.CustomButtons do FTaskDialog.CustomButtons.Add(s); end;
×