Fork: Difference between revisions
Dialects of BASIC moved to the BASIC section.
(Dialects of BASIC moved to the BASIC section.) |
|||
Line 70:
MsgBox, 0, Fork, Stop this process.</syntaxhighlight>
=={{header|
==={{header|BaCon}}===
<syntaxhighlight lang="freebasic">' Fork
pid = FORK
Line 96 ⟶ 97:
Waiting for child to exit
I am the child, my PID is:12733</pre>
==={{header|FreeBASIC}}===
In Windows without using windows.bi, we can use a vbscript command.
<syntaxhighlight lang="freebasic">
Function script(s As String) As String
Dim As String g = _
"Set WshShell = WScript.CreateObject(""WScript.Shell"")" + _
Chr(13,10) + "Return = WshShell.Run("""+s+" "",1,0)"
Return g
End Function
Function guardaArchivo(nombreArchivo As String, p As String) As String
Dim As Long n = Freefile
If Open (nombreArchivo For Binary Access Write As #n) = 0 Then
Put #n,,p
Close
Else
Print "No se puede guardar " + nombreArchivo : Sleep : End
End If
Return nombreArchivo
End Function
Sub ejecutaScript(nombreArchivo As String)
Shell "cscript.exe /Nologo " + nombreArchivo
End Sub
Var g = script("notepad.exe") '<< ejecuta este .exe (notepad como demo)
guardaArchivo("script.vbs",g)
ejecutaScript("script.vbs")
Dim As String s
Print "Hola"
Input "Teclee algo: ", s
Print s
Kill "script.vbs"
Sleep
</syntaxhighlight>
==={{header|Run BASIC}}===
You can run a program until that program executes a wait statement.
Once the program waits,you can use it's functions.
<syntaxhighlight lang="runbasic">run "someProgram.bas",#handle
render #handle ' this runs the program until it waits
' both the parent and child are running
' --------------------------------------------------------
' You can also call a function in the someProgram.bas program.
' For example if it had a DisplayBanner Funciton.
#handle DisplayBanner("Welcome!")</syntaxhighlight>
==={{header|Visual Basic .NET}}===
{{trans|C#}}
<syntaxhighlight lang="vbnet">Module Module1
Sub Fork()
Console.WriteLine("Spawned Thread")
End Sub
Sub Main()
Dim t As New System.Threading.Thread(New Threading.ThreadStart(AddressOf Fork))
t.Start()
Console.WriteLine("Main Thread")
t.Join()
End Sub
End Module</syntaxhighlight>
=={{header|Batch File}}==
Line 696 ⟶ 763:
</pre>
=={{header|Go}}==
Line 1,444 ⟶ 1,473:
end
# parent code</syntaxhighlight>
=={{header|Rust}}==
Line 1,647 ⟶ 1,664:
<syntaxhighlight lang="bash">(echo "Process 1" >&2 ;sleep 5; echo "1 done" ) | (echo "Process 2";cat;echo "2 done")</syntaxhighlight>
=={{header|Wart}}==
|