Scolring - Forum

Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology

Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered

You are not logged in.

#26 27-Oct-2014 22:05:10

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,477
Website

Re: getting the size of a file on the web and checking its download

stock-photo-monkey-holding-a-empty-banner-and-screaming-mixed-breed-between-chimpanzee-and-bonobo-years-34301146.jpg

Offline

#27 27-Oct-2014 22:06:09

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,081
Website

Re: getting the size of a file on the web and checking its download

Iri what I mean is that the NOBODY flag create a erquest to the server where it return only header information.
This is made for this, so this is really fast since the server do not send the body information with the datas

Offline

#28 27-Oct-2014 22:06:50

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,081
Website

Re: getting the size of a file on the web and checking its download

LOl I've almost finished too smile
Will commit this soon

Offline

#29 27-Oct-2014 22:08:00

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: getting the size of a file on the web and checking its download

_createpack can not create a file with a nil content. It's a logical behavior.
i think you make your code a bit complex.

mutate is an imperative Scol function : it changes directly in memory the value of a variable. Thus, it is also dangerous.
To use it, a variable must be in a tuple, even if its size is 1. This is one of the most difficult to understand functions, in Scol.

Unfortunately, i don't write an english tutorial yet about it. I can give you my short and old french explanation :

Mutate

'mutate' est une fonction très utile mais aussi très dangeureuse car c'est une fonction impérative dans un environnement fonctionnel. Elle remplace certains (voire tous les) éléments d'un tuple sans toucher aux autres, directement au niveau des pointeurs. Par exemple, le tuple

    let ["a" "c" "c"] -> tuple in
    ...
    mutate tuple <- [_ "b" _];

On a remplacé la valeur du 2e élément : de "c" elle est passée à "b". Le tuple vaut désormais ["a" "b" "c"]. Là où il y a des undescores, les éléments restent inchangés. Remarquez également le sens de la "flèche", de la gauche vers la droite, ce qui est logique.
Bien sur, le typage du tuple doit être respecté ! mutate <- [_ 2 _] provoquera une erreur ! Autre exemple :


    let [a b c] -> tuple in
    let 2*b -> d in
    ...
    mutate <- [a d _];

Ici, on a un tuple composé de trois variables a, b et c. On a une autre variable, d, définit comme valant le double de b (ce qui implique que b est un entier donc de type I, le type de a et c restant indéterminé).
Puis on remplace le 2e élément du tuple par d, comme lors du premier exemple. Mais on a aussi remplacé le 1er élément par la même variable. Si la vairable a n'a pas subi de traitement entre temps, le 1er élément restera inchngé sinon il sera modifié. De plus, 'mutate' modifie toutes les variables qui pointent directement ou non vers le tuple. C'est parfois très utile, c'est parfois très dangereux ...

Note : 'mutate' ne fonctionne qu'avec des tuples. Pour modifier une variable unique, il faut la placer dans un tuple de taille 1 :

    let [mavariable] -> tuple in
    ...
    mutate tuple <- [mavariable];

