Start from a main routine: Difference between revisions

Added Easylang
m (syntax highlighting fixup automation)
(Added Easylang)
 
(10 intermediate revisions by 7 users not shown)
Line 67:
 
=={{header|BASIC}}==
==={{header|GWBASIC}}===
{{works with|GWBASIC}}
As is well known, GWBASIC cannot refer to anything with a name. Also, does not require an executable program to have a main() procedure.
However, as in the other instances, there's nothing to stop you creating a subprocess and then calling it by its line number to start the program:
<syntaxhighlight lang="qbasic">10 'SAVE "MAIN",A
20 GOSUB 100 ' Main
30 END
100 ' Sub Main
110 CLS
120 PRINT "This is the Main sub!"
130 RETURN</syntaxhighlight>
 
==={{header|QBasic}}===
{{works with|QBasic|1.1}}
Line 165 ⟶ 177:
From Main
</pre>
 
=={{header|EasyLang}}==
<syntaxhighlight>
proc main . .
print "Hello from main!"
.
main
</syntaxhighlight>
 
=={{header|Erlang}}==
Line 278 ⟶ 298:
 
If you want the script to exit even when it hits an error, you can use an [http://www.jsoftware.com/help/dictionary/dx009.htm#26 immex phrase], which will be the first thing executed by the event loop, before it prompts.
 
=={{header|jq}}==
 
A jq program consists of a (possibly empty) sequence of directives and function definitions followed by a single (but possibly compound) jq expression that is evaluated in the context of the prior definitions. The jq expression can take many forms, such as a single JSON value, or a pipeline of filters. In particular, it could be the invocation of a previously defined function named main as in this example:
<syntaxhighlight lang="jq">
def main:
"Hello, World!";
main
</syntaxhighlight>
 
The jq interpreter has two modes of operation: a data-driven mode (the default) and an autonomous mode (corresponding to the `-n` command-line option).
In general, in the data-driven mode, the expression at the end of the jq program is evaluated once for each input, so that in the above example,
the "Hello, World!" string would be emitted once for each input.
By contrast, if the `-n` command-line option is specified, then a single JSON `null` would be presented to the final expression, so that in the above example,
the string would be emitted just once.
 
=={{header|Julia}}==
Line 688 ⟶ 724:
{{out|input=foo /bar baz "visual basic"}}
<pre>main; args:foo, /bar, baz, visual basic</pre>
 
=={{header|V (Vlang)}}==
main() is the usual entry point for a program.
<syntaxhighlight lang="Vlang">
 
fn main() {
println("hello world")
}
</syntaxhighlight>
 
However, this can be skipped in one file programs, allowing Vlang to be used like a script.
<syntaxhighlight lang="Vlang">
println("hello world")
</syntaxhighlight>
 
=={{header|Wren}}==
Line 693 ⟶ 743:
 
However, it's easy enough to create a ''main'' function and call that to start execution of the script.
<syntaxhighlight lang="ecmascriptwren">var main = Fn.new {
System.print("Hello from the main function.")
}
Line 729 ⟶ 779:
 
END PROGRAM</syntaxhighlight>
 
=={{header|XPL0}}==
XPL0 programs are normally compiled and run from a main procedure, although this procedure is not explicitly named 'main'. It is possible to compile procedures without a main procedure that are later linked to a module with a main procedure. This feature was used frequently on old, slow 6502-based computers, such as the Apple II.
 
=={{header|Z80 Assembly}}==
Line 767 ⟶ 820:
{{omit from|Java|Uses a main method}}
{{omit from|NetRexx|Uses a main method}}
{{omit from|Plain English|Programs start from a 'run' method}}
{{omit from|Python}}
{{omit from|Rust}}
{{omit from|Swift}}
{{omit from|UNIX Shell|Scripts start running from the top}}
{{omit from|XPL0}}
{{omit from|zkl}}
 
2,063

edits