Auto Update
Heacien edited this page Oct 24, 2018
·
1 revision
First we need to test if httpRequest is enabled
if (httpCanRequest()) {
If the upper test returns 1 we can continue with fetching our code from a external page
httpRequest("http://e2.net/my/code.txt")
If we get a httpClk() == 1
we can save the code as a file
fileWrite(">e2shared/my_code.txt",httpData())
It's important to know that you can only save files under the e2shared
folder!
@name httpRequest
@persist HTTP
# To run the expression when a request finishes
runOnHTTP(1)
# If it's the first run and you can make a new request
if (!HTTP & httpCanRequest()) {
print("Getting the code")
HTTP = 1
# Starts a new request
httpRequest("https://raw.githubusercontent.com/Heacien/Fam-Freeman/master/httpRequest")
}
# If a completed request was run
if (httpClk() & HTTP == 1) {
print("Saving the code")
HTTP = 2
# Writes string data to the file (overwriting it)
fileWrite(">e2shared/httpRequest.txt", httpData())
}