Cela peut paraître idiot (on pourrait modifier directement 'mavariable' mais dans un certain nombre de cas, c'est la seule solution !

Offline

#30 27-Oct-2014 22:14:55

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: getting the size of a file on the web and checking its download

arkeon wrote:

Iri what I mean is that the NOBODY flag create a erquest to the server where it return only header information.
This is made for this, so this is really fast since the server do not send the body information with the datas

Yes, i understand. But my question is not here wink

You want download a file, so you perform a GET request.
If you make before a HEAD request, you've two requests instead of one. Although this data is also known in the GET header response.

Offline

#31 27-Oct-2014 22:22:51

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,081
Website

Re: getting the size of a file on the web and checking its download

You can update :
https://svn.scolring.org/trunk/scol_app … /tools.pkg
https://svn.scolring.org/trunk/scol_app … player.pkg

to test create a scol file like :

_load "tools/os3dplayer/os3dload.pkg"
main "http://ifam.net/openspace/spacemanshooter1/dan_no_mohawk/spacemanwithtank.pak" "" "" "" 0

Offline

#32 27-Oct-2014 22:24:26

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,081
Website

Re: getting the size of a file on the web and checking its download

the progress bar have everything configurable.
this is a widget over the splash one that blit the progress bitmap.

Offline

#33 27-Oct-2014 22:25:03

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,477
Website

Re: getting the size of a file on the web and checking its download

the code works with _createpak or _storepack, for what that's worth. I'm not sure why the last parameter of INETGetURL makes things different as the relevant object destpath is being passed to the callback.

no need to answer, it works, that's all I need to proceed at this point

Offline

#34 27-Oct-2014 22:27:01

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,081
Website

Re: getting the size of a file on the web and checking its download

Yes iri you get this info in the simple get request too, but this request end only when the all file is downloaded.
So with this one you get the data size before to send the download request. it can also permit to check the file difference with size and date from the local one before downloading it.

Offline

#35 27-Oct-2014 22:29:06

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,081
Website

Re: getting the size of a file on the web and checking its download

I think you forgot to clean the file before download it again.
just call _storepack "" thefile; to make it empty. the pak format allow bad data after the correct one, but the file size must grow for nothing, and only the first data in file will be loaded.

Try my code it all work good smile

Offline

#36 27-Oct-2014 22:38:01

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,477
Website

Re: getting the size of a file on the web and checking its download

arkeon wrote:

I think you forgot to clean the file before download it again.
just call _storepack "" thefile; to make it empty. the pak format allow bad data after the correct one, but the file size must grow for nothing, and only the first data in file will be loaded.

Try my code it all work good smile

Ok please share when you have time.

Offline

#37 27-Oct-2014 22:39:35

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,081
Website

Re: getting the size of a file on the web and checking its download

6 posts up in this page smile

Offline

#38 27-Oct-2014 22:45:47

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,081
Website

Re: getting the size of a file on the web and checking its download

Commited again, I have forgotten to manage the windows resize for the progress bar.

Offline

#39 27-Oct-2014 22:55:00

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,477
Website

Re: getting the size of a file on the web and checking its download

arkeon wrote:

You can update :
https://svn.scolring.org/trunk/scol_app … /tools.pkg
https://svn.scolring.org/trunk/scol_app … player.pkg

to test create a scol file like :

_load "tools/os3dplayer/os3dload.pkg"
main "http://ifam.net/openspace/spacemanshooter1/dan_no_mohawk/spacemanwithtank.pak" "" "" "" 0

Oops I miss that. I will get back to work on it in the morning thanks!!!!!!

Offline

#40 27-Oct-2014 23:39:06

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: getting the size of a file on the web and checking its download

arkeon wrote:

Yes iri you get this info in the simple get request too, but this request end only when the all file is downloaded.
So with this one you get the data size before to send the download request. it can also permit to check the file difference with size and date from the local one before downloading it.

http://www.scolring.org/forum/viewtopic … 7171#p7171

Offline

#41 28-Oct-2014 17:17:25

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,477
Website

Re: getting the size of a file on the web and checking its download

arkeon I tried out your code and for some reason it slows the player startup. I don't know why. In any case, thank you for your update as I will be using the download bar in my project.

Offline

#42 28-Oct-2014 18:19:40

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,081
Website

Re: getting the size of a file on the web and checking its download

the other code is the same so it should not slow down the startup, and the downloading method is better than the inet one. It use the OS3D 1.8beta runtimes, maybe I made some other changes I don't remember ^^

Offline

#43 28-Oct-2014 18:24:44

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,477
Website

Re: getting the size of a file on the web and checking its download

arkeon wrote:

the other code is the same so it should not slow down the startup, and the downloading method is better than the inet one. It use the OS3D 1.8beta runtimes, maybe I made some other changes I don't remember ^^

I see, that's probably it.

Offline

#44 28-Oct-2014 18:26:55

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,081
Website

Re: getting the size of a file on the web and checking its download

You can download the last scol and OS3D version here :
https://svn.scolring.org/trunk/setups/i … plugin.exe

then

https://svn.scolring.org/trunk/setups/i … _setup.exe

This is not the final one but it has a lot of new features smile

(the player code is not updated with the one from yesterday in this version)

Offline

#45 28-Oct-2014 18:31:06

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,477
Website

Re: getting the size of a file on the web and checking its download

arkeon wrote:

You can download the last scol and OS3D version here :
https://svn.scolring.org/trunk/setups/i … plugin.exe

then

https://svn.scolring.org/trunk/setups/i … _setup.exe

This is not the final one but it has a lot of new features smile

(the player code is not updated with the one from yesterday in this version)

Thanks! atm I think I will hold off on trying everything with the next version, unless you want me to do some testing for you. smile

Offline

#46 28-Oct-2014 18:39:14

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,081
Website

Re: getting the size of a file on the web and checking its download

AS you want smile but yes we need beta testers smile

Offline

Board footer

Powered by FluxBB