English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   support.Apps (https://eab.abime.net/forumdisplay.php?f=8)
-   -   How to check if a volume/drive exists? (https://eab.abime.net/showthread.php?t=94495)

Foebane 03 October 2018 22:44

How to check if a volume/drive exists?
 
Is there a command to check if a drive/volume exists before using the CD command to change to it and run a script? This is because my User-Startup uses this command at the moment to change to DH4:, but not all my configurations have a DH4: and this command is being called from a WB HDF.

I thought "IF EXISTS DH4:" would work fine, but apparently not.

EDIT: Reply if you like, but I think I've found a workaround if there's no solution to this issue. However, if there is a solution, then I'll happily accept it.

kolla 04 October 2018 01:04

Isn't there an "assign dh4: exists"?

-Acid- 04 October 2018 01:50

Assign >NIL: exists dh4:
if not warn
do something
else
dont bother
endif

Foebane 04 October 2018 05:57

Quote:

Originally Posted by -Acid- (Post 1273833)
Assign >NIL: exists dh4:
if not warn
do something
else
dont bother
endif

This script didn't work for me, even with "dh4:@", with @ being the name of the file to execute.

I've found a simple solution, and it works. Thanks, anyway. :)

desiv 04 October 2018 06:23

Quote:

Originally Posted by Foebane (Post 1273853)
I've found a simple solution, and it works. Thanks, anyway. :)

And??
Enquiring minds want to know!!!! ;-)

Thanx

Foebane 04 October 2018 07:53

Quote:

Originally Posted by desiv (Post 1273854)
And??
Enquiring minds want to know!!!! ;-)

Thanx

My solution was to simply add DH4: to the configuration and point to an empty "@" file, so there wouldn't be any more "Drive DH4: is empty" messages and yet it wouldn't run anything else.

Now the User-Startup lines involved are simply:

CD DH4:
EXECUTE @

When I tried the script suggested by Acid, the DH4: wasn't executed either way, and to be honest, I'm still rusty on some AmigaDOS commands. At least I know what the two above lines do. :)

StingRay 04 October 2018 08:27

Quote:

Originally Posted by Foebane (Post 1273853)
This script didn't work for me, even with "dh4:@", with @ being the name of the file to execute.

I've found a simple solution, and it works. Thanks, anyway. :)


Acid's solution works fine so you most probably did it wrong. :) Easy check:


Code:

assign >NIL: DH4: exists
if not warn
echo "DH4: found"
else
echo "DH4: not available"
endif

Copy/paste and execute it and you'll either see a "not available" or "found" text.

malko 04 October 2018 11:24

If you are using ARP, you can use the following :
Code:

IF EXISTS DH4:
  <put your code here>
ELSE
  <put your code here>
ENDIF

PS:
Quote:

Originally Posted by Foebane (Post 1273794)
[...] EDIT: Reply if you like, but I think I've found a workaround if there's no solution to this issue. However, if there is a solution, then I'll happily accept it.

Nice one ! :D :laughing

Foebane 04 October 2018 11:51

Cool, it worked this time! :) Don't know what I did wrong before.

Thanks, StingRay, Acid and Malko!

I guess I gave up too easily.

mech 16 February 2023 17:26

check for cd
 
I know this is a old thread,but there is something on Aminet that may apply:


aminet.net/disk/misc/chkcd10.lha


All times are GMT +2. The time now is 09:50.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.05579 seconds with 11 queries