Get error message to don't have output window

Find quick help here to get you started with Hollywood
Post Reply
papiosaur
Posts: 217
Joined: Fri Mar 31, 2023 1:34 pm

Get error message to don't have output window

Post 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.
User avatar
emeck
Posts: 191
Joined: Fri Apr 03, 2015 3:17 pm

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

Post 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()
PowerBook 5.8 MorphOS 3.18
Mac Mini MorphOS 3.18
User avatar
jPV
Posts: 734
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

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

Post 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 ;)
papiosaur
Posts: 217
Joined: Fri Mar 31, 2023 1:34 pm

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

Post 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 ?
papiosaur
Posts: 217
Joined: Fri Mar 31, 2023 1:34 pm

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

Post 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.
Flinx
Posts: 342
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

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

Post 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
User avatar
jPV
Posts: 734
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

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

Post 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?
User avatar
airsoftsoftwair
Posts: 5830
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

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

Post 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.
User avatar
airsoftsoftwair
Posts: 5830
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

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

Post 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
Post Reply