Program name: Difference between revisions

Content added Content deleted
(Add Zig example)
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 78: Line 78:
<lang aime>o_text(argv(0));
<lang aime>o_text(argv(0));
o_byte('\n');</lang>
o_byte('\n');</lang>

=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==
<lang>
<lang>
Line 90: Line 91:
$
$
</pre>
</pre>

=={{header|Applesoft BASIC}}==
=={{header|Applesoft BASIC}}==
<lang ApplesoftBASIC>
<lang ApplesoftBASIC>
Line 154: Line 156:
680 RETURN
680 RETURN
</lang>
</lang>

=={{header|ARM Assembly}}==
=={{header|ARM Assembly}}==
{{works with|as|Raspberry Pi}}
{{works with|as|Raspberry Pi}}
Line 213: Line 216:
</lang>
</lang>

=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==
<lang AutoHotkey>
<lang AutoHotkey>
MsgBox, % A_ScriptName
MsgBox, % A_ScriptName
</lang>
</lang>

=={{header|AWK}}==
=={{header|AWK}}==
<lang AWK>
<lang AWK>
Line 422: Line 427:
<pre>Path to executable: C:\Users\kernigh\Documents\field\scratch.exe</pre>
<pre>Path to executable: C:\Users\kernigh\Documents\field\scratch.exe</pre>


=={{header|C++}}==
C++ has difficulty accessing source code filenames, because C code must be compiled into an executable. However, C++ can access the executable's filename.

<lang cpp>#include <iostream>

using namespace std;

int main(int argc, char **argv) {
char *program = argv[0];
cout << "Program: " << program << endl;

return 0;
}</lang>
=={{header|C sharp|C#}}==
=={{header|C sharp|C#}}==
This effectively outputs the executable name, file path, and any arguments for the current program.
This effectively outputs the executable name, file path, and any arguments for the current program.
Line 467: Line 459:
}
}
}
}
}</lang>

=={{header|C++}}==
C++ has difficulty accessing source code filenames, because C code must be compiled into an executable. However, C++ can access the executable's filename.

<lang cpp>#include <iostream>

using namespace std;

int main(int argc, char **argv) {
char *program = argv[0];
cout << "Program: " << program << endl;

return 0;
}</lang>
}</lang>


Line 624: Line 630:
→ "http://www.echolalie.org/echolisp/"
→ "http://www.echolalie.org/echolisp/"
</lang>
</lang>

=={{header|Elena}}==
=={{header|Elena}}==
ELENA 4.x :
ELENA 4.x :
Line 1,117: Line 1,124:
module(..., package.seeall)
module(..., package.seeall)
end</lang>
end</lang>

=={{header|M2000 Interpreter}}==
=={{header|M2000 Interpreter}}==
<lang M2000 Interpreter>
<lang M2000 Interpreter>
Line 1,160: Line 1,168:


Print["Program: " <> Program]</lang>
Print["Program: " <> Program]</lang>



=={{header|Mercury}}==
=={{header|Mercury}}==
Line 1,209: Line 1,216:
end
end
</lang>
</lang>

=={{header|Nanoquery}}==
<lang Nanoquery>println args[1]</lang>
{{out}}
<pre>programname.nq</pre>


=={{header|Nemerle}}==
=={{header|Nemerle}}==
Line 1,241: Line 1,253:
Program: pn.jar
Program: pn.jar
</pre>
</pre>

=={{header|Nanoquery}}==
<lang Nanoquery>println args[1]</lang>
{{out}}
<pre>programname.nq</pre>


=={{header|newLISP}}==
=={{header|newLISP}}==
Line 1,276: Line 1,283:
Program name: ./ProgramName
Program name: ./ProgramName
</pre>
</pre>

=={{header|Objective-C}}==
=={{header|Objective-C}}==


Line 1,373: Line 1,381:
<lang Perl>use FindBin;
<lang Perl>use FindBin;
print "Program name $FindBin::Script\n";</lang>
print "Program name $FindBin::Script\n";</lang>

=={{header|Perl 6}}==
{{works with|rakudo|2015-10-16}}
In Perl 6, the name of the program being executed is in the special global variable <tt>$*PROGRAM-NAME</tt>.
<lang perl6>say $*PROGRAM-NAME;</lang>


=={{header|Phix}}==
=={{header|Phix}}==
Line 1,499: Line 1,502:


(module+ main (printf "Program: ~a\n" (program)))</lang>
(module+ main (printf "Program: ~a\n" (program)))</lang>

=={{header|Raku}}==
(formerly Perl 6)
{{works with|rakudo|2015-10-16}}
In Perl 6, the name of the program being executed is in the special global variable <tt>$*PROGRAM-NAME</tt>.
<lang perl6>say $*PROGRAM-NAME;</lang>


=={{header|Raven}}==
=={{header|Raven}}==
Line 1,925: Line 1,934:


Wscript.Echo "FullName:",Wscript.FullName
Wscript.Echo "FullName:",Wscript.FullName

=={{header|vbscript}}==
=={{header|vbscript}}==


Line 1,960: Line 1,970:
appname = fullpath
appname = fullpath
End If</lang>
End If</lang>




=={{header|x86 Assembly}}==
=={{header|x86 Assembly}}==