Jump to content

Starting a web browser: Difference between revisions

m
syntax highlighting fixup automation
(J)
m (syntax highlighting fixup automation)
Line 8:
=={{header|EchoLisp}}==
Since we are already in a browser window, the browser is started. '''print-hatml''' sends an html string to the standard output area. The table is styled with the "htable" css class, which is included in EchoLisp.
<langsyntaxhighlight lang="scheme">
;; table from "Separate_the_house_number_from_the_street_name"
;;
(print-html (table->html adresses))
</syntaxhighlight>
</lang>
{{out}}
 
Line 122:
=={{header|Go}}==
This uses the same format and color scheme for the table as the Raku entry.
<langsyntaxhighlight lang="go">package main
 
import (
Line 249:
err = os.Remove(fileName)
check(err)
}</langsyntaxhighlight>
 
{{out}}
Line 260:
Here, we assume that <code>browser</code> refers to a browser in a format which is usable by a command shell, and <code>din5008</code> and <code>sampledata</code> have been defined according to the [[Separate_the_house_number_from_the_street_name#J|J house number street name]] task entry:
 
<langsyntaxhighlight Jlang="j"> wrap=: {{'<',m,'>',y,'</',(;{.;:m),'>' }}(L:0)("1)
'table.htm'fwrite~'<style>tr:nth-child(even){color:blue}</style>','table' wrap ,'tr' wrap ;"1 'td' wrap din5008"1 sampledata
1660
launch browser,' table.htm'</langsyntaxhighlight>
 
(Here, 1660 was the length of the generated file.)
 
=={{header|Julia}}==
<langsyntaxhighlight lang="julia">using Tables, BrowseTables
 
function testbrowsertable(addresstext)
Line 335:
 
testbrowsertable(adressen)
</syntaxhighlight>
</lang>
 
=={{header|Nim}}==
Based on Phix solution. Using same colors as Scala program.
 
<langsyntaxhighlight Nimlang="nim">import os, strutils
 
func separateHouseNumber(address: string): tuple[street, house: string] =
Line 426:
discard execShellCmd("firefox test.html")
os.sleep(5000)
removeFile("test.html")</langsyntaxhighlight>
 
{{out}}
Line 434:
Borrowing code from the [[Separate_the_house_number_from_the_street_name|Separate the house number from the street name]] task.
{{trans|Raku}}
<langsyntaxhighlight lang="perl">use File::Temp qw(tempfile);
 
my @addresses = (
Line 509:
# wait for a bit to give browser time to load before destroying temp file
sleep 5;
</syntaxhighlight>
</lang>
{{out}}
<table border="2"> <tr bgcolor="#02ccfe"><th>Address</th><th>Street</th><th>House Number</th>
Line 547:
 
=={{header|Phix}}==
<!--<langsyntaxhighlight Phixlang="phix">(notonline)-->
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- (file i/o, system)</span>
<span style="color: #008080;">constant</span> <span style="color: #000000;">addresses</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #008000;">"Plataanstraat 5"</span><span style="color: #0000FF;">,</span>
Line 652:
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<!--</langsyntaxhighlight>-->
output as perl
 
=={{header|Racket}}==
 
<langsyntaxhighlight lang="racket">
#lang at-exp racket
 
Line 676:
@table{@render-table}}}
}
</syntaxhighlight>
</lang>
 
=={{header|Raku}}==
Line 683:
Uses the code from the [[Separate_the_house_number_from_the_street_name|Separate the house number from the street name]] task almost verbatim. Included here to make a complete, runnable example.
 
<syntaxhighlight lang="raku" perl6line>use File::Temp;
 
my $addresses = qq :to /END/;
Line 781:
# wait for a bit to give browser time to load before destroying temp file
sleep 5;
</syntaxhighlight>
</lang>
{{out}} Will start the default browser (or open a new tab/window in a running one) and display this table.
<table border="2"> <tr bgcolor="#02ccfe"><th>Address</th><th>Street</th><th>House Number</th>
Line 822:
<!-- ==={{libheader|Scala}}=== -->
Uses nothing but the Standard Library:
<langsyntaxhighlight lang="scala">import java.awt.Desktop
import java.io.{IOException, PrintWriter}
import java.net.{URI, ServerSocket}
Line 956:
do print("Do you want to shutdown this server? <Y(es)/N>: ") while (!scala.io.StdIn.readBoolean)
sys.exit()
}</langsyntaxhighlight>
{{out}}
<font face="Arial, sans-serif" size="5">Split the house number from the street name</font>
Line 963:
=={{header|Tcl}}==
{{works with|Tcl|8.6}}<!--required for [file tempfile]-->
<langsyntaxhighlight lang="tcl">package require Tcl 8.6
 
# This is identical to the address task. Skip forward to the next section...
Line 1,041:
} else {
exec xdg_open $filename
}</langsyntaxhighlight>
{{out}}
<!-- Strictly, this is just the contents of the <body> inside a <div>… --><div style="margin-left: 50px">
Line 1,054:
 
The Wren code is based in part on the Nim example and uses the same color scheme.
<langsyntaxhighlight lang="ecmascript">/* starting_web_browser.wren */
 
import "./pattern" for Pattern
Line 1,176:
File.flushAll() // flush all streams
C.sleep(5) // wait five seconds
File.remove("test.html") // remove the file</langsyntaxhighlight>
<br>
We now embed this in the following C program, compile and run it.
<langsyntaxhighlight lang="c">/* gcc starting_web_browser.c -o starting_web_browser -lwren -lm */
 
#include <stdio.h>
Line 1,330:
free(script);
return 0;
}</langsyntaxhighlight>
 
{{out}}
10,333

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.