Page 2 of 6 FirstFirst 1234 ... LastLast
Results 11 to 20 of 52

Thread: Read ascii file

  1. #11
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,893
    Some suggestion or little sample?
    I've try all the possible combination..

    thanks
    Fabio

  2. #12
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,893
    possible that the PRG should be in the folder:
    C:\lianja\cloudserver\tenants\public\wwwroot\libra ry?
    I put it there and, as firefox, if I enter:
    http://localhost:8001/library/dws_ge...earchTable.org
    I get:
    file: file.html
    so I changed my file to dws_getResultSearchTable.prg
    [Code]
    ?? [<Table width = "100%" height = "10%" cellpadding = "5" cellspacing = "2" bgcolor = "white" border = 2px id = "table">]
    ?? [<Tr bgcolor = "gray">]
    ?? [<Td align = "center" colspan = "3">]
    ?? [</ Td>]
    ?? [</ Tr>]
    ?? [<Tr bgcolor = "# eaeaea">]
    ?? [<Tr bgcolor = "& rowcolor" class = "datacellgridline">]
    ............
    ..
    .
    [/ Code]
    and on firefox I get my nice HTML page ..



    therefore, the folder "Desktop webservice" is actually "library"?
    Now ... how do I use getUrl to populate my WebView?
    Code:
    READTEXT function ()
    {Window.alert ( "ReadText"); 
    result = Lianja.getUrl ( "http://localhost:8001/library/dws_getResultSearchTable.prg"); 
    window.alert (result); 
    divTabella var = document.getElementById ( "DivTabella"); 
    divTabella.innerHTML = result ;
    };
    does not work..
    reading here:
    Your service may return a JSON encoded object (as shown above), an XML string, string an HTML 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.
    I understood that if the prg returns: "file: file.html", then my variable "result" would be a string with the contents of the file "file.html" ..
    where am I wrong?

    I've try with port 8001 and 8002..

    thank you
    Last edited by phabio; 2016-03-17 at 09:48.

  3. #13
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,842
    Hi Fabio,

    This is not really the method that has been discussed so far, but might work for what you want to do:

    Code:
    <%@ Language=VFP %>
    <html>
    <head>
    </head>
    <body>
    <button id=test" type="button" onclick="readText()">Test</button>
    <div id="DivTabella">
    Click Test
    </div>
    <script type='text/javascript'>
    function readText()
    {
    	window.alert("ReadText");
    	document.getElementById("DivTabella").innerHTML ='<iframe src="http:/localhost:8002/file.html" width="100%" height="100" scrolling="no" frameborder="0"></iframe>';
    };
    </script>
    </body>
    </html>
    Note: file.htm is in the App. There are various attributes you can set on the iframe.

    Regards,

    Yvonne

  4. #14
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,893
    just fantastic ..

    Thanks Yvonne, too many parameters .. and without even an example, I would have never arrived ...

    Just finished writing the whole thing.

    Thanks again

    Fabio

  5. #15
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,893
    Only one problem left...

    in my HTML file I've a row like this:
    Code:
    <td>
    <input width="100%" type="text" value="" id="cod_art" onchange="filterComments('Z')" >
    </td>
    <td>
    <input width="100%" type="text" value="" id="catmercgam" onchange="filterComments('Z')" >
    </td>
    <td>
    <input width="100%" type="text" value="" id="des_web" onchange="filterComments('Z')" >
    </td>
    Now, the "filterComments" js function are never called...

    it's because now are all inside a "iframe"?

    thanks
    Fabio

  6. #16
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,165
    Blog Entries
    22
    In the HTML you generate into the iframe you can reference functions in the parent like this.

    window.parent.filterComments('Z')

    You can get a reference to the Lianja system object in the parent like this then use it in an iframe:

    window.Lianja = window.parent.Lianja;

    You can now reference all UI objects in the WebView.
    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

  7. #17
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,893
    Thans Barry, I try later..

  8. #18
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,893
    no... do not work..

    this is the body:
    Code:
    <body onload="filterComments('X');">
    <%
    proc drawTable()
    	? ('<p id="Query">' + '</p>')
    	? ('<div id="DivTabella" title="Tabella">')
    	? ('</div>')
    //	list html off &m_fields onclick m_target,"selectitem('{}')"	
    endproc
    
    drawTable()
    
    %>
    </body>
    this is the filterComments js function
    Code:
    function filterComments(m_empty)
    {	
    	var search_str;
    	var data = "&m_fields";
    	var dataquery = "&m_query";
    	var table = "&m_table";
    	var cursor = "&m_cursor";
    	var caption = "&m_caption";
    	var target = "&m_target";
    	var	execute = "";
    	
    	var datasets = [];
    	var querysets = [];
    	var i;
    	var value;
    	var	query = "";
    	var valore;
    	
    	window.alert("FilterComments");
    	
     	if (data.indexOf(",") > 0)
    	{		
    		datasets = data.split(",");	
    		querysets = dataquery.split(",");
    				
    		for (i=0; i<datasets.length; ++i) 
    		{
    			value = datasets[i];
    			
    			if (m_empty == "X")
    			{
    				valore = "";
    				valore = querysets[i];
    			}
    			else
    			{	
    				valore = document.getElementById(value).value ;
    			};
    			
    			query = query + ";" + value + "|" + valore;
    		}			
    		
    		query = query.substr(1);
    		document.getElementById('Query').innerHTML = 'Query = select ' + table + " where " + query;
    						
    		execute = 'sup_Search_sectionRefresh("' + table + '","' + cursor + '","' + query + '","' + caption + '","' + target + '")';
    		
    		var innerHTML = Lianja.evaluate(execute);
    
    		window.alert("Call read text");
    		
    		document.getElementById("DivTabella").innerHTML ='<iframe src="http:/localhost:8002/' + innerHTML + '" width="100%" height="90%" scrolling="yes" frameborder="0"></iframe>';
    			
    	}
    	else
    	{
    		Lianja.showMessage("Criteri non configurati correttamente");	
    		return;
    	}		
    	
    };
    and this the first row of my table..

    Code:
    <table width="100%" height="10%" cellpadding="5" cellspacing="2" bgcolor="white" border=2px id="tabella">
    <tr bgcolor="gray">
    <td align="center" colspan="3">
    </td>
    </tr>
    <tr bgcolor="#eaeaea">
    <tr bgcolor="&rowcolor" class="datacellgridline">
    <td valign=top align=left> <b>
    Articolo
    </td> </b>
    <td valign=top align=left> <b>
    Cat. merc.
    </td> </b>
    <td valign=top align=left> <b>
    Descrizione
    </td> </b>
    </tr>
    <td>
    <input width="100%" type="text" value="" id="cod_art" onchange="window.parent.filterComments('Z')" >
    </td>
    <td>
    <input width="100%" type="text" value="" id="catmercgam" onchange="window.parent.filterComments('Z')" >
    </td>
    <td>
    <input width="100%" type="text" value="" id="des_web" onchange="window.parent.filterComments('Z')" >
    </td>
    </tr>
    if I put filterComments inside the file .. something works the filterComments function is called, but then it does not work .. maybe because it fails referencing variables ..

    Can be the "div" in the Body the problem?

    thanks again

    Fabio

  9. #19
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,842
    Hi Fabio,

    With the filterComments function inside the html file, when it fails, right-click in the WebView Section and choose 'Inspect' and see what the error being returned is.

    Regards,

    Yvonne

  10. #20
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,893
    With funcion inside at the file, not see the variable "&m_fields"..

    Code:
    function filterComments(m_empty)
    {	
    	var search_str;
    	var data = "&m_fields";
    	var dataquery = "&m_query";
    	var table = "&m_table";
    	var cursor = "&m_cursor";
    	var caption = "&m_caption";
    	var target = "&m_target";
    	var	execute = "";
    	
    	var datasets = [];
    	var querysets = [];
    	var i;
    	var value;
    	var	query = "";
    	var valore;
    	
    	window.alert("FilterComments");
    	
     	if (data.indexOf(",") > 0)
    	{		
    	
    		window.alert("Data ok");
    		datasets = data.split(",");	
    		querysets = dataquery.split(",");
    With the solution proposed from Barry, the function should remain in the RSP file, but
    <input width="100%" type="text" value="" id="catmercgam" onchange="window.parent.filterComments('Z')" >
    not work.

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