Ultimate Amiga

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: command to list drives?  (Read 5979 times)

0 Members and 1 Guest are viewing this topic.

Hungry Horace

  • Amorphous Blue-Blob Man
  • Site Admin
  • A4000T
  • ******
  • Karma: 307
  • Offline Offline
  • Gender: Male
  • Posts: 3,364
  • Don't forget... Ameboid's need love too!
    • AUW
command to list drives?
« on: September 06, 2014, 11:30:17 AM »

HI All

Anyone know how i can get AMOS to list all of the available Hard drives? Even if this needs an extension to do it?

I thought Dev First$ and dev next$ would cover it, but all i seem to get returned is the first assign, no matter what parameters i use.


I could probably parse the output of the 'INFO' command, but that is hardly ideal...


All input welcome!
Logged
Quote from: KillerGorilla
because winuae is made of code and your amiga is made of stuff

bruceuncle

  • AMOS Dev
  • A500
  • *****
  • Karma: 6
  • Offline Offline
  • Gender: Male
  • Posts: 425
  • WINUAE Amiga User
Re: command to list drives?
« Reply #1 on: September 06, 2014, 03:03:02 PM »

I thought Dev First$ and dev next$ would cover it, but all i seem to get returned is the first assign, no matter what parameters i use.
Can't understand why you're not getting results with Dev First$ and Dev Next$.  Works fine for me  ??? .

This is an example that shows how to list Assigns and Drives.  Assigns are easy but there's no simple way to list Drives.  The only quick and easy method I can think up is also in this example.  But that involves the hard-coded Data statement to cover all possibilities.  If there's a limit to how many Floppy-, Hard- and CDROM-Drives are possible on an Amiga, that would probably be your best bet.  I don't know what limits there are so I just chucked in four hard drives and four floppies to show you the method.

Code: [Select]
Global G_LINES_MAX,G_LINE_COUNT
Proc _INIT_SCREEN
'
'  List all the assigns:
'
G_LINE_COUNT=0
Print " "
Proc _CHECK_LINE_COUNT
Under On : Print Pen$(7)+"List Assigns:"+Pen$(5) : Under Off
'*****
' Start
'*****
D$=Dev First$("")
Repeat
   Proc _CHECK_LINE_COUNT
   Print D$
   D$=Dev Next$
Until D$=""
'*****
' End
'*****
Proc _CHECK_LINE_COUNT
Print
Proc _CHECK_LINE_COUNT
Print Pen$(4)+"Press any key for next example..."+Pen$(5)
Proc _CHECK_LINE_COUNT
Print
Wait Key
'
'  Check whether the "standard" drive names exist:
'
G_LINE_COUNT=0
Proc _CHECK_LINE_COUNT
Under On : Print Pen$(7)+"Check 'Standard' Drives:"+Pen$(5) : Under Off
'*****
' Start
'*****
Restore STD_DRVS
Do
   Read DRV$
   Exit If DRV$=""
   Proc _CHECK_LINE_COUNT
   Print DRV$;
   If Drive(DRV$)
      Print " Exists"
   Else
      Print " Does Not Exist"
   End If
Loop
'*****
' End
'*****
Proc _CHECK_LINE_COUNT
Print
Proc _CHECK_LINE_COUNT
Print Pen$(4)+"Press any key for next example..."+Pen$(5)
Proc _CHECK_LINE_COUNT
Print
Wait Key
'
'  Or, list the available drives:
'
G_LINE_COUNT=0
Proc _CHECK_LINE_COUNT
Under On : Print Pen$(7)+"List 'Standard' Drives:"+Pen$(5) : Under Off
'*****
' Start
'*****
Restore STD_DRVS
Do
   Read DRV$
   Exit If DRV$=""
   If Drive(DRV$)
      Proc _CHECK_LINE_COUNT
      Print DRV$
   End If
Loop
'*****
' End
'*****
Direct

'
'  I don't know what the sum total of Amiga drive configurations is.
'  So just expand these data statements to take them all in...
'
STD_DRVS:
Data "dh0:","dh1:","dh2:","dh3:","df0:","df1:","df2:","df3:",""

Procedure _CHECK_LINE_COUNT
   Inc G_LINE_COUNT
   If(G_LINE_COUNT>G_LINES_MAX)
      Print Pen$(1)+"Press any key to continue listing..."+Pen$(5)
      Wait Key
      G_LINE_COUNT=0
   End If
End Proc

Procedure _INIT_SCREEN
   If Ntsc
      L_YSIZE=200
      G_LINES_MAX=25-4
   Else
      L_YSIZE=256
      G_LINES_MAX=32-4
   End If
   Screen Open 0,640,L_YSIZE,8,Hires
   Palette $0,$AAA,$77,$FFF,$F00,$DD,$AA,$FF3
   Wait Vbl
   Cls 2
   Pen 5 : Paper 2
End Proc

In my usual fashion, I've complicated the code to made the listings look neat and to allow you to see the assigns before they scroll off the screen.  So the essential bits are enclosed in
     '*****
     ' Start
     '*****

and
     '*****
     ' End
     '*****

comment lines.

It's probably worth putting something simple and easy in as an AMOS V2.xx enhancement (eventually!).  There's probably also some AmigaDOS calls that would do the job and cover any drive combinations (can anyone help with that?) .

Hope this helps ;)
Logged
Repeat after me ...  "The AMOS Pro architecture is complex but it is not complicated."

Hungry Horace

  • Amorphous Blue-Blob Man
  • Site Admin
  • A4000T
  • ******
  • Karma: 307
  • Offline Offline
  • Gender: Male
  • Posts: 3,364
  • Don't forget... Ameboid's need love too!
    • AUW
