Ian Branch
Members-
Content Count
1352 -
Joined
-
Last visited
-
Days Won
3
Everything posted by Ian Branch
-
Are Valid Dates?
Ian Branch replied to Ian Branch's topic in Algorithms, Data Structures and Class Design
As you suggest, one solution is not necessarily the answer for all circumstances. I had considered various options and this was what I considered an appropriate solution. 😉 I had two considerations.. 1. Are either of the date fields NULL; and 2. If they weren't, are they properly constituted date(s). This mechanism gave me coverage for both. It is a little of 'Belts & Braces' as the date entries are via TDateTimePickers. From here, if all good, various 'validity/comparison' checks are done, if they fail the User is sent back to correct the date(s) as appropriate. Thank you for your input. Regards, Ian -
Yup. My error was in the {$IFDEF.... rather than having {$IF..... This is all good now. // {$IF not(defined(Hello)) and not(defined(Bellow)) and not(defined(Yellow))} ShowMessage('{$IF...'); {$ENDIF} // {$IF not(defined(Hello)) and not(defined(Bellow)) and not(defined(Yellow)) and not(defined(Users))} ShowMessage('{$IF...'); {$ENDIF} // Tks for the pointers, this works as expected now. The first shows, the second doesn't. Regards, Ian
-
OK. So I have missed some nuance... I have the following test code with Users defined... {$IFDEF Users} ShowMessage('{$IFDEF...'); {$ENDIF} // {$IFNDEF Hello || Bellow || Yellow || Users} ShowMessage('{$IFNDEF...'); {$ENDIF} And I have Complete Boolean Evaluation set to True. Yet I get both messages... This works.. {$IFDEF Users} ShowMessage('{$IFDEF...'); {$ENDIF} // {$IFDEF not(defined(Hello)) or not(defined(Bellow)) or not(defined(Yellow)) or not(defined(Users))} ShowMessage('{$IFNDEF...'); {$ENDIF} Although my mind says it should be Hello not defined AND Bellow not defined AND Yellow not defined AND Users not defined. i.e. none of the defines are defined... If I now make it... // {$IFDEF Users} ShowMessage('{$IFDEF...'); {$ENDIF} // {$IFDEF not(defined(Hello)) and not(defined(Bellow)) and not(defined(Yellow)) and not(defined(Users))} ShowMessage('{$IFNDEF...'); {$ENDIF} // And I have Complete Boolean Evaluation set to False. On that basis, I should get both messages with.. // {$IFDEF Users} ShowMessage('{$IFDEF...'); {$ENDIF} // {$IFDEF not(defined(Hello)) and not(defined(Bellow)) and not(defined(Yellow))} ShowMessage('{$IFNDEF...'); {$ENDIF} // But no, only the first one. Interesting stuff.
-
Thank you gentlemen for both your solutions. Much appreciated. FPiette - I didn't realize a NOT could be applied that way. emailx45 - Sneaky, and another thing I have learnt. A day where nothing is learnt is a day wasted... Regards & All the best for 2021. Ian
-
Hi Team, I couldn't find where to report this to Uwe so here I am.. D10.4.1, Win 10, 32bit. I downloaded what I believe is the latest UsesCleaner.zip, built it and tried it on an App. It appeared to do the right thing producing this.. unit MainFrm; interface uses System.SysUtils, System.StrUtils, System.UITypes, System.TimeSpan, System.ImageList, vcl.wwdbgrid, vcl.Buttons, vcl.Grids, vcl.wwdbigrd, vcl.DBCtrls, vcl.ImgList, Windows, Messages, Variants, Classes, Graphics, Controls, Unfortunately, when I went to build my project I got this error.."[dcc32 Error] MainFrm.pas(326): E2010 Incompatible types: 'NativeUInt' and 'TSearchRec'" on this line.." FindClose(sr);" in this code.. procedure FillFiles(Strings: TStrings; const strDirectory: string); var sr: TSearchRec; begin if FindFirst(strDirectory + '\*.tbl', faAnyFile, sr) = 0 then try Strings.BeginUpdate; try Strings.Clear; repeat Strings.Add(sr.Name); until FindNext(sr) <> 0; finally Strings.EndUpdate; end; finally FindClose(sr); end; end; After some head scratching and trying various things I eventually changed the order of the uses clause to this... unit MainFrm; interface uses Windows, System.SysUtils, System.StrUtils, System.UITypes, System.TimeSpan, System.ImageList, vcl.wwdbgrid, vcl.Buttons, vcl.Grids, vcl.wwdbigrd, vcl.DBCtrls, vcl.ImgList, Messages, Variants, Classes, Graphics, Controls, Note the relocation of the Windows, The App now builds and runs fine. Is this a bug with UsesCleaner or Delphi?? Regards, Ian
-
That will do it every time. ;-)
-
Hi Uwe, I have a project Group with 18 projects, including DBiWorkflow. I ran UsesCleaner over the group. 1. Edited .cfg to make Compressed = 0 & GroupNames empty - No issues building or running the Apps. 2. Edited .cfg to make Compressed = 1 - No issues building or running the Apps. 3. Edited the GroupNames back in. - No issues building or running the Apps. Attached for your reference is the DBiWorkflow.dpr and the UsesCleaner.cfg from this exercise. Thank you. Regards, Ian UsesCleaner.cfg DBiWorkflow.dpr
-
Sure. I suspect that is not all involved though. Here you go. DBiWorkflow.dpr
-
Hi Team, I have similar code to below in several places // pBlob := dmC.jtImages.CreateBlobStream(dmC.jtImages.FieldByName('JTImage'), bmWrite); // try pBlob.Seek(0, soFromBeginning); // fsFile := TFileStream.Create(sFileName, fmOpenRead or fmShareDenyWrite); try pBlob.CopyFrom(fsFile, fsFile.Size); finally fsFile.Free end; finally pBlob.Free end; // end else begin MessageBeep(MB_ICONERROR); TaskMessageDlg('File not found!', 'File ' + sFileName + ' not found!', mtError, [mbOK], 0); pBlob.Free; end; pBlob is declared as a TStream. I consistently get the following error message.. "[dcc32 Warning] XXXXXFrm.pas(1213): W1036 Variable 'pBlob' might not have been initialized" pointing to the last pBlob.Free; I know it is only a Warning but it is annoying in an otherwise clean compile/build. What am I missing? How do I rectify this please? Regards & TIA, Ian
-
Hi emailx45. Yes, I have those safeguards, including checking and limiting the image file type/size. Only .jpg or .jpeg & <256kB.
-
Interesting. I retyped the line and it, Delphi, is happy now.
-
Hi amailx45, Interesting. That would not have occurred to me in a million years. Slight problem.. Delphi doesn't like it. :-( SFileName is an undeclared identifier... Ian
-
OK. My thanks to emailx45 for getting me on the right track & overcoming my laziness. 😉 My above code has been condensed to... // (dmC.jtImages.FieldByName('JTImage') as TBlobField).LoadFromFile(sFileName); // Thank you. Regards, Ian
-
Actually I just discovered why I was getting the messages. I was doing a Free of pBlob at the end of the "if FielExists(sFileName) then ..." and of course nothing had happened with pBlob at that time. My Bad. Thanks for looking. Ian
-
Hi emailx45, My apologies. I thought the code was fairly generic and therefore wouldn't need further clarification. My Bad. 😞 D10.4.1, ElevateDB. In this case jtImages is an ElevateDB Table Blob field. Yes, dmC is a datamodule. I am guilty of simple cut & paste when I incorporated my code. I note your alternative code. TBlobStream appears to be an element of the BDE, which I don't have installed. Ian
-
HI Uwe, I hadn't, but now did. It still made the project unusable. Whilst there may be a convention about the structure of the Uses clauses, one-line per, I'm not fussed. ;-) When I loaded the Project, the 'ProjectGroup' had gone from attached screenshot_4 to screenshot_3. :-( Don't sweat it. It was just a thought bubble. Regards, Ian
-
@Uwe Raabe What's the chances of UsesCleaner being able to process .dpr files?? Just a thought bubble... ;-) Ian
-
Hi Team, I came across this by accident... http://www.delphiarea.com/products/delphi-packages/assistant It hasn't been touched in years. Does anybody know of something similar and more recently supported? I am using D10.4 att. Regards & TIA, Ian
-
Agreed. Quite interesting. The consensus thus far for the 'tool' would seem to be it is more of academic value than production.
-
Hi Anders, Thanks for the feedback. I can certainly see how it would be useful in some sort of training environment. ATT as I learn about it I have only implemented in its basic form as a novelty thing when closing the App. Applicability to other areas is still in question. IIUC it isn't going to work as is under Win 7 so that will be a road block. I had a look at DoubleAgent but it appears the animations are no longer available. Anyway, it is still a learning exercise for me, even if it isn't used in the end. Regards, Ian
-
BTW, it doesn't have to be this 'Clippy' thing, it is the concept of some sort of animated prompt that interests me.
-
Hi Anders & Remy, Thank you both for your responses. Very informative. I'm afraid things like TAgent, MSAgent ActiveX & MSAgent Server are not things I have any knowledge of. This 'Clippy' thing is something I am playing with att and if it is appropriate it will be on Win 7 PCs. Customer refuses to update. I see the note/reference about Double Agent. I will have a look. Are there any limitations/expectations to its use? I am hoping it will be OS/App agnostic, aside from being Windows based. Regards & Tks again. Ian
-
Hi Team, I need to prevent Users from actually editing, including deleting, a TComboBoxEx whilst still allowing the contents to be changed via the drop-down. The component's OnChange event fires whenever they do something in the field. The component doesn't have a Read-Only property. This might get in the road of the drop-down working, so what do I do? Regards & TIA, Ian
-
No shame involved. I suspect ALL programmers are guilty of this more than once. ;-)
-
Just to close this off. I did a complete D10.4.1 De/Re. All good now.