QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: MasterGy on December 09, 2020, 04:08:37 am
-
Hi ! can anyone tell me how to read out the filename of the program that is running? For example, I generate x.exe from x.bas. How does x.exe know that it is x.exe?
-
Put a line in your program:
RunningProg$="Bond, my name is James Bond.exe"
(just an idea)
SEE ALSO:
https://www.qb64.org/forum/index.php?topic=1259.0
-
-
Minor nitpick: COMMAND$(0) could potentially also have a path component, in which case you'd want to remove it.
Or maybe you're only interested in seeing if the name matches a list of options, in which case you can just take the RIGHT$ of it.
-
Very nice this "command$(0)"
So then file name is:
Filename$= RIGHT$(COMMAND$(0), LEN(COMMAND$(0)) - LEN(_CWD$) - 1)
-
@euklides @MasterGy
Or this:
Or, if in Linux or Mac:
-
Thank you Felippe, and everybody ,that's exactly what I needed!