Possibility to load local files

Got an idea for enhancing SpiderBasic? New command(s) you'd like to see?
Stefan Schnell
Posts: 46
Joined: Tue Dec 01, 2015 8:17 am
Contact:

Possibility to load local files

Post by Stefan Schnell »

Hello Fred,

a suggestion for a future release, is a function to load a local file. Here my example for a binary database file:

Code: Select all

  ; Sub Main------------------------------------------------------------
    Procedure Main()

      ; Sub loadNewDBFileEvent------------------------------------------
        !function loadNewDBFileEvent() {
        !  v_dbase.close()
        !  var uInt8Array = new Uint8Array(this.result);
        !  v_dbase = new v_sqlite.Database(uInt8Array);
        !}

      ; Sub btnOpenDBEvent----------------------------------------------
        !function btnOpenDBEvent() {
        !  var reader = new FileReader();
        !  reader.onload = loadNewDBFileEvent;
        !  var dbfile = new File([''], '');
        !  reader.readAsArrayBuffer(dbfile); 
        !}

      If OpenWindow(#MainWin, 10, 40, 320, 240, "SQLite test")

        !var input = document.createElement('input');
        !input.type = "file";
        !input.name = "files[]";
        !input.id = "files";
        !input.style.top = '205px';
        !input.style.left = '10px';
        !input.style.position = 'absolute';
        !input.onchange = btnOpenDBEvent;
        ;!document.getElementById("spiderbody").appendChild(input);
        !var win = document.getElementsByClassName('spiderwindow-content');
        !win[1].children[2].appendChild(input);

      EndIf
    EndProcedure
Thanks in advance.

Cheers
Stefan