SNIPE wrote: ↑2023-Feb-22, 7:03 am
however I still would like for it to, after it asks for me to browse for the file, echo gcc %thefilename%.c -o %thefileame.exe and then execute that.
I'm curious: Why do you want to print the command to the actual command prompt and then have the user press a key to execute it?
I understand the idea, but you can do almost the same thing from inside the script.
Something like;
Code: Select all
set defaultparameters=-a -b -c
echo Current command line is: gcc %parameters% %filename%.c -o %filename%.exe
echo.
echo Just press Enter to execute this command, or enter additional parameters.
echo Enter a * as the first character to blank the existing parameters.
echo.
set /p userparameters=Enter Parameters:
if "%userparameters:~0,1%"=="*" (
set defaultparameters=
set userparameters=%userparameters:~1%
)
gcc %defaultparameters% %userparameters% %filename%.c -o %filename%.exe
If the user just presses Enter, the default value of %parameters% will be used. If they enter new parameters, those will be appended to the existing ones. If they enter a star, the default parameters will be blanked and only what they enter will be used.
I don't know much (OK, anything) about compiling programs, however, if I were doing it on a regular basis, and there were certain parameters that I found myself using frequently, I would probably make a menu-driven script using the Choice command, with there being a key to toggle each parameter on/off, indicated by a star next to it, and then when the compile option is chosen, it would issue the command and include all the parameters that the user has chosen. If a parameter also needs additional info, such as a numeric value, the script would ask for that as well when that parameter is toggled on.
I've done stuff like this for scripts that convert files.