Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,2 @@
---
from: http://rosettacode.org/wiki/Start_from_a_main_routine

View file

@ -0,0 +1,8 @@
Some languages (like Gambas and Visual Basic) support two startup modes.   Applications written in these languages start with an open window that waits for events, and it is necessary to do some trickery to cause a main procedure to run instead.   Data driven or event driven languages may also require similar trickery to force a startup procedure to run.
;Task:
Demonstrate the steps involved in causing the application to run a main procedure, rather than an event driven window at startup.
Languages that always run from main() can be omitted from this task.
<br><br>

View file

@ -0,0 +1,3 @@
BEGIN
print( ( "Hello, World!", newline ) )
END

View file

@ -0,0 +1,4 @@
BEGIN {
# This is our main startup procedure
print "Hello World!"
}

View file

@ -0,0 +1,5 @@
with Ada.Text_IO;
procedure Foo is
begin
Ada.Text_IO.Put_Line("Bar");
end Foo;

View file

@ -0,0 +1,5 @@
main: function [][
print "Yes, we are in main!"
]
main

View file

@ -0,0 +1,5 @@
subroutine main()
print "Hello from main!"
end subroutine
call main()

View file

@ -0,0 +1,9 @@
#include<stdio.h>
#define start main()
int start
{
printf("Hello World !");
return 0;
}

View file

@ -0,0 +1,13 @@
MODULE MainProcedure;
IMPORT StdLog;
PROCEDURE Do*;
BEGIN
StdLog.String("From Do");StdLog.Ln
END Do;
PROCEDURE Main*;
BEGIN
StdLog.String("From Main");StdLog.Ln
END Main;
END MainProcedure.

View file

@ -0,0 +1,6 @@
USE: io
IN: example
: hello ( -- ) "Hello, world!" print ;
MAIN: hello

View file

@ -0,0 +1,5 @@
include foo.fs
...
: main ... ;
main bye

View file

@ -0,0 +1 @@
$ gforth -e "2 2 + . bye"

View file

@ -0,0 +1 @@
' main turnkey app.exe

View file

@ -0,0 +1,8 @@
' FB 1.05.0 Win64
Sub main()
Print "Hello from main!"
End Sub
main
Sleep

View file

@ -0,0 +1,3 @@
PUBLIC SUB Main()
' This is the start of the program
END

View file

@ -0,0 +1,24 @@
package main
import "fmt"
var count = 0
func foo() {
fmt.Println("foo called")
}
func init() {
fmt.Println("first init called")
foo()
}
func init() {
fmt.Println("second init called")
main()
}
func main() {
count++
fmt.Println("main called when count is", count)
}

View file

@ -0,0 +1 @@
:- initialization(main).

View file

@ -0,0 +1,4 @@
: main(n)
"Sleeping..." println
n sleep
"Awake and leaving." println ;

View file

@ -0,0 +1,6 @@
: main(n)
"Sleeping..." println
n sleep
"Awake and leaving." println ;
10000 main

View file

@ -0,0 +1,4 @@
BEGIN {...} # as soon as parsed
CHECK {...} # end of compile time
INIT {...} # beginning of run time
END {...} # end of run time

View file

@ -0,0 +1,6 @@
-->
<span style="color: #008080;">procedure</span> <span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<span style="color: #0000FF;">...</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<!--

View file

@ -0,0 +1,2 @@
println("hello world");
line(0, 0, width, height);

View file

@ -0,0 +1,4 @@
void hello() {
println("hello world");
}
hello();

View file

@ -0,0 +1,6 @@
void setup() {
hello();
}
void hello() {
println("hello world");
}

View file

@ -0,0 +1,5 @@
SUB main
PRINT "Hello from main!"
END SUB
main

View file

@ -0,0 +1,4 @@
[ say "Please use the shell to calculate a value" cr
say "and leave it on the stack. Type 'leave' when" cr
say "you have done this." cr
shell ] constant is my-value

View file

@ -0,0 +1,9 @@
/*REXX*/
address 'XEDIT'
.
.
.
[XEDIT commands here.]
.
.
.

View file

@ -0,0 +1,4 @@
#/usr/bin/env racket -tm
#lang racket
(provide main)
(define (main . args) (displayln "Hello World!"))

View file

@ -0,0 +1,4 @@
BEGIN {...} # as soon as parsed
CHECK {...} # end of compile time
INIT {...} # beginning of run time
END {...} # end of run time

View file

