Jump to content

Modulinos: Difference between revisions

m
change header from Freepascal, which does not exist, to Pascal and add a works-with
(Added Groovy)
m (change header from Freepascal, which does not exist, to Pascal and add a works-with)
Line 426:
 
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}}==
Line 995 ⟶ 937:
 
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}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.