local http = require "socket.http" local w32 = require "w32" -- the form local getdocForm = VCL.Form("getdocForm") getdocForm._ = { left=100, top=100, height=140, caption="Online documentation sample form", } -- login name getdocForm.lblFname = VCL.Label(getdocForm, "lblFname") getdocForm.lblFname._ = { left=10, top= 20, caption="File name:" } getdocForm.edFname = VCL.Edit(getdocForm, "edFname") getdocForm.edFname._ = { left=10, top= 40, width=300, text="http://www.lua.org/docs.html" } -- the run button getdocForm.btnRun = VCL.Button(getdocForm, "btnRun") getdocForm.btnRun._ = { left=80, top= 80, width=150, onclick = "btnRunClick", caption = "Get online documentation"} -- button click event function btnRunClick(Sender) local prc,tp = w32.GetTempPath() local frc,tf = w32.GetTempFileName(tp,"",0) local b, c, h = http.request(getdocForm.edFname.text) if c==200 then tf = tf..".html" file.save(tf,b) os.execute(tf) else VCL.MessageDlg("HTTP request failed\n Error code:"..tostring(c),"mtError","mbOk") end end -- mainloop getdocForm:ShowModal() getdocForm:Free()