Calling browser from J to present results

This is a discussion on Calling browser from J to present results within the APL forums in Programming Languages category; I have been wondering for some time how to call a browser and present data from J on a page. For some reason I thought it would need some programming and have not given myself time to do it but as it turns out it is embarrasingly easy to do. I put up a script on http://groups.google.com/group/J-Programming called vafrakall.ijs In Íslandish "vafri" means "browser" and "vafrakall" means "calling the browser" What is needed is: require'files ~system/extras/util/browser.ijs' NB. put some html lines into a a fwrite 'C:/temp/test.html' launch_jbrowser_ 'file:///C:/temp/test.html'...

Go Back   Application Development Forum > Programming Languages > APL

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 05-31-2008, 12:32 PM
Gosi
Guest
 
Default Calling browser from J to present results

I have been wondering for some time how to call a browser and present
data from J on a page.

For some reason I thought it would need some programming and have not
given myself time to do it but as it turns out it is embarrasingly
easy to do.

I put up a script on
http://groups.google.com/group/J-Programming
called
vafrakall.ijs

In Íslandish "vafri" means "browser" and "vafrakall" means "calling
the browser"

What is needed is:

require'files ~system/extras/util/browser.ijs'

NB. put some html lines into a

a fwrite 'C:/temp/test.html'

launch_jbrowser_ 'file:///C:/temp/test.html'
Reply With Quote
  #2  
Old 05-31-2008, 05:41 PM
kai
Guest
 
Default Re: Calling browser from J to present results

On May 31, 5:32 pm, Gosi <gos...@gmail.com> wrote:
> I have been wondering for some time how to call a browser and present
> data from J on a page.


I take it that this msg made it accidentically into comp.lang.apl?

Anyway, what about the performance - bit slow I guess?
Reply With Quote
  #3  
Old 05-31-2008, 06:43 PM
Gosi
Guest
 
Default Re: Calling browser from J to present results

On May 31, 9:41*pm, kai <kaithomas...@googlemail.com> wrote:
> On May 31, 5:32 pm, Gosi <gos...@gmail.com> wrote:
>
> > I have been wondering for some time how to call a browser and present
> > data from J on a page.

>
> I take it that this msg made it accidentically into comp.lang.apl?
>
> Anyway, what about the performance - bit slow I guess?


Actually I would like to get a similar option from APL.
I may have overlooked something there as well or when I have asked I
may not have been understood.
I guess it is equally simple to do in APL as in J and I have missed it
in APL just like I missed it in J up till now.
If the people who know how to do this in APL want to answer they can
see exactly what I mean.
I have asked before and never got an answer.
Probably because people who know how to do this think it so simple
that they think that I can not be asking such a simple question.
So instead of discussing performance which incidentally is excelent as
is usual in J.
Both writing code and executing it.
I would rather get some real answers if possible.
I put another script there too vafranidurstodur.ijs which is similar
to the first but does execute some code and displays the results.
Sometimes the simple things can be hard to get.
Reply With Quote
  #4  
Old 06-01-2008, 02:27 AM
kai
Guest
 
Default Re: Calling browser from J to present results

> > I take it that this msg made it accidentically into comp.lang.apl?
>
> > Anyway, what about the performance - bit slow I guess?

>
> Actually I would like to get a similar option from APL.
> I may have overlooked something there as well or when I have asked I
> may not have been understood.


Even after re-reading you original message I could not find any
question at all

> I guess it is equally simple to do in APL as in J and I have missed it
> in APL just like I missed it in J up till now.
> If the people who know how to do this in APL want to answer they can
> see exactly what I mean.


Well, yes, it is:
)cmd C:\Documents and Settings\kai\My Documents\myHtmlPage.html

....
> So instead of discussing performance which incidentally is excelent as
> is usual in J. Both writing code and executing it.


There is a performance issue with Dyalog so why shouldn't I ask? On my
machine the command listed above needs 18 seconds until the page is
eventually displayed. More or less the same on my notebook, with an
already running browser.


Reply With Quote
  #5  
Old 06-01-2008, 02:54 AM
Ibeam2000
Guest
 
Default Re: Calling browser from J to present results

Under Microsoft, with any of the APLs which support COM, you should be
able to automate Windows Explorer. This means, with APL, you can
start the browser, load documents, load web pages, have limited access
to the document itself, and close the browser. You could program a
kind of slide show. The interface was designed to automate the
browser, and little more.

What the Microsoft Explorer interface was not good at doing was any
kind of bulk data loading. Suppose you had a huge document (say 500K
or more) of text which you wanted to download. The interface could
never reliably tell you whether the document was finished or not, and
often you could not retrieve more than the first part of it. I wrote
some code for MSIE 5.0 and it is still working with 6.0, perhaps 7.0
is better, more complete, and more reliable.

What was sometimes useful was the document object model where if you
downloaded certain types of documents, such as Word files or Excel
spreadsheets, you could take them apart using the underlying object
model. What you couldn't do is get the raw text of the document,
which was often all that you needed.

For bulk data loading, Netscape 4.0 had a much better COM interface.
You would have to get the larger document in pieces (a little
catenation), but it was quite reliable.

To my knowledge, the early Firefox did not have any of the COM support
of its predecessor, Netscape,

Perhaps the most promising thing about Firefox is the built-in Mozilla
engine, in principle you should be able to dynamically compose XML-
like documents which then turn into visual controls. This potentially
replaces all of the GUI features built into the various APLs, however,
from my limited knowledge, it still looks difficult to invoke
callbacks to APL from Mozilla.

Reply With Quote
  #6  
