Making an .exe that executes source file inside itself.
u0_a183
u0_a183 at example.com
Wed Apr 25 20:44:10 UTC 2018
On Wednesday, 25 April 2018 at 19:54:26 UTC, BoQsc wrote:
> On Wednesday, 25 April 2018 at 19:43:31 UTC, Jonathan M Davis
> wrote:
>> On Wednesday, April 25, 2018 19:19:58 BoQsc via
>> Digitalmars-d-learn wrote:
>>> So there has been idea I've got for around few months now:
>>> making
>>> a software which executable would contain a source file.
>>> A software that anyone could modify by opening an executable
>>> and
>>> quickly change a few lines of it, rerun an executable, see the
>>> changes.
>>>
>>> Could this be easily possible with D language, considering
>>> that sources files can be ran without long slow compilation
>>> process?
>>
>> The normal way to do that is to just write a script. In the
>> case of D, you can just use rdmd to do it. e.g. if you're on a
>> POSIX system, just put
>>
>> #!/usr/bin/env rdmd
>>
>> at the top of your .d file and chmod it so that it's
>> executable, and it'll run like any other script.
>>
>> - Jonathan M Davis
>
> Thank you Jonathan for a response.
> I was aware of this, and it certainly perfectly works where
> command line/terminal interface is the main tool to control the
> system, a good example would be linux/gnu distributions and
> macOS.
> However in Windows while installing D language, I noticed that
> .d source file extension is not associated with neither D
> compiler (dmd.exe) nor D script interpretator (rdmd.exe)
> So they can't be ran directly by clicking on those, nor they
> have any icons that show that these source codes are actually
> executable. This is a huge problem, because people that are not
> aware of D language migh be harder to understand that source
> script could be executable, at least - without help from some
> more experienced user.
If the purpose is to make scripts run by clicking them you can
assign a file type to .d files.
On Windows 10.
https://www.digitaltrends.com/computing/how-to-set-default-programs-and-file-types-in-windows-10/
Doing so would make the script engine the default program instead
of a text editor so you might not want to. Or maybe assign .dxe
and changing the filename before running.
More information about the Digitalmars-d-learn
mailing list