Photo by Mr Cup / Fabien Barral on Unsplash
Contents
Getting started
Sometimes you need to toggle between multiple versions of Euphoria on one system.
It’s a bit tricky, and I don’t recommend it, but I’ll try to make this as easy as possible on Windows 10.
Warning!
A word of warning, this is our first Intermediate article. I expect that you’re already familiar with installing Euphoria. You should also be relatively familiar with the command line, how environment variables work, how to write a batch file, and your own system in general. You’ll probably need to adapt these steps to your own needs as necessary.
Conventions
This method should work for switching between any number of Euphoria versions. I use this it to switch between 32-bit and 64-bit Euphoria 4.1 on my 64-bit Windows 10 system. I recommend using color-coded terminals to avoid any confusion in which environment is live. Best of all, you can run each of these environments simultaneously!
Version | Architecture | Path | Shortcut | Code | Preview |
---|---|---|---|---|---|
Euphoria 2.5 | N/A | C:\Euphoria25 |
N/A | 06 |
Aqua |
Euphoria 3.1 | N/A | C:\Euphoria31 |
F8 | 2F |
Green |
Euphoria 4.0 | N/A | C:\Euphoria40 |
F7 | 5F |
Purple |
Euphoria 4.1 | 32-bit | C:\Euphoria41-32bit |
F6 | 4F |
Red |
Euphoria 4.1 | 64-bit | C:\Euphoria41-64bit |
F5 | 1F |
Blue |
Installation
So how do we get multiple versions of Euphoria installed side-by-side? We copy them!
Here are the steps to get any number of versions installed. Repeat as necessary for each version you need.
- Install a version of Euphoria to
C:\Euphoria
. - Copy this folder to its new home. You can do this in Windows Explorer, but I prefer to use Robocopy, e.g.
robocopy /E C:\Euphoria C:\Euphoria41-32bit
- Update the
%EUDIR%\bin\eu.cfg
files for all Euphoria 4.x versions to use the new path for that version. - Uninstall the “original” version from
C:\Euphoria
.
At this point, you don’t need to maintain any version as being “installed” on your system under Programs and Features.
Environment
We’ll need to prepare your environment to accept dynamic changes to put any version of Euphoria into the path.
Head back to our previous article (Installing Euphoria 4.1 on Windows 10) if you need, and do the following:
- Add a new environment variable
EUDIR
with your default environment, e.g.C:\Euphoria41-64bit
. - Edit your
PATH
environment variable and changeC:\Euphoria\bin
to%EUDIR%\bin
.
Done correctly, this won’t change anything about your original Euphoria installation.
Command scripts
This, as they say, is where the magic happens. We’ll create a series of command scripts (or “batch files”) to switch our environment on-the-fly. Repeat the following steps for each version of Euphoria you want to use. I create these files on my Desktop for easy access.
- Create a new text file named
Euphoria {VERSION}.cmd
, e.g.Euphoria 4.1 (32-bit).cmd
. - Open the new script in Notepad++ and enter the following:
@echo off ECHO. COLOR 5F CD %USERPROFILE% SET EUDIR=C:\Euphoria40 SET PATH=%EUDIR%\bin;%PATH% TITLE Euphoria 4.0.5 (32-bit) %COMSPEC% /k "eui.exe -v"
- Replace the
COLOR
,EUDIR
, andTITLE
values to match your environment. See the table above.
If you’re using Euphoria 2.5 or 3.1, you’ll need to change this line:
%COMSPEC% /k "eui.exe -v"
to look like this instead:%COMSPEC% /k "ECHO. | exwc.exe"
Unfortunately you cannot avoid seeing the “file name to execute?” prompt, but at least the echo
trick ignores it.
Explanation
So how does all this work?
ECHO.
First we echo a blank line. I just the aesthetics of padding the version output with blank lines.
COLOR 5F
Next we set the terminal color using the color codes listed above. See color /?
for details.
CD %USERPROFILE%
Command scripts will drop you into the directory where the script lives. But by default, Command Prompt drops you into your home directory. So we’re just restoring that behavior with this command.
SET EUDIR=C:\Euphoria40
SET PATH=%EUDIR%\bin;%PATH%
Here we’re overriding the environment variables that point to the relevant Euphoria environment.
TITLE Euphoria 4.0.5 (32-bit)
This sets the terminal title which, in conjunction with the colored back ground, helps prevent confusion when using multiple environments.
%COMSPEC% /k "eui.exe -v"
Finally, we drop the user into a new Command Prompt instance. The /k
argument executes the provided command and then stays in the command prompt instead of exiting. See cmd /?
for details.
Notepad++ macros
We can take this a step further and extend the macro from our previous article (Setup Notepad++ to edit Euphoria code).
Reassign shortcuts
First, we’ll need to reassign a couple existing menu item shortcuts so that we can use F5-F6-F7-F8 for these macros.
- Click Run > Modify Shortcut/Delete Command…
- Select the Main menu tab.
- Scroll down to 97 Search Results Window ( F7 ) and click Modify.
- Add Shift to the shortcut.
- Repeat steps 3-4 for 167 Focus on Another View ( F8 ) (add Shift as well).
Insert macros
We can drop in all four macros at once by modifying the shortcuts.xml
for Notepad++.
- Click File > Open…
- Browse to
%APPDATA%\Notepad++
and selectshortcuts.xml
. - Remove the previous “Run in Euphoria” macro around line 22.
- Insert the following macros. You may need to modify these depending on your setup.
<Command name="Run in Euphoria 4.1 (64-bit)" Ctrl="no" Alt="no" Shift="no" Key="116">%EUDIR%\bin\euiw.exe %EUDIR%\bin\startw.exw -d "$(CURRENT_DIRECTORY)" C:\Euphoria41-64bit\bin\euiw.exe "$(FILE_NAME)"</Command> <Command name="Run in Euphoria 4.1 (32-bit)" Ctrl="no" Alt="no" Shift="no" Key="117">%EUDIR%\bin\euiw.exe %EUDIR%\bin\startw.exw -d "$(CURRENT_DIRECTORY)" C:\Euphoria41-32bit\bin\euiw.exe "$(FILE_NAME)"</Command> <Command name="Run in Euphoria 4.0 (32-bit)" Ctrl="no" Alt="no" Shift="no" Key="118">%EUDIR%\bin\euiw.exe %EUDIR%\bin\startw.exw -d "$(CURRENT_DIRECTORY)" C:\Euphoria40\bin\euiw.exe "$(FILE_NAME)"</Command> <Command name="Run in Euphoria 3.1 (32-bit)" Ctrl="no" Alt="no" Shift="no" Key="119">%EUDIR%\bin\euiw.exe %EUDIR%\bin\startw.exw -d "$(CURRENT_DIRECTORY)" C:\Euphoria31\bin\exw.exe "$(FILE_NAME)"</Command>