• Welcome to Theos PowerBasic Museum 2017.

Using A Web Browser to Display Output

Started by Charles Pegge, October 07, 2007, 09:07:43 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Charles Pegge

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.

<font size=2>
<a href="r.htm">REFRESH</a><br>
<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>
`time` - `unidate`
"r.htm" save

Petr Schreiber


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 ?

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


Charles Pegge

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.

Edwin Knoppert

Petr Schreiber

Hi Charles,

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

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


Edwin Knoppert

Kent Sarikaya

Not to change the subject, but I think you might find this site interesting Charles.

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.

Charles Pegge

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.