Author Topic: Using A Web Browser to Display Output  (Read 6483 times)

0 Members and 1 Guest are viewing this topic.

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 704
    • Charles Pegge
Using A Web Browser to Display Output
« on: October 07, 2007, 09:07:43 AM »

Generating program outputs as web pages is a very simple and powerful method for presenting information. You can produce anything from a single line result to a multipage hypertext document with tables, images (and Javascripts even) without ever  getting involved with the underlying operating system.

The snippet below  is an R$ inline function that generates a Web page to display a small very basic table of statistics.

A refresh link on the page, which links to itself, reminds the user to update the results after each run of the program. (does the same thing as F5)

The $ sign is a sort of superquote mark. Text contained between $..$ is treated as a string and placed on the stack, when the closing $ is reached. Functions may be embedded inside this text between inverse quotes for which the `  mark is used (Ascii 96). The advantage of using this system instead of conventional strings is a clearer layout.

Following this string is the name of the htm file and the save command.

The entire function is encapsulated between ( ) round brackets so that the stack contents created inside the brackets are disallocated on completion.

R$
Code: [Select]
(
 $
 <html>
 <head>
 </head>
 <body>
 <font size=2>
 <a href="r.htm">REFRESH</a><br>
 STATS:<br>
 <table>
 <tr><td>Global Variables  </td><td>`dimsc str`</td></tr>
 <tr><td>Functions:        </td><td>`funsc str`</td></tr>
 <tr><td>Subs:             </td><td>`subsc str`</td></tr>
 <tr><td>Assembler:        </td><td>`asmsc str`</td></tr>
 <tr><td>Loops:            </td><td>`lopsc str`</td></tr>
 <tr><td>Lines:            </td><td>`linsc str`</td></tr>
 <tr><td>Intrinsics used   </td><td>`basw  str`</td></tr>
 </table>
  <br>
 `time` - `unidate`
 <br>
 </font>
 </body>
 </html>
 $
 "r.htm" save
 )

Offline Petr Schreiber

  • Sr. Member
  • ****
  • Posts: 254
Re: Using A Web Browser to Display Output
« Reply #1 on: October 07, 2007, 09:44:59 AM »
Charles,

thanks for new sample.
I am afraid I forgot how to run the scripts. I know how to load them in R$ console ( source code is printed on screen ), but how to "activate" above proggie ?



Thanks,
Petr
AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 704
    • Charles Pegge
Re: Using A Web Browser to Display Output
« Reply #2 on: October 07, 2007, 11:15:23 AM »
Hi Petr,

It is already part of the metabasic.prog  program which is invoked with mb  on the R$ console. It is on the latest version posted early this morning. For test purposes it uses the R$ source code, which is now called r$.data

But in general the way to run a program from the R$ terminal is:
 "myprog.prog" load exec

which reminds me to write a proper command line editor.
« Last Edit: October 07, 2007, 11:18:31 AM by Charles Pegge »

Offline Edwin Knoppert

  • Sr. Member
  • ****
  • Posts: 284
    • Hellobasic.com
Re: Using A Web Browser to Display Output
« Reply #3 on: October 07, 2007, 01:25:12 PM »
FYI: <br> should be <br /> :)

Offline Petr Schreiber

  • Sr. Member
  • ****
  • Posts: 254
Re: Using A Web Browser to Display Output
« Reply #4 on: October 07, 2007, 01:31:59 PM »
Hi Charles,

thanks a lot, now it works.
I think <br> can be as is, <br/> is not HTML but XHTML I think.


Bye,
Petr
AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com

Offline Edwin Knoppert

  • Sr. Member
  • ****
  • Posts: 284
    • Hellobasic.com
Re: Using A Web Browser to Display Output
« Reply #5 on: October 07, 2007, 02:25:34 PM »
it's certainly not <br/>

:)

Offline Kent Sarikaya

  • Full Member
  • ***
  • Posts: 201
Re: Using A Web Browser to Display Output
« Reply #6 on: October 07, 2007, 08:22:56 PM »
Not to change the subject, but I think you might find this site interesting Charles.
http://www.runbasic.com/

You can program via the web and also create web pages and run servers in run basic.
There is a lot there, just need to poke around. I think it is pretty interesting and well done.

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 704
    • Charles Pegge
Re: Using A Web Browser to Display Output
« Reply #7 on: October 08, 2007, 05:52:53 PM »

That's a powerful idea, and their video demos are very good. Soon we will become (if so inclined,)  Google munchkins coding directly onto their servers, with instant sharing of resources.There's a kind of inevitability to it.