Obtaining the path of the application program?
Jeff Henrikson <[email protected]> Thu, 26 Aug 2021 07:51:35 -0700
| Newsgroups | gmane.comp.lang.racket.user,gmane.lisp.scheme.plt |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------DD49D48C5EA5DFD05F895E29
Content-Type: text/plain; charset="UTF-8"; format=flowed
Content-Transfer-Encoding: quoted-printable
Racket users,
Many software applications use their location in the filesystem to=20
establish filesystem relationships between their executable file, their=20
configuration and their data.=C2=A0 For this purpose, C provides the first=
=20
element of the string array provided to main, python provides __file__,=20
bash provides ${BASH_SOURCE[0]}, etc.
Racket strips said value before current-command-line-arguments receives=20
the subsequent command-line arguments from the operating system.
A related value can be pulled from syntax-source as follows:
(define-syntax (get-current-source stx)
=C2=A0 (datum->syntax
=C2=A0=C2=A0 (quote-syntax here)
=C2=A0=C2=A0 (syntax-source stx)
=C2=A0=C2=A0 stx))
Macro get-current-source works as intended if called at program startup=20
and the program is compiled on the fly with:
racket program.rkt
However get-current-source has the unintended property of memorizing the=20
original source location if the program is compiled with raco exe (and=20
then moved).
Is there a way in racket to obtain the path of the application program?
Jeff Henrikson
--=20
You received this message because you are subscribed to the Google Groups "=
Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to racket-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To view this discussion on the web visit https://groups.google.com/d/msgid/=
racket-users/a076dfa2-d1a5-3cda-72ae-a30cdb91dc31%40gmail.com.
--------------DD49D48C5EA5DFD05F895E29
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta http-equiv=3D"content-type" content=3D"text/html; charset=3DUTF-8=
">
</head>
<body>
<div class=3D"moz-text-html" lang=3D"x-unicode">
<p>Racket users,<br>
<br>
Many software applications use their location in the filesystem
to establish filesystem relationships between their executable
file, their configuration and their data.=C2=A0 For this purpose, C
provides the first element of the string array provided to main,
python provides __file__, bash provides ${BASH_SOURCE[0]}, etc.<br>
<br>
Racket strips said value before current-command-line-arguments
receives the subsequent command-line arguments from the
operating system.<br>
<br>
A related value can be pulled from syntax-source as follows:<br>
</p>
<blockquote>(define-syntax (get-current-source stx)<br>
=C2=A0 (datum->syntax<br>
=C2=A0=C2=A0 (quote-syntax here)<br>
=C2=A0=C2=A0 (syntax-source stx)<br>
=C2=A0=C2=A0 stx))<br>
</blockquote>
<p>Macro get-current-source works as intended if called at program
startup and the program is compiled on the fly with:<br>
</p>
<blockquote>racket program.rkt<br>
</blockquote>
<p>However get-current-source has the unintended property of
memorizing the original source location if the program is
compiled with raco exe (and then moved).</p>
Is there a way in racket to obtain the path of the application
program?
<p><br>
</p>
<p>Jeff Henrikson</p>
<p><br>
</p>
</div>
</body>
</html>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;Racket Users" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:racket-users+unsubscribe-/[email protected]">racket=
-users+unsubscribe-/[email protected]</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/d/msgid/racket-users/a076dfa2-d1a5-3cda-72ae-a30cdb91dc31%40gmail.com?ut=
m_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgid/rac=
ket-users/a076dfa2-d1a5-3cda-72ae-a30cdb91dc31%40gmail.com</a>.<br />
--------------DD49D48C5EA5DFD05F895E29--