AMCAF Extension V1.40 Manual  Index

Disk Support Functions

These are various functions to help you with disk access and filenames.

function: return the last dos error code
errnumber=Io Error

The Io Error function gives back the number of the last DOS-error.

function: return a dos errorstring
error$=Io Error$(errnumber)

This function returns the string of the corresponding DOS error message.
If no string for the error number exists, an empty string will be returned.
When using Kickstart 2.0 not the interior list is taken but the localized strings of the system.

function: return the filename of a full path

This function cuts the filename out of an mixed path and file string.

Example: Filename$("DH2:AMOS/AMOSPro") results in "AMOSPro".

function: return the directory of a full path

Path$ returns the pathname part of a mixed path-filename string. Could be used as a kind of Parent$-Function too.

Example: Path$("DH2:AMOS/AMOSPro") returns "DH2:AMOS".

function: append a forward slash to a path if required

Adds a slash to a pathname, if it is a directory. Handy if you want to add a filename to a path.

Examples: Extpath$("DH2:AMOS")+"AMOSPro" returns "DH2:AMOS/AMOSPro",
          Extpath$("DH2:")+"AMOS"        returns "DH2:AMOS".

function: return an objects protection flags as a string
prot$=Object Protection$(prot)

Object Protection$ returns the Protection flags of an Object.
The Object Protection$ function converts this numeric value into a string in the format "hsparwed".

function: compare a string with a certain pattern
flag=Pattern Match(sourcestring$,pattern$)

Pattern Match checks, if the string 'sourcestring$' matches the pattern 'pattern$'.
If this is the case, then True (-1) will be returned otherwise False (0).
The pattern may contain any regular DOS jokers, an asterisk (*) will be converted into '#?' automatically.

This command only works on OS2.0 and higher.

function: return the state of a disk device
flags=Disk State(directory$)

Disk State acquires the current state of a disk drive. 'flags' is a bitmap which holds two bits:

0=0: The disk is not write protected, you can write onto the disk.
0=1: The volume is write protected or is currently being validated.
1=0: Currently the disk is not in use, nobody is reading or writing.
1=1: The disk is currently in use.

If no disk is in the drive, it normally should return -1, but I'm afraid in this case a requester will be opened with the title "No disk in drive xxx:" which creates the error 'File not found'.

Please use the following workaround:

Request Off
Request On
If Errtrap Then FLAGS=-1

function: return the type of a volume
type=Disk Type(directory$)

The Disk Type function returns the type of a directory. This value can be:

0: It is a real device              (e.g. 'DF0:')
1: The path is a directory (assign) (e.g. 'LIBS:')
2: It is the name of a volume       (e.g. 'Workbench2.0:')

Using this function you can filter specific disk types out of a device list.

function: calculate the hash value of a file
hash$=Dos Hash$(file$)

This function return the hash value of a file. Only for advanced users who want to read directly from dos disks.