![]() Memo1.Text := FPHTTPClientDownload(Edit1.Text, True, 'test.txt') Procedure TForm1.Button2Click(Sender: TObject) Memo1.Text := FPHTTPClientDownload(Edit1.Text) Procedure TForm1.Button1Click(Sender: TObject) Then put your cursor on the function line and press Ctrl+Shift+C. - content when the content SaveToFile is set to False - filename when the file has been downloaded successfully Now add this function above the "end." line (usually the last line of the unit):įunction TForm1.FPHTTPClientDownload(URL: string SaveToFile: boolean = false Filename: string = ''): string #Synapse library for free pascal codeSwitch to Code View (F12) and simply include fphttpclient in the uses clause: Your form should look something like this: And akRight and akBottom for Memo1 so that when the form is resized the components fill the form. Place 2 TButtons, TEdit and a TMemo on the form.Ĭhange button1's Caption to "Download and Display" and button2's to "Download and Save".Īlso empty the Memo1's Lines property and set its ScrollBars to ssAutoVertical.īut what happens when we get large outputs and we need to resize the form? We can't have tiny components to fiddle around! To fix this you can enable the akRight for Edit1 under Anchors. So it is more convenient than the other ones.Ĭreate an Application Project ( Project - New Project - Application - OK). This is the most simple of the 3, plus the library is bundled with Lazarus. There might be other ways, but these are the most popular. We can retrieve the contents of a link in 3 ways: fpHTTPClient, Synapse, Indy. ![]() ![]() And we can even use REST APIs to do amazing things. We can communicate with servers or websites, get data from them, then parse and present the data in our program window just like we want to. Getting the contents of a link can give us so much to do. What if we could download the contents of a link on the web to our own Lazarus program? Let's find out how! ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |