Jump to content

FPiette

Members
  • Content Count

    1167
  • Joined

  • Last visited

  • Days Won

    16

Everything posted by FPiette

  1. FPiette

    SMTP Server -> Client

    There is no ICS with SSL for Delphi 5. If you have a lot of component it is feasible to port it to latest Delphi version provided you have full source code for every components.
  2. FPiette

    SMTP Server -> Client

    Why don't you simply update your application to use the SMTP component with SSL enabled (SMTPS)? If you don't want to update your application, then you can do as you said, but of course using ICS components. You have everything you need. This application would altough be more complex that a simple update of the existing application to use SMTPS.
  3. FPiette

    remove part of string and compare

    1) Open the file if read mode (The "Source"), 2) Open a temporary file in write more, 3) If end of source file goto line 7 4) Read a line from the source 5) If the line must be kept, wtri to temporary file 6) Loop to line 3 7) Close source 8 Close temporary 9) Rename source to .bak 10) Rename temporary to source name To read the source file, use TStreamReader. To write the temporary file, use TStreamWriter.
  4. FPiette

    remove part of string and compare

    Why can't you use my example and do the reverse. It is trivial! Maybe a little bit more programming learning is required and also some effort to correctly specify a problem. We could have avoided all this if the question was asked clearly from the beginning function ExtractDomain(const URL : String) : String; var I, J : Integer; begin I := Pos('://', URL); if I <= 0 then I := 1 else Inc(I, 3); J := Pos('/', URL, I); if J <= 0 then begin Result := Copy(URL, I, MAXINT); Exit; end; Result := Copy(URL, I, J - I); end; procedure TForm1.Button1Click(Sender: TObject); var Index : Integer; Dict : TDictionary<String, Integer>; URL : String; Domain : String; Value : Integer; UrlFile : TStreamReader; begin Dict := TDictionary<String, Integer>.Create(10000); try ListBox1.Items.BeginUpdate; try // Load the dictionary with url.txt file UrlFile := TStreamReader.Create('url.txt'); try while not UrlFile.EndOfStream do begin URL := Trim(UrlFile.ReadLine); if URL = '' then continue; Domain := ExtractDomain(UpperCase(URL)); if Dict.TryGetValue(Domain, Value) then // Domain already found, ignore it continue; // Domain not seen before, add to dictionary Dict.Add(Domain, 0); end; finally FreeAndNil(UrlFile); end; // Now filter the ListBox to remove duplicate and items wich // are already in the dictionary (because they come from url.txt) for Index := ListBox1.Items.Count - 1 downto 0 do begin URL := Trim(ListBox1.Items[Index]); if URL = '' then begin ListBox1.Items.Delete(Index); continue; end; Domain := ExtractDomain(UpperCase(URL)); if Dict.TryGetValue(Domain, Value) then begin // Domain already found, delete from ListBox ListBox1.Items.Delete(Index); continue; end; // Domain not seen before, add to dictionary and don't remove Dict.Add(Domain, 0); end; finally ListBox1.Items.EndUpdate; end; finally FreeAndNil(Dict); end; end;
  5. FPiette

    remove part of string and compare

    Sorry but for me "welcome.com" is simply the domain part of the URL.
  6. FPiette

    Adding file directories to project

    Sure you are wrong: you can move the index storage to another drive of folder. You should. You can select what you put into the index. An index is really useful, you've got a nice example here: you complain the search is slow and yet you don't want to use an index. Kind of crazy, isn't it? To index your Delphi source files, you have to add the folder(s) where your sources are and ask the indexer to index .pas, .dpr, .dfm, .fmx, .dpk and others you like as text files (which they are).
  7. FPiette

    remove part of string and compare

    I still do see what he call "root domain". What are the root domains of "www.company.co.uk", "www.ulg.ac.be" and "www.company.com"?
  8. FPiette

    Adding file directories to project

    Search would not take much time if Windows indexing API is used.
  9. FPiette

    Adding file directories to project

    Which overhead? Of course PascalAnalyzerLite does a large number of analyzes you don't know yet you need them 🙂 For example, it will tell you which used units are not really required.
  10. FPiette

    remove part of string and compare

    Here is code to add all URL from url.txt except those already existing in the ListBox and avoiding all duplicates. function ExtractDomain(const URL : String) : String; var I, J : Integer; begin I := Pos('://', URL); if I <= 0 then I := 1 else Inc(I, 3); J := Pos('/', URL, I); if J <= 0 then begin Result := Copy(URL, I, MAXINT); Exit; end; Result := Copy(URL, I, J - I); end; procedure TForm1.Button1Click(Sender: TObject); var Index : Integer; Dict : TDictionary<String, Integer>; URL : String; Domain : String; Value : Integer; UrlFile : TStreamReader; begin Dict := TDictionary<String, Integer>.Create(10000); try ListBox1.Items.BeginUpdate; try for Index := ListBox1.Items.Count - 1 downto 0 do begin URL := Trim(ListBox1.Items[Index]); if URL = '' then begin ListBox1.Items.Delete(Index); continue; end; Domain := ExtractDomain(UpperCase(URL)); if Dict.TryGetValue(Domain, Value) then begin // Domain already found, delete from ListBox ListBox1.Items.Delete(Index); continue; end; // Domain not seen before, add to dictionary and don't remove Dict.Add(Domain, 0); end; // Now process url.txt file to add to the ListBox all URL found in // it, avoiding to add duplicates UrlFile := TStreamReader.Create('url.txt'); try while not UrlFile.EndOfStream do begin URL := Trim(UrlFile.ReadLine); if URL = '' then continue; Domain := ExtractDomain(UpperCase(URL)); if Dict.TryGetValue(Domain, Value) then // Domain already found, ignore it continue; // Domain not seen before, add to dictionary Dict.Add(Domain, 0); // and add the URL to the ListBox ListBox1.Items.Add(URL); end; finally FreeAndNil(UrlFile); end; finally ListBox1.Items.EndUpdate; end; finally FreeAndNil(Dict); end; end;
  11. FPiette

    remove part of string and compare

    What if an URL from url.txt is not in the ListBox? Simply ignore it or add it to the ListBox? In other words, does url.txt contain unwanted URL or does it contain URL to be added to the ListBox avoiding duplicates? And you didn't answered my question about "root domain".
  12. FPiette

    remove part of string and compare

    You have to keep the code as I designed it to initialize the dictionary and clean - if needed - the list box content. Then, after the for/loop, without clearing the dictionary, add a second for/loop to scan the URL file as I explained in my previous message. To read the URL file, of course you may use a string list or you may use TStreamReader or traditional file I/O to read the file line by line. The later will avoid loading the entire file in memory and only then scan for the lines.
  13. FPiette

    Adding file directories to project

    Sure, I perfectly know that. I have done it numerous times. You may go the faster route by adding upfront all directories in the search path, where or not they have used source file (You don't know at that time). Then compile the project which should compile fine given the number of directories you added. Then use PascalAnalyzerLite (https://www.peganza.com) to analyze the project. The report (General / Status / Loaded Files) gives the the list of loaded files with their path. Then remove all the directories from the search path and add all files listed by PascalAnalyzerLite and you are done.
  14. FPiette

    Adding file directories to project

    The problem is only when they put directories on different drives. If they are all on the same drive, the IDE maintain relative paths and you can copy the project and the files on another system PRESERVING the directory structure. Then you add all files to the project as I explained instead of adding directories to the search path.
  15. FPiette

    Adding file directories to project

    I never add path to the project search path, nor to global Delphi path: I always add every file in the project directly. Delphi global path contain only the standard directories setup by Delphi installer. I do that because if have a huge number of units splits into categories, each in his own directory. Adding all those directories to the search path (either global or project) make compilation time much longer. And secondly because it like to see - in project manager - exactly what by program is using. And finally be able to click in the project manager on any file my application is using. Adding files to the project is quicker if you use drap&drop from Explorer to project manager.
  16. FPiette

    remove part of string and compare

    The idea is just the same as above and then read the url file line by line, extract the domain, check the dictionary. If already there, just read next line if not there, add the domain in the dictionary and add the url to the listbox. You should be able to do that easily yourself. I don't understand what you call "domain root". Give an example.
  17. FPiette

    remove part of string and compare

    function ExtractDomain(const URL : String) : String; var I, J : Integer; begin I := Pos('://', URL); if I <= 0 then I := 1 else Inc(I, 3); J := Pos('/', URL, I); if J <= 0 then begin Result := Copy(URL, I, MAXINT); Exit; end; Result := Copy(URL, I, J - I); end; procedure TForm1.Button1Click(Sender: TObject); var Index : Integer; Dict : TDictionary<String, Integer>; URL : String; Domain : String; Value : Integer; begin Dict := TDictionary<String, Integer>.Create(10000); try ListBox1.Items.BeginUpdate; try for Index := ListBox1.Items.Count - 1 downto 0 do begin URL := ListBox1.Items[Index]; if URL = '' then begin ListBox1.Items.Delete(Index); continue; end; Domain := ExtractDomain(Trim(UpperCase(URL))); if Dict.TryGetValue(Domain, Value) then begin // Domain already found, delete from ListBox ListBox1.Items.Delete(Index); continue; end; // Domain not seen before, add to dictionary and don't remove from list Dict.Add(Domain, 0); end; finally ListBox1.Items.EndUpdate; end; finally FreeAndNil(Dict); end; end; This will check for domain by ignoring character casing and ignoring the protocol. You may adept this to a TStrings easily. I used a dictionary because you said you have 10K items. A dictionary should be faster than a simple list when there are a lot of items but I have not checked how many items are required so that dictionary is faster than list.
  18. FPiette

    Batch Reading Emails from Windows Explorer

    Not sure I understand what you want to do! Please clarify the context. By the way, the email file format depend on the source (mail client) you use to drop the file. Outlook will drop a .msg file.
  19. FPiette

    compiler setting issue?

    {$POINTERMATH ON} ?
  20. FPiette

    No C/S FireDac for Delphi Professional

    @Mark ElderFinally, what will you do? I ask because you have not reacted to any answer you received. And by the way, if you don't want to write a full message, at least click on the like button of each answer you like. The like button is the heart icon on the right side of each message. Thanks.
  21. FPiette

    Interlocked API and memory-mapped files

    InterlockedCompareExchange can be used to implement a spinlock. When using shared memory, this will work interprocess.
  22. FPiette

    No C/S FireDac for Delphi Professional

    I think ADO components are included in PRO version as well.
  23. FPiette

    How do I enumerate all properties of a Variant?

    Undocumented doesn't mean it has not documentation inside the exe/dll. The proof is that my function show the list of functions. Try to import the DLL in Delphi as it is a type library (Delphi Menu Component / Import component / Import a Type Library. If it doesn't appear in the list, click the Add button and select your dll. If it doesn't work, try adding it as an ActiveX instead.
  24. FPiette

    Interlocked API and memory-mapped files

    I think so provided the data is in shared memory.
×