@ -0,0 +1,2 @@
func Main
see "Hello World!" + nl

View file

@ -0,0 +1,7 @@
BEGIN {
# begin code
}
END {
# end code
}

View file

@ -0,0 +1,5 @@
sub main
print "Hello from main!"
end sub
call main

View file

@ -0,0 +1,7 @@
object PrimaryMain extends App {
Console.println("Hello World: " + (args mkString ", "))
}
object MainTheSecond extends App {
Console.println("Goodbye, World: " + (args mkString ", "))
}

View file

@ -0,0 +1,12 @@
# This code runs only for line 1.
1 {
i\
Explain-a-lot processed this file and
i\
replaced every period with three exclamation points!!!
i\
}
# This code runs for each line of input.
s/\./!!!/g

View file

@ -0,0 +1,6 @@
$ include "seed7_05.s7i";
const proc: main is func
begin
writeln("hello world");
end func;

View file

@ -0,0 +1,10 @@
$ include "seed7_05.s7i";
include "draw.s7i";
include "keybd.s7i";
const proc: main is func
begin
screen(200, 200);
KEYBOARD := GRAPH_KEYBOARD;
ignore(getc(KEYBOARD));
end func;

View file

@ -0,0 +1,6 @@
SUB main
PRINT "Hello from main!"
END SUB
CALL main
END

View file

@ -0,0 +1,3 @@
fn main() {
println("hello world")
}

View file

@ -0,0 +1 @@
println("hello world")

View file

@ -0,0 +1,35 @@
Imports System.Collections.ObjectModel
Imports Microsoft.VisualBasic.ApplicationServices
Namespace My
' The following events are available for MyApplication:
' Startup: Raised when the application starts, before the startup form is created.
' Shutdown: Raised after all application forms are closed. This event is not raised if the application terminates abnormally.
' UnhandledException: Raised if the application encounters an unhandled exception.
' StartupNextInstance: Raised when launching a single-instance application and the application is already active.
' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
Partial Friend Class MyApplication
'''<summary>Sets the visual styles, text display styles, and current principal for the main application thread
'''(if the application uses Windows authentication), and initializes the splash screen, if defined.</summary>
'''<param name="commandLineArgs">A <see cref="ReadOnlyCollection(Of T)" /> of <see langword="String" />,
'''containing the command-line arguments as strings for the current application.</param>
'''<returns>A <see cref="T:System.Boolean" /> indicating if application startup should continue.</returns>
Protected Overrides Function OnInitialize(commandLineArgs As ReadOnlyCollection(Of String)) As Boolean
Console.WriteLine("oninitialize; args: " & String.Join(", ", commandLineArgs))
Return MyBase.OnInitialize(commandLineArgs)
End Function
' WindowsFormsApplicationBase.Startup occurs "when the application starts".
Private Sub MyApplication_Startup(sender As Object, e As StartupEventArgs) Handles Me.Startup
Console.WriteLine("startup; args: " & String.Join(", ", e.CommandLine))
End Sub
'''<summary>Provides the starting point for when the main application is ready to start running, after the
'''initialization is done.</summary>
Protected Overrides Sub OnRun()
Console.WriteLine("onrun")
MyBase.OnRun()
End Sub
End Class
End Namespace

View file

@ -0,0 +1,6 @@
Module Main
Sub Main(args As String())
Console.WriteLine("main; args:" & String.Join(", ", args))
Application.Run(New Form1())
End Sub
End Module

View file

@ -0,0 +1,3 @@
SUB Main()
' This is the start of the program
END

View file

@ -0,0 +1,5 @@
var main = Fn.new {
System.print("Hello from the main function.")
}
main.call()

View file

@ -0,0 +1,3 @@
FUNCTION main ()
'This is the beginning of the program
END FUNCTION

View file

@ -0,0 +1,14 @@
PROGRAM "Start from a main routine"
DECLARE FUNCTION Entry ()
DECLARE FUNCTION main ()
FUNCTION Entry ()
main ()
END FUNCTION
FUNCTION main ()
PRINT "Hello from main!"
END FUNCTION
END PROGRAM

View file

@ -0,0 +1,5 @@
sub main()
print "Hello from main!"
end sub
main()

View file

@ -0,0 +1 @@
org &8000

View file

@ -0,0 +1 @@
SAVE "MYPROG" LINE 500: REM For a program with main code starting at line 500

View file

@ -0,0 +1 @@
"Hello".println()