RunProgram() without parameter in IDE
RunProgram() without parameter in IDE
RunProgram("")
Works as expected in the compiler, but throws an error in the IDE (5.73LTS and 6.0A4)
Works as expected in the compiler, but throws an error in the IDE (5.73LTS and 6.0A4)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: RunProgram() without parameter in IDE
What...what is the expected outcome to use it with an empty string? I don't think that's intended.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Re: RunProgram() without parameter in IDE
That is the error That shouldn't happen according to the documentation, and it doesn't happen once compiled.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: RunProgram() without parameter in IDE
It looks like that's exactly the error you should get in the IDE ("RunProgram(): A filename must be specified.")That shouldn't happen according to the documentation
According to the documentation, the first parameter (Filename$) is not optional, and therefore it has to be supplied.
Re: RunProgram() without parameter in IDE
Filename$ The executable name including its path.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Re: RunProgram() without parameter in IDE
No, I mean where in the docs does it say an error will be thrown for a null filename (as bluenzl claims)? It doesn't. In fact, the manual doesn't say anything at all about a missing filename. It just assumes one will be supplied.
Re: RunProgram() without parameter in IDE
Filename$ does not imply an empty string, since in this case it makes no sense to use the function.
If you sit down to eat using the emptiness in the plate, then in this case it makes no sense to sit down to eat.
I assume that you are using a variable that, for some unforeseen reason, turned out to be an empty string. Make a self-check that the file exists before sending it to the function.
If you sit down to eat using the emptiness in the plate, then in this case it makes no sense to sit down to eat.
I assume that you are using a variable that, for some unforeseen reason, turned out to be an empty string. Make a self-check that the file exists before sending it to the function.
Re: RunProgram() without parameter in IDE
(Before deliving deeper, this is a very minor thing, so no worries.)
Still I have to disagree with you guys, for two reasons (sorry )
1. Let's look at the docs:
It didn't sucesfully launch, thus it should return a zero, instead it errors out. The doc doesn't state it must be a valid string, it only states that it will return a value depending on the success of the call.
Then, 2. (more a personal thing) I strongly believe the IDE and the compiled program should work the same as much as possible. I suspect Fred simply built in an extra check to catch this error upfront.
Still I have to disagree with you guys, for two reasons (sorry )
1. Let's look at the docs:
If it has been succesfully launched, then it should return a non-zero value.Return value
Nonzero if the program has been successfully launched, zero otherwise.
If #PB_Program_Open was included in the Flags, the return-value is a number that identifies the program. It may be used in calls to get information about the program such as ReadProgramString() or ProgramExitCode() or other functions mentioned above.
It didn't sucesfully launch, thus it should return a zero, instead it errors out. The doc doesn't state it must be a valid string, it only states that it will return a value depending on the success of the call.
Then, 2. (more a personal thing) I strongly believe the IDE and the compiled program should work the same as much as possible. I suspect Fred simply built in an extra check to catch this error upfront.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: RunProgram() without parameter in IDE
That latter would be a little silly, as you would have to parse the full path to catch any error. Try RunProgram("Notepad.exe"). It'll work. Now, WHERE is "notepad.exe"?AZJIO wrote: ↑Wed Oct 06, 2021 9:33 am Filename$ does not imply an empty string, since in this case it makes no sense to use the function.
If you sit down to eat using the emptiness in the plate, then in this case it makes no sense to sit down to eat.
I assume that you are using a variable that, for some unforeseen reason, turned out to be an empty string. Make a self-check that the file exists before sending it to the function.
And why would such a check be necessary when compiled?
Also, if I had to check the validity of the string myself, then why does the function return a value at all if (not) succesful?
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: RunProgram() without parameter in IDE
Code: Select all
Define Path$ = "Notepad.exe"
PathFindOnPath_(@Path$, #Null)
Debug Path$
Code: Select all
Define path.String
path\s = "Notepad.exe"
; PathFindOnPath_(path\s, #Null)
PathFindOnPath_(@path\s, #Null)
Debug path\s
Code: Select all
Procedure.s PathFind(path$)
Protected tmp$
tmp$ = Space(#MAX_PATH)
PokeS(@tmp$, path$)
; Wow64EnableWow64FsRedirection(0) ; https://www.purebasic.fr/english/viewtopic.php?p=481621#p481621
If PathFindOnPath_(@tmp$, #Null)
path$ = tmp$
EndIf
; Wow64EnableWow64FsRedirection(1)
ProcedureReturn path$
EndProcedure
Debug PathFind("Notepad.exe")
Last edited by AZJIO on Wed Dec 22, 2021 9:46 pm, edited 5 times in total.
Re: RunProgram() without parameter in IDE
The debugger just tells you about a potential error in your command arguments. It is the same for many PB commands. If you don't like that just use "DisableDebugger" to disable such checks.
quidquid Latine dictum sit altum videtur
Re: RunProgram() without parameter in IDE
No no, it's fine. It just threw me a curvebal when testing stuff from the IDE.
I simply wasn't expecting it when reading the documentation (which suggests I would get a return value).
If it's by design, fine.
I simply wasn't expecting it when reading the documentation (which suggests I would get a return value).
If it's by design, fine.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: RunProgram() without parameter in IDE
It is indeed weird that an empty string "" is handled differently from let's say "a". Both should just return 0. "" in a compiled exe even opens file explorer for whatever reason.