-
Content Count
620 -
Joined
-
Last visited
-
Days Won
11
Everything posted by corneliusdavid
-
I would save the GUIDs as TEXT fields, not binary. They could even be stored as numbers in the TEXT field as SQLite is very loose with it's storage compared with Delphi. Read about them here: https://www.sqlite.org/datatype3.html There are no generators in SQLite. You're probably very used to using them in Firebird or InterBase. Instead, you might consider the AUTOINCREMENT feature of the INTEGER type but there are some considerations to using that as well.
-
Copy Encrypted InterBase Database to another machine
corneliusdavid replied to corneliusdavid's topic in Databases
Sriram, Thank you so much for your detailed response. I had indeed read every link and technical resource I could find, even scanned all through David I's book. I found and learned lots of information but never found anything about using InterBase as the database for installed RAD Server modules--I just assumed it would be possible as it seems like the natural choice for RAD Server modules. In my opinion, this seems wrong (or greedy). They promote RAD Server which uses encrypted InterBase and they promote the use of InterBase for your applications. But when you install RAD Server and InterBase together, fully licensed with RAD Server, you can only use RAD Server, you can't use the fully capable, licensed, running InterBase without purchasing another license. I could understand restricting InterBase use only through RAD Server modules but I guess that might be technically difficult to enforce. Thanks again! -
Delphi Daily WTF / Antipattern / Stupid code thread
corneliusdavid replied to Tommi Prami's topic in RTL and Delphi Object Pascal
True! -
Delphi Daily WTF / Antipattern / Stupid code thread
corneliusdavid replied to Tommi Prami's topic in RTL and Delphi Object Pascal
I was surprised to check this thread this morning and see all the comments. I guess I should've mentioned I had already refactored this. Since I despise both GOTOs and EXITs, I rewrote it without any of them: function BlankControl(EditControl: TObject; const EditMess: string; ShowErrorMsg: Boolean; MaxLen: Integer): Boolean; begin // assume False, prove otherwise Result := false; if EditControl is TCustomEdit then Result := length(trim((EditControl as TCustomEdit).Text)) < MaxLen else if EditControl is TComboBox then Result := length(trim((EditControl as TComboBox).Text)) < MaxLen else if EditControl is TDBComboBox then Result := length(trim((EditControl as TDBComboBox).Text)) < MaxLen else if EditControl is TDBRadioGroup then Result := length((EditControl as TDBRadioGroup).Value) = 0 else if EditControl is TDBLookupComboBox then Result := length((EditControl as TDBLookupComboBox).Text) = 0 else if EditControl is TDBCheckBox then Result := (EditControl as TDBCheckBox).State = cbGrayed else KSMessage('control is not edit checked kslib', mtError, 0); if Result then Showerror(EditControl, EditMess, false, ShowErrorMsg); end; I guess I had also left out the final "else" clause in my original post--sorry about that, it's included here. -
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.