PDA

View Full Version : #Include ... evolution



ErosOlmi
29-03-2016, 12:12
Next thinBasic beta will have the possibility to #INCLUDE sources directly from the a web page using HTTP or HTTPS.
It can be used to quickly test something published from others or to refer to library maintained in the web
Example:

'---Test include from Web
#INCLUDE "https://raw.githubusercontent.com/petrSchreiber/SmartTexture/master/smartTexture.tbasicu"

Dim t As SmartTexture
t.FromFile("C:\myImage.png")
t.Make(1, %TBGL_TEX_MIPMAP)


I think it will be necessary to add new features like a web #INCLUDE defined inside a parent web #INCLUDE.
Anyway let's start and we will see.

Michael Hartlef
29-03-2016, 12:24
Interesting. How would you handle a fallback, if the include is not available?

ErosOlmi
29-03-2016, 14:16
Actually if problem is related to no internet connection, I can trap it easily.

But if internet connection is OK and the problem is related to the file, it is more difficult to trap it.
Usually web servers reply with some html code telling "file not found" but that page is a personalized page so every server can reply in different ways.

I found some info about how to get it: http://stackoverflow.com/questions/13564947/how-can-i-find-if-a-webpage-exists-using-wininet
using HttpQueryInfo. I will try to apply.

ErosOlmi
29-03-2016, 16:22
OK, I think I've got the following situations:

error connecting to internet
file not found
other errors are considered generic errors with a specific error code that maybe we will detect in details in future releases

Petr Schreiber
29-03-2016, 19:02
Eros... :drink:


Petr

Michael Hartlef
29-03-2016, 21:22
Sounds like a good plan