Modulinos: Difference between revisions
Content added Content deleted
(Added Groovy) |
m (change header from Freepascal, which does not exist, to Pascal and add a works-with) |
||
Line 426: | Line 426: | ||
cr .( Why aren't you running this as a script? It only provides a constant.)</lang> |
cr .( Why aren't you running this as a script? It only provides a constant.)</lang> |
||
=={{header|Free Pascal}}== |
|||
Makefile: |
|||
<lang make>all: scriptedmain |
|||
scriptedmain: scriptedmain.pas |
|||
fpc -dscriptedmain scriptedmain.pas |
|||
test: test.pas scriptedmain |
|||
fpc test.pas |
|||
clean: |
|||
-rm test |
|||
-rm scriptedmain |
|||
-rm *.o |
|||
-rm *.ppu</lang> |
|||
scriptedmain.pas: |
|||
<lang pascal>{$IFDEF scriptedmain} |
|||
program ScriptedMain; |
|||
{$ELSE} |
|||
unit ScriptedMain; |
|||
interface |
|||
function MeaningOfLife () : integer; |
|||
implementation |
|||
{$ENDIF} |
|||
function MeaningOfLife () : integer; |
|||
begin |
|||
MeaningOfLife := 42 |
|||
end; |
|||
{$IFDEF scriptedmain} |
|||
begin |
|||
write('Main: The meaning of life is: '); |
|||
writeln(MeaningOfLife()) |
|||
{$ENDIF} |
|||
end.</lang> |
|||
test.pas: |
|||
<lang pascal>program Test; |
|||
uses |
|||
ScriptedMain; |
|||
begin |
|||
write('Test: The meaning of life is: '); |
|||
writeln(MeaningOfLife()) |
|||
end.</lang> |
|||
Example: |
|||
<lang sh>$ make |
|||
$ ./scriptedmain |
|||
Main: The meaning of life is: 42 |
|||
$ make test |
|||
$ ./test |
|||
Test: The meaning of life is: 42</lang> |
|||
=={{header|Go}}== |
=={{header|Go}}== |
||
Line 995: | Line 937: | ||
printf("Test: The meaning of life is %d", meaningoflife());</lang> |
printf("Test: The meaning of life is %d", meaningoflife());</lang> |
||
=={{header|Pascal}}== |
|||
{{works with|Free_Pascal}} |
|||
Makefile: |
|||
<lang make>all: scriptedmain |
|||
scriptedmain: scriptedmain.pas |
|||
fpc -dscriptedmain scriptedmain.pas |
|||
test: test.pas scriptedmain |
|||
fpc test.pas |
|||
clean: |
|||
-rm test |
|||
-rm scriptedmain |
|||
-rm *.o |
|||
-rm *.ppu</lang> |
|||
scriptedmain.pas: |
|||
<lang pascal>{$IFDEF scriptedmain} |
|||
program ScriptedMain; |
|||
{$ELSE} |
|||
unit ScriptedMain; |
|||
interface |
|||
function MeaningOfLife () : integer; |
|||
implementation |
|||
{$ENDIF} |
|||
function MeaningOfLife () : integer; |
|||
begin |
|||
MeaningOfLife := 42 |
|||
end; |
|||
{$IFDEF scriptedmain} |
|||
begin |
|||
write('Main: The meaning of life is: '); |
|||
writeln(MeaningOfLife()) |
|||
{$ENDIF} |
|||
end.</lang> |
|||
test.pas: |
|||
<lang pascal>program Test; |
|||
uses |
|||
ScriptedMain; |
|||
begin |
|||
write('Test: The meaning of life is: '); |
|||
writeln(MeaningOfLife()) |
|||
end.</lang> |
|||
Example: |
|||
<lang sh>$ make |
|||
$ ./scriptedmain |
|||
Main: The meaning of life is: 42 |
|||
$ make test |
|||
$ ./test |
|||
Test: The meaning of life is: 42</lang> |
|||
=={{header|Perl}}== |
=={{header|Perl}}== |