How to know if Run() fails?

Anything related to Hollywood Designer goes in here
walkero
Posts: 13
Joined: Fri Jul 29, 2022 11:59 pm

How to know if Run() fails?

Post by walkero »

Hello everyone.
In an app I am building, I rely on a couple of third-party applications to exist in users' systems and are in PATH, no matter if they are based on Linux, macOS or Windows. To figure out if they exist I use Run() and try to capture an error by executing the binary with an argument like "--version" or "-h".

On Linux, that I am doing the development, the ReturnCode returns as zero, no matter if the command was successful or if it doesn't even exist. So, the ReturnCode is failing to provide an error.

Is there a way you guys would propose to see if the binaries my app needs, are available and in PATH?
Should the Execute() and Run() return a failure when the application fails?

Also, is there a way to do something like Try ... Catch, which would be helpful to catch problem and avoid the application to crash, while giving feedback to the user?

Thank you all for your help.
walkero
Posts: 13
Joined: Fri Jul 29, 2022 11:59 pm

Re: How to know if Run() fails?

Post by walkero »

A solution I found so far is getting the PATH environment and split it by colon (:). Then take each folder of these and check with Exists() if the binary is in there. This works fine, it is fast and accurate, but in console I get a message of "*** UNSUPPORTED USE CUSTOM HOOKS", whenever Exists() is executed. If I remove it, then the message is not there. Any idea what that means?
Flinx
Posts: 342
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: How to know if Run() fails?

Post by Flinx »

walkero wrote: Thu Jul 03, 2025 9:38 am I get a message of "*** UNSUPPORTED USE CUSTOM HOOKS", whenever Exists() is executed
Please show a code example.
User avatar
jPV
Posts: 734
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: How to know if Run() fails?

Post by jPV »

walkero wrote: Thu Jul 03, 2025 12:55 am Also, is there a way to do something like Try ... Catch, which would be helpful to catch problem and avoid the application to crash, while giving feedback to the user?
Generally speaking when using Hollywood functions?

I use something like that usually:

Code: Select all

Local err, retval = ?HWFunction()
If err
	p_Error(GetErrorName(err))
Else
	...
EndIf
walkero
Posts: 13
Joined: Fri Jul 29, 2022 11:59 pm

Re: How to know if Run() fails?

Post by walkero »

@jPV
Thank you for that. I will test it asap

@Flinx
Please, try the following example. The xad is removed, everything is fine. But as long as it is there, the "*** UNSUPPORTED USE CUSTOM HOOKS" message appears.

Code: Select all

@VERSION 9,0

/*
** Enable DPI-awareness so that our GUI looks sharp even on high DPI monitors
*/
@OPTIONS {DPIAware = True, EnableDebug = True}

@REQUIRE "xad", {Link = True, InstallAdapter = True}

Global PATHSEP$ = "/"
Global dependencies = {
	{bin$ = "app1"},
	{bin$ = "app2"},
	{bin$ = "app3"}
}

path$, envFound = GetEnv("PATH")
If envFound
	folders, cnt = SplitStr(path$, ":")
	For i = 0 To TableItems(dependencies) - 1
		DebugPrint("Checking file: ", dependencies[i].bin$)
		For j = 0 To cnt - 1
			DebugPrint("Checking in folder: ", folders[j] .. PATHSEP$ .. dependencies[i].bin$)
			If Exists(folders[j] .. PATHSEP$ .. dependencies[i].bin$)
				DebugPrint("Application found")
			EndIf
		Next
	Next
EndIf
Thank you guys for your help.
User avatar
airsoftsoftwair
Posts: 5830
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: How to know if Run() fails?

Post by airsoftsoftwair »

Actually, there are two different things in this thread:

1. Checking if Run() fails: This is currently not possible because of all the complexity involved. Remember that on many systems Run() also lets you "run" data files like images, sounds, etc. if there are programs associated with it. Checking if all this has succeeded is very complex so currently Run() will never fail if a file cannot be opened etc. so you have to take care of that on your own.

2. Concerning the "unsupported use custom hooks" message: That is some debug output from the XAD plugin. It might be fixed already in the (unreleased) 1.1 of the XAD plugin because that has some history entry related to Exists(). To workaround it, just set "InstallAdapter" to FALSE and manually pass "xad" in the "Adapter" tag when you need it.
plouf
Posts: 666
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: How to know if Run() fails?

Post by plouf »

ok bout integrated run

but returncode under

-> windows return nothing if not exist, 0 if succeed, some number if program fail etc
-> amigaos return 10 if not found
-> linux return 0 even if command exists or not

so "proper" OSes you can somehow understand what happened.
is this linux peculiarity ? or hollywood implementation ? can be workaround somehow !?
Christos
User avatar
airsoftsoftwair
Posts: 5830
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: How to know if Run() fails?

Post by airsoftsoftwair »

plouf wrote: Tue Jul 08, 2025 6:16 am is this linux peculiarity ? or hollywood implementation ? can be workaround somehow !?
Those return codes are probably OS dependent. I'll check if this can be standardized somehow but I'm not sure if it's possible because Hollywood would probably have to handle all shell peculiarities and keep in mind that on AmigaOS there are also ROM commands which don't even exist as physical files but it's still possible to run them. It's all very complicated.
plouf
Posts: 666
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: How to know if Run() fails?

Post by plouf »

its not neccessary to overcome OS behavious
right now it returns code 20 in AmigaOs , which is ok as this is AmigaOS returncode.
the same returncode you can check vai cli etc
i mean THIS is the OS... programmer must handle it :)

however in Walkero's case the OS DID have some behaviour, complete lost in Hollywood
my opinion is to have OS way, no matter how OS behaves,

Then its programmer's responsibility to take care of OS'es peculiarities.
The same user is responsible for file path, significant diffirencies in AmigaOS (dh0:/xx/) Windows (c:/xx/) Linux (/xx/) etx
Christos
walkero
Posts: 13
Joined: Fri Jul 29, 2022 11:59 pm

Re: How to know if Run() fails?

Post by walkero »

Thank you all for your replies. And understood that there is some complexity for the failing situations, since there are plenty of systems that Hollywood supports. For now, I am doing some checks, trying to figure out if something fails. I plan to deal with them by case.
Post Reply