Page 1 of 6 123 ... LastLast
Results 1 to 10 of 52

Thread: Read ascii file

  1. #1
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,862

    Read ascii file

    Hi all,
    I'm tryng to read a ascii file from rsp page in javascript.

    I'm not a javascript developer... just copy and paste.. :-)

    I've find this funzction:

    Code:
    function readText(files){
    
    	if(files){
    		window.alert(files);
    		var reader = new FileReader();
    		reader.onload = function (e) {  
    			var output=e.target.result;
    					
    			window.alert(output);
    			
    			var divTabella = document.getElementById("DivTabella");
    			divTabella.innerHTML = output;
    		
    		};
    		
    		
    		reader.readAsText(files);
    	}
    };
    but if I call:
    readText('../../library/file.html');

    not work..

    I've put the file in c:\lianja\library folder...

    thank a lot
    Fabio

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,731
    You seem to misunderstand how a Webview works.

    A Webview section in a desktop app is not connected to an http server.

    You need to look at the Lianja system object and see what methods you can use to read text files in a desktop app.

    Attempting to use a FileReader is only valid in a web browser client not a desktop app with an embedded Webview.

    The desktop client has a web server running internally in port 8002. Go back and read the release notes for v2.0 where this is described.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  3. #3
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,862
    Hi Barry,
    thank for the reponse.
    I've read the Josip post:
    http://www.lianja.com/community/show...rs-Web-service

    Your service may return a JSON encoded object (as shown above), an XML string, an HTML string or plain text.
    If the result returned starts with "file:" then the file specified e.g. "file:mytempfile.txt" is read and the result is sent back to the client. This provides the ability to query large amounts of information not limited by internal string length.
    If the result returned starts with "tempfile:" then the file specified e.g. "tempfile:mytempfile.txt" is read and the result is sent back to the client. The file mytempfile.txt is then deleted.

    but I do not understand how use
    result = getURL("http://localhost:8002/desktopwebservice/dws_getinfo?xxxxxxxxxxx")

    to retrive a file..

    I am very ignorant as to the web ..

    can you help me?

    from js I call a VFP function to write a file, then I need to read from the js caller..

    thanks
    Fabio
    thanks

  4. #4
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,862
    In which folder I've to put dws_getinfo.prg library?

    thanks
    Fabio

  5. #5
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,731
    It is all described in the links.
    http://www.lianja.com/community/show...rs-Web-service

    Read that first...
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  6. #6
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,862
    It is what I reported myself, and I'm trying to put in place ..

    If the result returned starts with "file:" then the file specified e.g. "file:mytempfile.txt" is read and the result is sent back to the client. This provides the ability to query large amounts of information not limited by internal string length.
    If the result returned starts with "tempfile:" then the file specified e.g. "tempfile:mytempfile.txt" is read and the result is sent back to the client. The file mytempfile.txt is then deleted.
    and I'm trying to implement this .. but without examples is not simple ..

    Code:
    function readText()
    {
    	window.alert("ReadText");
    	result = Lianja.getUrl("http://localhost:8002/desktopwebservice/dws_getResultSearchTable");
    	
    	window.alert(result);
    	var divTabella = document.getElementById("DivTabella");
    	divTabella.innerHTML = result;
    	
    };
    but not work...


    in which folder I need to write getResultSearchTable.prg file?

    thanks
    Fabio
    Last edited by phabio; 2016-03-16 at 10:45.

  7. #7
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,862
    this my last rsp function:
    Code:
    function readText()
    {
    	window.alert("ReadText");
    	result = Lianja.getUrl("http://localhost:8002/desktopwebservice/dws_getResultSearchTable");
    	
    	window.alert(result);
    	
    	var divTabella = document.getElementById("DivTabella");
    	divTabella.innerHTML = result;
    	
    };
    and the getResultSearchTable.prg

    Code:
    return "file:file.html"
    getResultSearchTable.prg and file.html exists in Library folder, byt the "result" is every empty..

    thanks
    for any suggestion
    Fabio

  8. #8
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,862
    is there anything you do not understand ...
    I also tried it from the command line:
    Code:
    ? getUrl("http://localhost:8002/desktopwebservice/dws_getResultSearchTable")
    dws_getResultSearchTable the script exists, and inside there is only:
    Code:
    ? "Dws_getResultSearchTable"
    return "file: file.html"
    If command line write:
    ? dws_getResultSearchTable ()

    it works

    if I write:
    a = getUrl("http://localhost:8002/desktopwebservice/dws_getResultSearchTable")
    ? a

    No..

    thanks for suggestion
    desperately, Fabio

  9. #9
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,731
    You should not return it as a string you should output the string using

    ?? "file:...."
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  10. #10
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,862
    No...
    I've changed my dws_getResultSearchTable() prg to:
    ?? "file:file.html"

    but not work..

    the folder for this prg is:
    c:\lianja\library
    or
    C:\lianja\cloudserver\tenants\public\wwwroot\libra ry
    or C:\lianja\cloudserver\tenants\public\library ?

    note:
    the prg is not auto compiled..
    to have the .dbo files I need to run from command line:
    ? dws_getResultSearchTable()

Page 1 of 6 123 ... LastLast

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us