Jump to content

programmerdelphi2k

Members
  • Content Count

    1406
  • Joined

  • Last visited

  • Days Won

    22

Everything posted by programmerdelphi2k

  1. programmerdelphi2k

    How do I delete a row in a database with FireDAC?

    implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var LSQLText: string; begin LSQLText := Format('delete from MyTable where MyField=%s', { } [ { } StringGrid1.Cells[StringGrid1.Col, StringGrid1.Row] { } ]); // ShowMessage(LSQLText); end; end. LSQLText := Format('delete from MyTable where MyField=%s', { } [ { } StringGrid1.Cells[StringGrid1.VisibleColCount, StringGrid1.VisibleRowCount] { } ]); // ShowMessage(LSQLText); StringGrid1.Cols[1].Text := 'MyQRcode'; // LSQLText := Format('delete from MyTable where %s=%s', { } [StringGrid1.Cols[1].Text.Trim, { } StringGrid1.Cells[StringGrid1.VisibleColCount, StringGrid1.VisibleRowCount] { } ]); // ShowMessage(LSQLText);
  2. I believe that you have 2 problems now: 1) send a file by Whatsapp; 2) your glasses is broken
  3. programmerdelphi2k

    How do I delete a row in a database with FireDAC?

    look, StringList class in general (grid, stringlist, etc...) is not aware data... it just know itself data, like: strings, pointers, properties, etc... then, when you move between record (if using Livebinding, for example), it's it who receive the info about record changes, then the stringGrid is updated. said this, you can: 1) use the BindSourceDB to get your info about your records, because it is like a Datasource regular to datasets... many properties and methods with same functions BindSourceDb.Dataset.Field.... 2) to delete any record, you can use your Query component with qr.Sql.Text:="delete from tablex where fieldX = nValue"; qr.EXECUTE; it's ready!
  4. programmerdelphi2k

    Find, Replace and Save

    hi @PeterBelow I think that is not necessar so much code for this task! you need just: open the file and scan "sequencially" the buffer (with your size desired) the sequecial reads you can do with: here I'm going to use "FileOpen(...)" directly (MSWindows) to avoid using any unnecessary stream class over here! FileOpen(...), FileSeek(...), on end... FileClose(...) with this functions, your task (read) it's done! Once you've found your pattern by comparing each buffer read, then you can update your buffer and save it in another file for this purpose! the "compare" procedure you can use any one that desire, or create yourself; if ByteX[ i ] = ByteY [ i ] then ... to avoid problems with original file, just write the changes in another file!!! compare this buffer with your pattern assign new values to buffer found write new buffer content in your file temp for example close fileS opened and created! I have my code with a little bit lines: +/-16 lines to sequencial reads, does not matter size file! 21 + 17 lines to compare bytes: divided in 2 procedures
  5. programmerdelphi2k

    Validate data against a set of rules

    for sure, you needs create a "class" to specific case! then, you can use it in any other similar case! a little skeleton... unit uMyPeoples; interface type TMyPeoples = class private FFirstName: string; // ... another fields... // function GetFirstName: string; procedure SetFirstName(const Value: string); protected public constructor Create; destructor Destroy; override; // function ValidMyCurseDate(const ADate, AMin, AMax: TDate): boolean; // property FirstName: string read GetFirstName write SetFirstName; // // ... another propreties to another fields end; implementation { TMyPeoples } constructor TMyPeoples.Create; begin end; destructor TMyPeoples.Destroy; begin inherited; end; function TMyPeoples.GetFirstName: string; begin result := FFirstName; end; procedure TMyPeoples.SetFirstName(const Value: string); begin if (Value = '....') then FFirstName := Value; end; function TMyPeoples.ValidMyCurseDate(const ADate, AMin, AMax: TDate): boolean; begin result := (ADate >= AMin) and (ADate <= AMax); end; end. the rest... you can use your SQL query to valid all records readed!
  6. programmerdelphi2k

    Display of bmp and jpeg images is poorer quality in Windows 11

    here my sample, simple to load... BMP or JPEG or GIF or any other types allowed on TPictures class!!! uses GIFImg; procedure TForm1.Button1Click(Sender: TObject); var Pic: TPicture; begin Pic := TPicture.Create; try Pic.LoadFromFile('d:\ABitmap.bmp'); Image1.Picture.Assign(Pic); // Pic.LoadFromFile('d:\AJPEG.jpeg'); Image2.Picture.Assign(Pic); // Pic.LoadFromFile('d:\AGIF.gif'); Image3.Picture.Assign(Pic); finally Pic.Free; end; end;
  7. programmerdelphi2k

    Display of bmp and jpeg images is poorer quality in Windows 11

    I think that your problem can be on: converting your JPEG to BMP, or inverse: try this procedures: https://helloacm.com/how-to-convert-jpeg-to-bmp-and-bmp-to-jpeg-in-object-pascal-delphi/ review your "Stretch draw" procedure too!
  8. programmerdelphi2k

    Display of bmp and jpeg images is poorer quality in Windows 11

    I think that you need to say more about: what components/classes used to load/show the pictures? what components/classes used to print it? what "your" code used with above?
  9. programmerdelphi2k

    Cross Platform Reminder

    for sure, use the O.S. options, because I dont needs worry about create the "whells" if you target O.S. have a "scheduler", use it. naturally, this is more in the control of the O.S. than from your app! if you want have "control" over all, create a app!
  10. programmerdelphi2k

    FireDac variable column length overflow

    https://docwiki.embarcadero.com/Libraries/Sydney/en/FireDAC.Stan.Option.TFDFormatOptions.StrsTrim look in your component to query the properties about field size on Fields editor
  11. programmerdelphi2k

    form data store component ?

    no no no... my "zip" is about "compressing and decrease the amount of data to be written to memory or disk" you talk about "zip... it", not me!
  12. programmerdelphi2k

    DL a file from the web

    @David Schwartz for sure, I think that you understand my fun-session! 🙂 now, what you exactly want to say with "what is the shortest bit of code that would let you download a file?"... I see something very intriguing in this question! I explain: Even if the client (programmer) types just a single word- (command) like "downloadMyFilePlease('Hello.mp3')" (let's not consider the filename for now), what happens behind the scenes is realized by the operating system, at least!!! And, in this context, the operating system accessed its library of commands to download... and these commands were coded by someone, who wrote tens, or thousands of lines of code so that "such a task" could be carried out successfully or no!!! So, what exactly would be the definition of the smallest amount of bits to perform the file download? You mean: the smallest amount of bits encoded by you or the operating system as a whole? I ask for the simple reason: if you don't code, then someone else will have to code for you!!! Or am I wrong?
  13. NOTE: A warning about use of "folders of the System", like "Program files"!!! as "folder system" always needs "admin privilegies", it's a common scenary have this access denied when try create new files, like when "building/compiling" your project! sometimes there are not any critical error-message! simply the files it's not created and the IDE report some other message for that situation! as general rule: DONT INSTALL YOUR PROJECTS, or any other that needs to be re-compiled/re-builded in "Program files" or other that needs any Admin priviligies! create a new directory for this cases! like: C:\MyProjects\MySDKs
  14. if the file was not found on project-folder, then, you'll always needs in "Search path" in your project (Project->Options->Compiling...->Search...) or in IDE (Tools->Language->Delphi->Library Path... but here, it's for when needs in all projects like when installing new packages, libs,etc...) search all "*.INC" and see where it is in (folder), normally, it will be in "sources" folder! if the project have many *.DPK, then, you have that updates it too! See a example, if you dont want changes your Project-Options:
  15. find some option to config your project on MMX, or, in your Delphi project --- Project -> Options -> Compiling -> "Search path" .... and define where is the source files!!!
  16. JPG or PDF it's all bits to computer, then, what the difference to Whapsapp?
  17. programmerdelphi2k

    Multiple Simultaneous Connections with TidFTP

    maybe, it would be better some like this: type TMyThreadDownload = class(TThread) //.... + all definitions necessary private FileToDownload:string; // URL + filename protected procedure Execute; public constructor Create.... destructor Destroy;override.... // property FileToDownload:string read FFileToDownload write FFileToDownload; end; implementation ... other definitions constructor Create; begin FreeOnTerminate:=true; // not use MyThread.Free on button1 end; procedure TMyThreadDownload.Execute; // my sample to HTTP, but you can port it to FTP class!!! var MyClientHttp: TIdHTTP; //or any other class to downloads MyIOHandler:TIdSSLIOHandlerSocketOpenSSL; MyStream:TFileStream; begin // create IOHandler + definitions // create MyClientHtpp + definitions // create your MyStream + definitions try try MyClientHttp.Get( FFileToDownload, MyStream); // MyStream.SaveToFile('...'); except // what to do ? end; finally // release objects created end; end; then, you usage: Button1 click: var MyThread:TMyThreadDownload; begin // if you want on loop, then just loop it! // MyyThread:=TMyThreadDownload.Create; MyThread.FileToDownload:= 'xxx'; MyThread.Start; end;
  18. programmerdelphi2k

    Multiple Simultaneous Connections with TidFTP

    you can see this way: client side: each thread will works like a "separated software"! then, each software should have your credencials, as well as, your file to download/upload server side: it's another history!
  19. here, RAD 11.2 Alexadria does not cause this error! see my tips above!
  20. programmerdelphi2k

    form data store component ?

    my tip for "zip" your infos: memory or disk! many know about ZLib compress in Delphi usage, TCompressXXXX = ok! now add this: take your info in string format, like using Base64 convertion ( dont worry about size.... final-string = source + 1/3(source) --- dont worry, continue reading... after convert your string in Base64, convert it in "bytes" --- here the magic flowing... (many equal digits will be "the point" to elimate duplicates) after this, compress it using your ZLib class it's ready! you can get until "90% off" (or more) as result! I have tested with text, bitmap, and other types! bitmap 8MBytes stay with 1.x MBytes same that the type is already compress by default, like GIF, JPEG, etc.. you can reduce it more! there are no losses, because the real-data it's not affected!
  21. programmerdelphi2k

    Create multiple instances of tApplication with multiple MainThreads?

    "A thread is the entity within a process that can be scheduled for execution. All threads of a process share its virtual address space and system resources. Each process is started with a single thread, but can create additional threads from any of its threads"... https://learn.microsoft.com/en-us/windows/win32/procthread/multiple-threads then, in fact, there is just one "main", the rest is co-adjuvant process
  22. programmerdelphi2k

    Create multiple instances of tApplication with multiple MainThreads?

    I know about loop, I came form "Clipper summer87" the same "principle" is used in GUI app... a looping "REPEATing" until end message!
  23. programmerdelphi2k

    Create multiple instances of tApplication with multiple MainThreads?

    look, each "TApplication" represent a "application = process" on memory! then, have many "TApplication" means have many process of same process (or be: clones)... but at end, all clones will be the same app! what you can do is: many forms and changes one or other to be "the main-Form", but not all at same time! -- because, you cannot have 2 or more "main-Forms" in the same application!
  24. try create a "new session" on Registry for your RAD Studio using: https://docwiki.embarcadero.com/RADStudio/Sydney/en/IDE_Command_Line_Switches_and_Options BDS.exe /r NewName ..... other params
  25. programmerdelphi2k

    DL a file from the web

    the minor code for me is: open Chrome and paste the url
×