Re: command to list drives?
« Reply #2 on: September 06, 2014, 05:16:07 PM »

wow... I think thats longer than my code to read the results of the 'info' command!

the manual says you restrict the DEV command to either assigns or drives only by using "/d" or "/a"  (if i remember right) but everything i did only gave me one listing, of the first assign! (very strange) .... maybe another bug of AMOSpro?

using hard coded options 'dh0:' etc is exactly what i'm trying to avoid, as this has caused a problem sharing my WHDLoad booting program with a friend.



The code i'm using now is this... its a bit nasty but it works, lol

Code: [Select]
PROCEDURE _GETDRIVES
' ====== this is a program to fill  an array with available drives

' --- output the INFO command to ram:
Exec "C:info >t:infoout"


' ---  load the file, stick it into string

Reserve As Work 1,Object Size("t:infoout")

Bload "t:infoout",1

For B=0 To Length(1)-1
   ALL$=ALL$+Chr$(Peek(Start(1)+B))
Next B

Erase 1
Exec("C:delete t:infout")




' ==== now read each line at a time

For Q=3 To 100
      FISH$=Itemstr$(ALL$,Q,Chr$($A))
   If FISH$="" Then Exit


   For T=1 To Len(FISH$)-3

      If Mid$(FISH$,T,3)=":  " Then Exit

   Next T

   FISH$=Left$(FISH$,T)

   ADRIVE$(F)=FISH$
   F=F+1
   If F>32 Then Exit
   Rem Print FISH$

Next Q

Erase 1
End Proc
Logged
Quote from: KillerGorilla
because winuae is made of code and your amiga is made of stuff

Lonewolf10

  • AMOS Extensions Developer
  • AMOS Dev
  • A2000
  • *****
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 618
    • http://www.aliensrcooluk.com
Re: command to list drives?
« Reply #3 on: September 06, 2014, 07:30:08 PM »


An interesting problem which you now have the solution for :)

I don't think I have ever tried to list all available drives, I have always gone for the hardcoded method - either the drive ID ("df0:") or the disk name ("Games_Vol1:").
Logged

bruceuncle

  • AMOS Dev
  • A500
  • *****
  • Karma: 6
  • Offline Offline
  • Gender: Male
  • Posts: 425
  • WINUAE Amiga User
Re: command to list drives?
« Reply #4 on: September 07, 2014, 10:35:30 AM »

The manual's wrong (again!).  I didn't even check it and haven't got to input / output yet in the docs...
Correct filters are "d:**" for drives and "a:**" for assigns.  So Dev First$("d:**") is what you're after.



Sent from my Lumia 800 using Tapatalk
Logged
Repeat after me ...  "The AMOS Pro architecture is complex but it is not complicated."

bruceuncle

  • AMOS Dev
  • A500
  • *****
  • Karma: 6
  • Offline Offline
  • Gender: Male
  • Posts: 425
  • WINUAE Amiga User
Re: command to list drives?
« Reply #5 on: September 08, 2014, 10:04:11 AM »

It seems a bit silly to call the function Dev First$ as the only two options are to list Assigns or Drives.  Not Devices!

Whilst the "D:" prefix prepares a list of Drives, any other prefix letter prepares a list of Assigns - not just the "A:" shown in the manual.  So I'll put it down as a mild bug at this stage.  I haven't pulled the code apart fully yet as I'll need to map the data storage it uses first (and understand how the lists are created).  So I won't be doing anything with it at the moment.

Is it realistic to expect an Amiga's Devices to be listed?  I don't know AmigaDOS well enough yet.  Can anyone elaborate please?
Logged
Repeat after me ...  "The AMOS Pro architecture is complex but it is not complicated."

Lonewolf10

  • AMOS Extensions Developer
  • AMOS Dev
  • A2000
  • *****
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 618
    • http://www.aliensrcooluk.com
Re: command to list drives?
« Reply #6 on: September 14, 2014, 01:06:21 AM »


I'm no expert on the OS, but Exec Library does have some device commands (AddDevice,RemDevice,OpenDevice and CloseDevice). That seems to imply that devices can be added and removed manually, though I would expect the OS to detect all available devices at startup and add them to an internal list.
Logged

Mia

  • A600
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 101
  • Generic Amiga User
Re: command to list drives?
« Reply #7 on: July 19, 2016, 08:26:10 PM »

The manual's wrong (again!).  I didn't even check it and haven't got to input / output yet in the docs...
Correct filters are "d:**" for drives and "a:**" for assigns.  So Dev First$("d:**") is what you're after.

Frist sorry to for posting on an old thread, but it's still valid.

Thanks Bruce you have saved me so much time, it works.

I did try to debug this issue but it is strange. I have tried the new AGUI library from aminet and it has a file requester that shows both the assigns and the disks - the code it uses is Dev First('') (2 single quotes) so I though if I copy that it will work, but it gave only the disks when run from my code, then when playing with the code in AGUI it suddenly broke and only shows the disks and not the assigns even if a revert to the oriinal code. so it is unpredictable meaning there is a "bug" somewhere, maybe in the internal counter for assigns (*guessing). I  will run Dev First$ twice, first with a:** and then d:** to confirm I have all the assigns and disks.

** Edit
I'm actually not sure if I found a bug, but it's bugging me lol. I think I've made myself a bit of a mess and I'm wasting time on this, spent most of the day on it and it's still not stable so I have to move back to the standard file selector or else I'll never get this finished.
« Last Edit: July 20, 2016, 12:54:59 AM by Mia »
Logged
Pages: [1]   Go Up
 

TinyPortal 2.2.2 © 2005-2022