TCPIP.HTTP_GET_FILE

The TCPIP.HTTP_GET_FILE("http://www.yyy.com","file_to_write") function creates a new thread. Thread reads data from a WWW server: When thread to terminate, it will cause your callback function WM_GETFILE(ThreadId, error).

  1. You can use the HTTPS resource. https://...
  2. You can use the basic authentication for WWW pages. Set username/password in URL (protocol://username:password@hostname/path_to_file), otherwise you must fill the dialog form.
  3. When thread to terminate, it will cause your function WM_GETFILE(ThreadId, error) from script (your callback function). You can see the error codes (~HTTP_STATUS_OK == 200), and standard system error code (for file operations).
  4. Return value: If the function succeeds, the return value is a ThreadId to the new thread. If the function fails, the return value is 0.
Here's an example that reads the www.google.com home page:
// File: http_get.w_js (JScript)
Window.AppendMenu(0,"MF_STRING",100,"Get file");
Window.DrawMenuBar();

function WM_COMMAND(id) {
if (id == 100) {
  var ThreadId = TCPIP.HTTP_GET_FILE("http://www.google.com", 
                                     "c:\\google.html");
  Window.MessageBox("Trace","ThreadId: " + ThreadId, 64);
};
};

function WM_GETFILE(ThreadId, error)
{Window.Delete(1);
 Window.TextOut(1,50,50,"ThreadId: " + ThreadId);
 Window.TextOut(1,50,70,"error: " + error);
 Window.UpdateWindow();
};
'VBScript
Window.AppendMenu 0,"MF_STRING",100,"Get file"
Window.DrawMenuBar

Function WM_COMMAND(id) 
If (id = 100) Then
 ThreadId = TCPIP.HTTP_GET_FILE("http://www.google.com", "c:\google.html")
 Window.MessageBox "Trace","ThreadId: " & ThreadId, 64 
End If
End Function

Function WM_GETFILE(ThreadId, err)
 Window.Delete(1)
 Window.TextOut 1,50,50,"ThreadId: " & ThreadId
 Window.TextOut 1,50,70,"error: " & err
 Window.UpdateWindow
End Function
content
The new scripting host. It is not wscript.exe!
JScript and VBScript are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.