Xojo Conferences
MBSOct2019CologneDE

Platforms to show: All Mac Windows Linux Cross-Platform

/CURL/CURLN text download
Function:
Required plugins for this example: MBS CURL Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /CURL/CURLN text download
This example is the version from Sun, 9th Mar 2019.
Project "CURLN text download.rbp"
FileTypes
Filetype text
End FileTypes
Class Window1 Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() DoDownload url.text End EventHandler
End Control
Control URL Inherits TextField
ControlInstance URL Inherits TextField
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control ResultText Inherits Label
ControlInstance ResultText Inherits Label
End Control
Control TextArea1 Inherits TextArea
ControlInstance TextArea1 Inherits TextArea
End Control
Control TextArea2 Inherits TextArea
ControlInstance TextArea2 Inherits TextArea
End Control
Private Sub DoDownload(URL as string) dim d as new CURLNMBS // collect output as we don't have events to handle it right away d.CollectDebugData = true d.CollectOutputData = true d.CollectHeaderData = true // write debug log d.OptionVerbose = true // download here d.OptionURL = URL // if you use SSL, maybe put in a certificate or disable verification? d.OptionSSLVerifyHost = 0 d.OptionSSLVerifyPeer = 0 // run download dim e as integer = d.Perform // check result dim s as string = d.OutputData TextArea1.text = FixText(S) ResultText.text="Result: "+str(e) dim DebugMessage as string = d.DebugData // check in debugger on error TextArea2.text = FixText(DebugMessage) if e <> 0 then break end if End Sub
Private Function FixText(s as string) As string // fix text encoding if s.Encoding <> nil then // ok? elseif encodings.UTF8.IsValidData(s) then s = DefineEncoding(s, Encodings.UTF8) else s = DefineEncoding(s, encodings.ISOLatin1) end if // fix line endings s = ReplaceLineEndings(s, EndOfLine) Return s End Function
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS CURL Plugin.

The biggest plugin in space...




Links
MBS FileMaker blog