-
Content Count
550 -
Joined
-
Last visited
-
Days Won
11
Everything posted by corneliusdavid
-
Delphi Daily WTF / Antipattern / Stupid code thread
corneliusdavid replied to Tommi Prami's topic in RTL and Delphi Object Pascal
I recently inherited an old project that had many bad code examples that looked like whenever anyone made a change to the code, they just left it like they found it instead of refactoring. There were empty IF-blocks, while-true loops, exit statements one line before the end of a procedure, and one of my favorites: for j := 0 to 0 do begin Temp := StartTop[j] + CompRow; CreateLabel(CNameL[j], LeftSide - 4, Temp, 150); ... All of these were in that ONE project. But the worst code in that I found in that project was a bunch of GOTOs: function BlankControl(EditControl: TObject; const EditMess: string; ShowErrorMsg: Boolean; MaxLen: Integer): Boolean; label 900, 1000; begin if EditControl is TCustomEdit then if length(trim((EditControl as TCustomEdit).Text)) < MaxLen then goto 1000 else goto 900; if EditControl is TComboBox then if length(trim((EditControl as TComboBox).Text)) < MaxLen then goto 1000 else goto 900; if EditControl is TDBComboBox then if length(trim((EditControl as TDBComboBox).Text)) < MaxLen then goto 1000 else goto 900; if EditControl is TDBRadioGroup then if ((EditControl as TDBRadioGroup).Value = '') then goto 1000 else goto 900; if EditControl is TDBLookupComboBox then if ((EditControl as TDBLookupComboBox).Text = '') then goto 1000 else goto 900; if EditControl is TDBCheckBox then if ((EditControl as TDBCheckBox).State = cbGrayed) then goto 1000 else goto 900; 900: Result := false; exit; 1000: Result := true; Showerror(EditControl, EditMess, false, ShowErrorMsg); end; -
For converting VCL to FireMonkey, the only tool I know if is Mida Converter. Disclaimer: I have not used it myself, so don't know how well it works. I don't use grids as often in mobile apps as I do in desktop apps, which is mostly what I use FireMonkey for so far, but I've had good success hooking up TGrid to datasets with LiveBindings.
-
Ah! TAdvMainMenu! That explains it. I was thinking that didn't look like the regular TMainMenu. My attempt to replicate it also failed.
-
It would help if you showed the code that you tried. You could also create one sub-menu at design-time, then look at the text view of the .dfm to see all the properties it sets to give you a clue.
-
Nice, that works pretty well. (You accidentally listed the URL twice so you might want to edit your post and correct it.) Why did you include the DelphiEncryptionCompendium units? Was that just to test? They aren't really needed for the functionality of the app. It'd be cool if there was a search button so you could quickly find a specific class in the huge generated list.
-
Disable & re-Enable a Procedure
corneliusdavid replied to Henry Olive's topic in RTL and Delphi Object Pascal
True. -
Disable & re-Enable a Procedure
corneliusdavid replied to Henry Olive's topic in RTL and Delphi Object Pascal
Lajos, Yes, but if you're enabling/disabling from within the data module you don't need to preface it with the variable name. -
Disable & re-Enable a Procedure
corneliusdavid replied to Henry Olive's topic in RTL and Delphi Object Pascal
So I gather you have a data module with an Orders table or query where one of the fields is DOCNO and you double-clicked on the OnChange event handler in the Object Inspector to create the procedure. So to clear it at runtime in code you would clear the OnChange property of the DOCNO field. In other words, you were very close: dm.Orders.DOCNO.OnChange := nil; And you would hook it back up again by reassigning the created procedure name: dm.Orders.DOCNO.OnChange := OrdersDOCNOChange; -
Can one include a TDataModule in a console application?
corneliusdavid replied to RaelB's topic in VCL
Yes, absolutely! If you want to write a server app or a web module, this is the best way to go as debugging a console app is very simple and the data module can be shared between the two projects. I do this quite frequently. Here's a sample console project loading a data module: program ConsoleProjectTest; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, udmUnit1 in 'udmUnit1.pas' {dmUnit1: TDataModule}; begin try dmUnit1 := TdmUnit1.Create(nil); try // do stuff with data module finally dmUnit1.Free; end; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end. Hope that helps! -
Before you go to too much work, you might want to read this blog if you haven't already. If you really need to convert this C# code, it would be helpful to see more of the definitions of the object types but here's a first stab... var tblProp: TableProperties; TopBord: TopBorder; BotBord: BottomBorder; // ... begin TopBord := TopBorder.Create; TopBord.Val := BorderValues.Dashed; TopBord.Size := 24; BotBord := LeftBorder.Create; BotBord.Val := BorderValues.Dashed; BotBord.Size := 24; // etc. tblProp := TableProperties.Create(TableBorders.Create(TopBord, BotBord... If the xxxBorder classes have parameterized constructors, it would look closer to C#: var tblProp: TableProperties; begin tblProp := TableProperties.Create(TableBorders.Create( TopBorder.Create(BorderValues.Dashed, 24), BottomBorder.Create(BorderValues.Dashed, 24), LeftBorder.Create(BorderValues.Dashed, 24), RightBorder.Create(BorderValues.Dashed, 24), InsideHorizontalBorder.Create(BorderValues.Dashed, 24), InsideVerticalBorder(BorderValues.Dashed, 24)));
-
Problems with Delphi "Mobile Tutorial: Using FireDAC and SQLite (iOS and Android)"
corneliusdavid replied to peteSW's topic in Databases
I just downloaded the sample shoplist database and opened it in SQLiteStudio and the table is empty. Perhaps add some records outside of your app, then if your app is still not showing anything, you'll know something is amiss in your data connection or LiveBindings. When making changes to a view that don't appear to affect the display on your phone, try changing a different view or adding a label to the master view. When I was getting up to speed with mobile development, there would be times I thought for sure I was modifying the right view only to find out the phone was a different size than I expected or I had inadvertently switched views. Once you verify what view to use, you shouldn't need to uninstall the app--it'll update it. -
I wrote my own "App Usage" server using PHP with data stored in MySQL. My app simply makes an HTTP POST call to the PHP script. It's pretty simple, but so are my needs. That may not be what you want but it's one idea.
-
Which setting enables this feature?
corneliusdavid replied to aehimself's topic in Delphi IDE and APIs
You're on the right screen: it's Code parameters. The Delay affects how quickly the tooltip will appear (or at least that's the idea--it doesn't display at all for me automatically if the delay is anything but "None"). You can always manually activate it by hitting Ctrl+Shift+Space. -
SQL expression evaluation not supported
corneliusdavid replied to Henry Olive's topic in RTL and Delphi Object Pascal
Yes, IB uses "simple" case. Try this: SELECT O.DELVTYPE, SUM(OD.REMAINQTY) QTY, (Case O.DELVTYPE When 'Sea' then O.DELVDATE + 45 else O.DELVDATE + 15 end) as DELVDATE FROM ORDETAIL OD JOIN ORDERS O ON O.RNO=OD.RNO WHERE OD.ITEMNO = 'ABX22' GROUP BY O.DELVTYPE, O.DELVDATE HAVING SUM(OD.REMAINQTY) > 0 -
I've got a small WebBroker application that requests the user to choose a file which is then posted to another page of the WebBroker application. The web form's HTML is like this: <form action="UploadFile" method="post" enctype="multipart/form-data"> <label for="MyFile">Select file to upload:</label><br /> <input type="file" id="MyFile"> <button type="submit">Upload</button> </form> The TWebApplicationItem that handles the "/UploadFile" path is trying to get the file to upload so it can save it on the server but I can't find documentation or an example of how to do this. I've tried looking at both TRequest.ContentFields and TRequest.Files properties but they're always empty. I found an old StackOverflow question relating to this that mentioned including the ReqMulti unit so that it parses the multi-part form but that didn't fill the Files property for me. Finally, I called Request.ExtractContentFields but it just gave me the same raw string, ('------WebKitFormBoundaryBRM3RcInbYBqzsVj--') that I saw in the TRequest.Content property. From what I've been reading, I should be able to create a TFileStream and somehow use the Content property to read the file from the headers but I'm not sure how to get the file information. Can someone point me in the right direction?
-
Getting uploaded file from post data
corneliusdavid replied to corneliusdavid's topic in Network, Cloud and Web
Re-reading the StackOverflow question and looking more closely at my HTML, I realized I was missing the name attribute in the input element. Now my Files property is being filled and I can save the uploaded file. 🙂 <form action="UploadFile" method="post" enctype="multipart/form-data"> <label for="MyFile">Select file to upload:</label><br /> <input type="file" id="MyFile" name="MyFile"> <button type="submit">Upload</button> </form> -
Wow--OK. This is more confusing than I first thought--I have more study to do on this! Thanks for pointing that out.
-
@Dave Nottage, thanks for that explanation. To further clarify my situation and after looking at my project again, my target SDK is only at 25.2.25 so while that works on my Android 11, it doesn't support all the newest features of Android API 30.
-
All I know is that it is working very well for me. I've got a Delphi app on my Android 11 phone that I actively use and it works well.
-
Delphi License Registration
corneliusdavid replied to Randall Carpenter's topic in Delphi IDE and APIs
Registering a serial number too many times is one problem--and easily solved by requesting a registration number bump. However, your second sentence indicates a different problem: You have too many copies of Delphi running with the same serial number. I believe the max is 2. I run into this once in a while if I leave Delphi up in a virtual machine and switch to a different VM to check a different project. If I forget to close one of them down and then leave the office with my laptop and try to use Delphi on that, I get the warning and have to remote into one of the VMs and close one down. So, using your second serial number to register a second copy of Delphi should solve your problem. And to answer your question, no, registering Delphi does not affect third party packages. -
Sometimes this happens to me as well but then I realize I had a file open from a different project or the line of code was excluded because of conditional compilation of some sort. Other times, the background compiler that does syntax checking just hasn't realized the line of code is able to be debugged; in that case, I just do a project Build All and it often solves the problem.
-
[Android][FMX] Which solution to have a full size app icon with Android 10?
corneliusdavid replied to Fabian1648's topic in FMX
I presume you've tried going into Project > Options > Application > Icons and setting all listed resolution image filenames under the Launcher, Notification, and Splash Images tabs? -
It's in my copy of Delphi 10.4 where I would expect: \source\fmx\FMX.Graphics.pas $(BDSLIB)\$(Platform)\release
-
Win64 Starting an external exe and capturing the standard output text...
corneliusdavid replied to Roger Cigol's topic in General Help
Yes, DosCommand has both Delphi and C++ Builder packages to do exactly what you need. -
Interbase license bound to specific computer?
corneliusdavid replied to Joe Sansalone's topic in Databases
There are several different licenses for different installation types of InterBase, but I'm assuming you're not using the Developer, Desktop, ToGo, or IBLite licenses. I'm pretty sure that it is not tied to a specific CPU or computer however, if one instance of a licensed InterBase is running and a second instance with the same license starts up, I think you'll get a license error. Whether or not Embarcadero tracks where the license is coming from, I'm not sure.