Old 06-01-2008, 03:59 AM
graham
Guest
 
Default Re: Calling browser from J to present results


"Ibeam2000" <Ibeam2000@gmail.com> wrote in message
news:fd7f156f-ad6c-4015-8162-09b5b1194c58@d77g2000hsb.googlegroups.com...

[Snip]

> What was sometimes useful was the document object model where if you
> downloaded certain types of documents, such as Word files or Excel
> spreadsheets, you could take them apart using the underlying object
> model. What you couldn't do is get the raw text of the document,
> which was often all that you needed.


[Snip]

If all you want is to receive the the text or the object model of the
document directly into APL have you tried using the XMLHTTP control. Below
is a rough and ready APL+WIN function to receive the text of an HTML
document. If you explore the controls methods you will see how to get the
object model instead.

Graham.

r <- GetHTML url
0 0{rho}'HTTP' []WI 'Create' 'Microsoft.XMLHTTP'
0 0{rho}'HTTP' []WI 'XOpen' 'GET' url 0
0 0{rho}'HTTP' []WI 'XSend'
r <- 'HTTP' []WI 'xstatusText'
:if 2=+/r{find}'OK'
r <- 'HTTP' []WI 'xresponseText'
0 0{rho}'HTTP' []WI 'Delete'
:endif


Reply With Quote
  #7  
Old 06-01-2008, 04:00 AM
Morten Kromberg
Guest
 
Default Re: Calling browser from J to present results

On May 31, 6:32Â*pm, Gosi <gos...@gmail.com> wrote:
> I have been wondering for some time how to call a browser and present
> data from J on a page.


And kai wrote:
> Anyway, what about the performance - bit slow I guess?


Internet Explorer provides an "OCX" control that can be embedded in
Dyalog GUI objects, I don't know whether the same is possible in J.
Firefox probably provides something similar. Using these is fairly
straightforward:

'WB' ⎕WC 'OCXCLASS' 'Microsoft Web Browser' // Make an OCXCLASS
object linked to IE
'F' ⎕WC 'Form' // Create a form
'F.WB' ⎕WC 'WB' // Create an
instance of WB withing the form
F.B.Navigate2⊂'c:\..mywebpage.htm' // Tell it where to
go

This doesn't seem to have the heavy startup cost of launching IE from
the command line, and also gives you more control, if you take the
time to learn about a few of the properties and methods of the Web
Browser OCX control. You can also take control of callbacks, handling
links in the web page "virtually" and generating new html on the fly,
giving the impression of having dynamic web content. I seem to
remember this required a little trickery that Stephen Taylor figured
out how to do.

Morten

Reply With Quote
  #8  
Old 06-01-2008, 08:11 AM
Morten Kromberg
Guest
 
Default Re: Calling browser from J to present results

On 1 Jun., 10:00, Morten Kromberg <mk...@dyalog.com> wrote:
> F.B.Navigate2$B">(B'c:\..mywebpage.htm'


That should of course have been

F.WB.Navigate2$B">(B'c:\..mywebpage.htm'
Reply With Quote
  #9  
Old 06-02-2008, 07:20 AM
Stephen Taylor
Guest
 
Default Re: Calling browser from J to present results

On Jun 1, 9:00 am, Morten Kromberg <mk...@dyalog.com> wrote:
> On May 31, 6:32 pm, Gosi <gos...@gmail.com> wrote:
>
> > I have been wondering for some time how to call a browser and present
> > data from J on a page.

> And kai wrote:
> > Anyway, what about the performance - bit slow I guess?

>
> Internet Explorer provides an "OCX" control that can be embedded in
> Dyalog GUI objects, I don't know whether the same is possible in J.
> Firefox probably provides something similar. Using these is fairly
> straightforward:
>
> 'WB' ⎕WC 'OCXCLASS' 'Microsoft Web Browser' // Make an OCXCLASS
> object linked to IE
> 'F' ⎕WC 'Form' // Create a form
> 'F.WB' ⎕WC 'WB' // Create an
> instance of WB withing the form
> F.B.Navigate2⊂'c:\..mywebpage.htm' // Tell it where to
> go
>
> This doesn't seem to have the heavy startup cost of launching IE from
> the command line, and also gives you more control, if you take the
> time to learn about a few of the properties and methods of the Web
> Browser OCX control. You can also take control of callbacks, handling
> links in the web page "virtually" and generating new html on the fly,
> giving the impression of having dynamic web content. I seem to
> remember this required a little trickery that Stephen Taylor figured
> out how to do.
>
> Morten


I'm using this technique very satisfactorily in a current application.
The application GUI has an embedded browser OCX. Various 'business
objects' support a Display method that returns HTML, including
hyperlinks to other displays. The application gets that into the
browser OCX. No webserver is used, but it would not be a big step to
incorporate one, translate the GUI controls into HTML, and deploy the
whole application through HTTP.

Stephen
Reply With Quote
  #10  
Old 06-02-2008, 07:45 AM
Gosi
Guest
 
Default Re: Calling browser from J to present results

On Jun 1, 12:11 pm, Morten Kromberg <mk...@dyalog.com> wrote:
> On 1 Jun., 10:00, Morten Kromberg <mk...@dyalog.com> wrote:
>
> > F.B.Navigate2$B">(B'c:\..mywebpage.htm'

>
> That should of course have been
>
> F.WB.Navigate2$B">(B'c:\..mywebpage.htm'


I got a good tip from Morten to tell the browser that the data is
UTF-8

<HEAD>

<META http-equiv="Content-Type" content="text/html; charset=UTF-8">

</HEAD>

Firefox did this automatically but ie did not.
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 08:53 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.