Page 1 of 1

Get error message to don't have output window

Posted: Tue Jul 25, 2023 10:51 pm
by papiosaur
Hello,

in my project, i use the command version to get version number of an executable.

If command version not found version, it send a message in a output window "version failed, error code 10".

It will be possible to send this error message in a string to don't have this output window please?

Thanks for your help.

Re: Get error message to don't have output window

Posted: Tue Jul 25, 2023 11:47 pm
by emeck
Hi.
You can send the output to a temp file, like:

Code: Select all

Execute("version filename > T:version.out")
And then open and read the file's content.

Or you can use the RunOutput option with InstallEventHandler()

Re: Get error message to don't have output window

Posted: Wed Jul 26, 2023 10:46 am
by jPV
The Version command fails and returns code 10 if it doesn't find a version string in a file, and the return code is 20 if it doesn't find a file at all. These return codes are outputted if you use the command in a script, which Hollywood's Execute() seems to do in practise. Redirecting the command output with > doesn't help in this case.

I don't remember if you can do anything else than setting the failure limit to bigger, so that the command doesn't fail even when it encounters errors. This has to be done in the same script with the command, so using two Executes in a row doesn't help... either you create a whole new temp script somewhere with two lines, the FailAt command to increase the failure limit and another line with the actual command, and execute that file, or you could trick Hollywood to include two lines within the Execute() function.

I'm not sure if you can trick Hollywood to include two lines with the new syntax of Execute(), but you could use the old syntax (just one parameter for the function) like this:

Code: Select all

Execute("FailAt 21\nVersion \"file name\" > T:version.out")
In that example I made it to skip all possible errors (file doesn't exist too), but if you want to skip just the version string error, change 21 to 11, for example. And remember to quote filenames/paths to handle possible spaces ;)

Re: Get error message to don't have output window

Posted: Wed Jul 26, 2023 6:12 pm
by papiosaur
@jPV : unfortunally don't work because i have some variables in my version syntax i think

@emeck : do you have an example for RunOutPut option please ?

Re: Get error message to don't have output window

Posted: Wed Jul 26, 2023 11:24 pm
by papiosaur
The code from jPV works! No error message from the command version now!

Code: Select all

Execute("FailAt 21\nVersion \"file name\" > T:version.out")
It should work too for others commands with error message code up to 20...

Thanks a lot jPV.

Thanks a lot emeck too for your help.

Re: Get error message to don't have output window

Posted: Thu Jul 27, 2023 10:52 am
by Flinx
papiosaur wrote: Wed Jul 26, 2023 6:12 pm do you have an example for RunOutPut option please ?
The topic seems to be completed with jPV's solution, but I wanted to learn something and have experimented with RunOutput and think that it still fits here. My example is for Windows, but there only the paths are different. Interesting is that the long help text from Hollywood_Console leads to several RunOutput events.

Code: Select all

Function p_printoutput(msg)
	DebugPrint("\n---printoutput---")
	DebugPrint(msg.Output)
EndFunction

Function p_printreturncode(msg)
	;ForEach(msg, DebugPrint)
	DebugPrint("\n---printreturncode---\nReturnCode:",msg.ReturnCode)
EndFunction

InstallEventHandler({RunOutput=p_printoutput, RunFinished=p_printreturncode})
Run("C:\\Program Files\\Hollywood\\Hollywood_Console.exe", "-help",{ReturnCode=True})
Repeat
	WaitEvent()
Forever

Re: Get error message to don't have output window

Posted: Thu Jul 27, 2023 12:15 pm
by jPV
Flinx wrote: Thu Jul 27, 2023 10:52 am
The topic seems to be completed with jPV's solution, but I wanted to learn something and have experimented with RunOutput and think that it still fits here.
Run() probably doesn't work in this case that well, at least without some extra effort, because you probably also want to process the output quite immediately without waiting/checking if/when the asynchronous Run() returns. Execute() is more straightforward in this case and you can just read the output in the next line in the script.

But maybe as a feature request in Hollywood, could Execute() have an option to alter the failure limit? Or getting the return code or output directly?

Re: Get error message to don't have output window

Posted: Mon Jul 31, 2023 12:51 am
by airsoftsoftwair
jPV wrote: Thu Jul 27, 2023 12:15 pm But maybe as a feature request in Hollywood, could Execute() have an option to alter the failure limit? Or getting the return code or output directly?
Yeah, might be worth considering because it would make catching the output and/or return code more easily without having to use event handlers.

Re: Get error message to don't have output window

Posted: Sun May 18, 2025 6:02 pm
by airsoftsoftwair

Code: Select all

- New: Execute() supports a new optional table tag named "CaptureOutput" now; if this is set to TRUE, the
  program's output as well as its return code will be returned by Execute(); this can be more convenient
  to use than Run() and its event handlers