'LETTER_OF_USB_DEVICE 'program by Euklides
'Working with files on USB devices
'When you write a program using files located on USB drives, you don't be
'sure that the letter of this drive is always the same.
'You cannot write for instance:
' OPEN "F:\MYFILE\info.txt" FOR INPUT AS #1
' ...
'If your drive has a new letter, for instance "E", you must go into your program
' and change the letter
'So what you can do is this:
'1) ' find the serial of your drive
' Use below:
' GOSUB SERIALSSHOW
' and you will see all the serials of then actuel connected drives
' For instance, the good drive has the serial "<9911-447E>
'2) Now write your program so:
' fic$ = "<9911-447E>:\MYFILE\info.txt"
' GOSUB DRIVELETTERFIND: IF _CLIPBOARD$ = "" THEN PRINT "USB unit is not connected for using " + fic$: END
' fic$ = _CLIPBOARD$:OPEN fic$ FOR INPUT AS #1
' ...
'=====================================================================
FUNCTION GetVolumeInformationA&
(lpRootPathName$
, lpVolumeNameBuffer$
, BYVAL nVolumeNameSize~&
, _
lpVolumeSerialNumber~&
, lpMaximumComponentLength~&
, lpFileSystemFlags~&
, lpFileSystemNameBuffer$
, BYVAL nFileSystemNameSize&
)'---
SERIALSSHOW:
FOR q
= 1 TO 26: X
= GetFileInfo
(q
):
IF SERIALFOUND
<> "<!!!-!!!>" THEN PRINT " ";
CHR$(64 + q
) + ": "; SERIALFOUND
'---
DRIVELETTERFIND: 'in-->fic$ like' "<SER-IAL>ficname" out--> like "D:\ficname"
IF J1
= 0 OR J2
= 0 THEN PRINT fic$;
" must be written like: <serial>\ficmame...":
END Serialsearch$
= MID$(fic$
, J1
, J2
- J1
+ 1): q
= 0FOR q
= 1 TO 26: X
= GetFileInfo
(q
) IF SERIALFOUND
= Serialsearch$
THEN '---
SERIALFOUND = "<!!!-!!!>":
Dname$
= CHR$(D
+ 64) + ":\": Sname$
= SPACE$(260) R
= GetVolumeInformationA
(Dname$
+ CHR$(0), Vname$
, 260, serial~&
, empty1~&
, empty2~&
, Sname$
, 260) SERIALFOUND = "<" + Sname$ + ">"
GetFileInfo = -1
'---
DRIVEEXISTS
= 0: varX$
= CHR$(V
+ 64) + ":\" + CHR$(0): VarX
= GetDriveType
(varX$
):
IF VarX
> 1 THEN DRIVEEXISTS
= 1'=====================================================================