Jump to content

FPiette

Members
  • Content Count

    1167
  • Joined

  • Last visited

  • Days Won

    16

Everything posted by FPiette

  1. FPiette

    Cust.Invoices Close

    UPDATE Invoice SET Status = "Closed" where ID = 5
  2. FPiette

    Cust.Invoices Close

    You can do it with a stored procedure but personally I always prefer to put SQL code in my Delphi source code so that when I read my program source code I see everything. The exact SQL request needed depends on the details of your database structure. I cannot the you exactly without knowing it. It is probably a "simple" update setting the Status field to "paid" with a WHERE clause selecting the correct record to be updated.
  3. FPiette

    Year Countsdown

    @JDS2018 It is time now, you the original poster, to give explanations about what you need to do. This looks like a home work you have been assigned to do. If this is the case, this would be bad that we write the code for you. You would learn much more if you try by yourself and ask small questions, one at a time, about what you cannot do. You have to prove you have done some research by yourself. And if you did and you can't still find, I'm sure someone here will help you. If you are a developer and faced with a real world problem such as a way to protect some software and make it stop working after one year, then explain that. If this something else, explain what is it. In any case, you have to prove you have done some research by yourself. And if you did and you can't still find, I'm sure someone here will help you. Understood?
  4. FPiette

    Prefix unit local variable names

    This discussion is endless. Each developer has his own preferences. There is no absolute best way to format code. IMO the only important thing is to have a consistent set of rules and to apply it strictly, especially for a team of developers. Everyone has to do the same so that each person can read the code the others wrote. There is always someone that will not like your set of rules... If you get code from elsewhere, you can reformat it using Delphi code format tool which is configurable with lot's of rules. This tools can do almost my own rules only some alignments are missing and I can survive.
  5. FPiette

    ways to organize related code in a form?

    You should pass the less possible data to the low level. Even if it is easier to pass a huge record with everything, you must refrain. Only pass what is needed. The current state will be updated by events from the lower level of code (the frame or embedded form). On by function returning a value.
  6. FPiette

    How create a website whit Delhpi

    That is beside the point of this topic. Remember what the OP has actually asked.
  7. FPiette

    How create a website whit Delhpi

    This has been developed to add HTTP/HTTPS to an application doing something totally different. The application control hardware in a blackbox and provide a remote user interface to configure/monitor/interact with the hardware. You probably know very well how a broadband modem/router works and is managed with a webbrowser. Of course what can do the most can also do the less. The ICS HTTP application server has since then used for many other things. When you have a huge amount of Delphi code, it is an easy path to reuse that code and provide a web interface to it.
  8. FPiette

    ways to organize related code in a form?

    If you have circular reference, that means your frames don't properly expose their features. None of the frame should ever refer to the hosting form! None should ever know that thei are hosted by a form. The frame does his work and returns results back to the hosting form thru methods, properties and events. The components in the frame, making the UI, shall NEVER referenced directly from the outside (Consider those components as strict private). If they must get values from the outside, then properties shall be used for the purpose. Let's take a trivial example: Assume an application having to compute the sum of two numbers and display the result. You build a form having what is required to display the sum and use a frame to let the user input the numbers and compute the sum. The frame would expose properties for the numbers so that the form can initialize it for example from a configuration file having default values. If no initialization required, the form simply do not touch those properties. When the user enter numbers in the frame, code in the frame compute the sum, store the result in a property and trigger an OnSumAvailable event (A TNotifyEvent). The form assign an event handler to the frame OnSumAvailable and from that event handler read the frame property containing the sum and display where it has to be displayed. In that architecture, you have a object derived from TFrame which encapsulate a behavior (UI and computation) and expose properties and event to support the behavior (It could also contain methods) without any assumption about how it is used. There is NO reference in the frame to the rest of the application. The is NO circular reference. In that architecture, the frame don't know and don't care how the computed sum is displayed on the hosting from. And the form don't know and don't care host the numbers are entered by the user. If will have zero impact if the frame is updated to use a track bar to enter the number or simple TEdit and zero impact if the form display the result in TLabel or a fancy 7-digits display component.
  9. FPiette

    How create a website whit Delhpi

    As I mentioned in a previous post in this thread, ICS has not only what is needed to publish static pages stored in HTML files (And JS, and CSS, and images, and anything) but also what is required to make dynamic pages based on HTML templates or based on pure Delphi code. Look at the example OverbyteIcsWebAppServer.dproj.
  10. FPiette

    Prefix unit local variable names

    I'll write almost as you do except: 1) First letter is always uppercase. 2) Constant have no prefix but always all uppercase with underscore to separate words like MAX_CLIENT 3) Local method variable have no prefix at all since all other have a prefix. As you said, it is much of personal taste but your asked so my answer.
  11. FPiette

    ways to organize related code in a form?

    In the first place, I would split in in a number of other forms or frames and host them in the tabsheet and panels you have on the main form.
  12. FPiette

    How create a website whit Delhpi

    You will find examples in the demos that are delivered with ICS. See http://wiki.overbyte.be. Maybe start with the example OverbyteIcsWebAppServer.dproj. If you need help with ICS, post your message in the dedicated forum https://en.delphipraxis.net/forum/37-ics-internet-component-suite/
  13. FPiette

    Enumeration Type as Parameter

    A catalog looks like a StringList, isn't it? Could you provide minimal but complete source code to build and use TWO catalogs?
  14. FPiette

    Enumeration Type as Parameter

    So you mean your remove type check at compilation time to do it at run time. Poor design. It would probably be a good idea that you explain WHY you need such construct. Maybe there are other solution than the [flawed?] one you designed.
  15. FPiette

    Enumeration Type as Parameter

    I don't see any generics here. Not sure I fully understand what you need. Anyway here is what I think is a solution: type TSet1 = (a11, a12, a13); TSet2 = (a21, a22, a23, a33); TFoo<T: record> = class public class procedure Foo(ADefault : Integer); end; implementation class procedure TFoo<T>.Foo(ADefault: Integer); var Info : PTypeInfo; NumberOfElement : Integer; begin Info := TypeInfo(T); NumberOfElement := Info.TypeData.MaxValue - Info.TypeData.MinValue + 1; Form1.Memo1.Lines.Add(NumberOfElement.ToString); end; // Example use procedure TForm1.Button1Click(Sender: TObject); begin TFoo<TSet1>.Foo(123); TFoo<TSet2>.Foo(456); end;
  16. FPiette

    Looping Memo.Text

    I think XE supports SplitString function in StrUtils unit.
  17. FPiette

    Byte Array to String

    I made another version which doesn't use any variant (Late binding) and has the advantage that during code editing, you get Delphi Code Insight showing all the methods and properties. unit OutlookDemo; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.OleServer, // To get TOutlookApplication version 2010, you need to install the // component package dcloffice2010XYZ.bpl (XYZ being Delphi version, // 260 for D10.3, 270 for D10.4). This package is in Embarcadero Studio bin // directory. Outlook2010; type TOutlookDemoMainForm = class(TForm) OutlookApplication1: TOutlookApplication; RTFBodyButton: TButton; Memo1: TMemo; procedure RTFBodyButtonClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var OutlookDemoMainForm: TOutlookDemoMainForm; implementation {$R *.dfm} procedure TOutlookDemoMainForm.RTFBodyButtonClick(Sender: TObject); var ANameSpace : NameSpace; AFolderItem : MAPIFolder; AMailItem : MailItem; RTFBody : array of Byte; RTFString : String; Stream : TFileStream; begin OutlookApplication1.Connect; ANameSpace := OutlookApplication1.GetNameSpace('MAPI'); AFolderItem := ANameSpace.GetDefaultFolder(olFolderInbox); AMailItem := AFolderItem.Items.Item(1) as MailItem; RTFBody := AMailItem.RTFBody; RTFString := TEncoding.Default.GetString(RTFBody); Memo1.Lines.Add(RTFString); Stream := TFileStream.Create('RTFBody.rtf', fmCreate); try Stream.Write(RTFBody[0], Length(RTFBody)); finally Stream.Free; end; end; end.
  18. FPiette

    Byte Array to String

    The OP is likely to need the AnsiString. That why I showed how to do that.
  19. The sources are in C:\Program Files (x86)\Embarcadero\Studio\21.0\source for a standard installation. No idea if sources are delivered with trial version. Try with Community Edition.
  20. That's quite a controversial question. It is easy to image that class inheritance will benefit a lot to the design of graphic application. And between a class and a record, there is only one more indirection in some case and none when value type are used thru pointers for performance reasons...
  21. I would create an overloaded SetEdges: procedure TGEORect.SetEdges(const AEdges : TEdgeArrayPoints); begin FEdges := AEdges; end;
  22. Better use a class for TPolygon and put not only the data but also the processing. If the class don't know how to do some things, then use an event to externalize that. For example, the class could not be able to render the polygon but have the algorithm to do it. Then, you can have an event in TPloygon named OnDrawLine and having proper arguments to delegate (externalize) the line drawing.
  23. You have to use an indexed property: property Edges[Index : Integer] : TPoint read GetEdges write SetEdges; And then implement GetEdges and SetEdges: procedure TGeoRect.SetEdges(Index : Integer; Pt : TPoint); begin if (Index < Low(FEdges)) or (Index > High(FEdges)) then raise ERangeException.Create('Invlid index'); FEdges[Index] := Pt; end; You may also use a type for the range used for indexing the array. GetEdge is similar.
×