Source language: Translate to:

USB Explorer

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

USB Explorer

Postby Neobook » Sun Feb 04, 2007 3:00 am

Hello,

I want to have a USB Explorer, but I didn't find a variable with [USB], so I try that :

If "E:\" "=" "True"
Setvar "[ImageDir]" "E:\"
Endif
If "H:\" "=" "=True"
Setvar "[ImageDir]" "H:\"
Endif
If "F:\" "=" "True"
Setvar "[ImageDir]" "F:\"
Endif

But it saied there is a driver error.


I took the Image Viewer example for do my USB Explorer.

You know, for the CDDrive, there is the variable [CDRomDrive], so if there is not the [USB] variable, maybe can I make it. But my code what I did, didn't work.

If you can help me.
Neobook
 
Posts: 131
Joined: Sat Jul 01, 2006 7:07 am

Postby Neobook » Sun Feb 04, 2007 4:27 am

Hello,

Thanks for your answer, is there an another possibility that rtGetDriveType ?
Neobook
 
Posts: 131
Joined: Sat Jul 01, 2006 7:07 am

Postby Sam Cox » Sun Feb 04, 2007 7:23 am

I think you have a misconception about USB. Even though we often talk about "USB drives," USB is an interface and not a type of drive, and it is possible to have multiple drives attached through the USB interface. I have three drives attached to my laptop when I'm not travelling.

But the important part of your question seems to be "how can I know that a certain disk is available?" There is a way using only Neobook commands. The method is to issue a command to the drive and determine if it responds. The trick is to handle the errors that Neobook would normally handle when issuing a command to a non-responding device.

This code that illustrates one way of determining whether a certain drive letter is responding:
Code: Select all
.drive K: does not exist on my system
SetVar "[Drive]" "K:"

ShowErrors "False"
FileList "[Drive]" "Files" "[ReturnValueNotUsed]"
ShowErrors "True"

If "[LastError]" "<>" ""
   AlertBox "MY ERROR MESSAGE" "THERE IS A PROBLEM HERE||[LastError]"
Endif

You should be able to adapt this code to your purposes. It would be useful to generalize this code as a function so you could write:
Code: Select all
Call "DriveExists" "A:" "[ReturnVar]"
or
Code: Select all
SetVar "[Drive]" "A:"
Call "DriveExists" "[Drive]" "[DriveExists]"
Last edited by Sam Cox on Sun Feb 04, 2007 9:25 am, edited 2 times in total.
User avatar
Sam Cox
 
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

Postby Neobook » Sun Feb 04, 2007 8:00 am

Thanks
Neobook
 
Posts: 131
Joined: Sat Jul 01, 2006 7:07 am

Postby Neobook » Mon Feb 05, 2007 12:31 pm

Hi Sam,

I don't know why is it not working.
Last edited by Neobook on Wed Feb 07, 2007 6:44 am, edited 1 time in total.
Neobook
 
Posts: 131
Joined: Sat Jul 01, 2006 7:07 am

Postby Sam Cox » Wed Feb 07, 2007 6:12 am

Hello Neobook,

Try making these changes to your code:
Code: Select all
.PAGE ENTER CODE

.drive letters to inspect in the order you want to inspect them
SetVar "[DriveList]" "KF"
StrLen "[DriveList]" "[DriveList.Len]"
Loop "1" "[DriveList.Len]" "[N]"
   SubStr "[DriveList]" "[N]" "1" "[DriveLetter]"
   ShowErrors "False"
   FileList "[DriveLetter]:" "Files" "[ReturnValueNotUsed]"
   ShowErrors "True"
   If "[LastError]" "=" ""
      ExitLoop
   Endif
   SetVar "[DriveLetter]" ""
EndLoop

If "[DriveLetter]" "<>" ""
  SetVar "[ImageDir]" "[DriveLetter]:\"
  Gosub "Refresh34"
Else
  AlertBox "[PubTitle] - DRIVE NOT FOUND" "Can't find the USB drive"
  Exit "" ""
Endif
Return
Code: Select all
.SUBROUTINES

:Refresh34

.load folders in image dir
FileList "[ImageDir]*.*" "Folders" "[Temp]"
StrParse "[Temp]" "[#13]" "[Dir]" "[DirCount]"
SetVar "[Temp]" ""
Loop "1" "[DirCount]" "[x]"
  If "[Dir[x]]" ">" ""
    SetVar "[Temp]" "[#91][Dir[x]][#93][#13][Temp]"
  EndIf
EndLoop
SetVar "[Folders]" "[Temp]"
DeleteArray "[Dir]" "[DirCount]"

.load compatible image files in image dir
FileList "[ImageDir]*.*" "Files" "[Temp]"
StrParse "[Temp]" "[#13]" "[File]" "[FileCount]"
SetVar "[Temp]" ""
Loop "1" "[FileCount]" "[x]"
  If "[File[x]]" ">" ""
    If "[Temp]" ">" ""
      SetVar "[Temp]" "[Temp][#13]"
    EndIf
    SetVar "[Temp]" "[Temp][File[x]]"
  EndIf
EndLoop
SetVar "[Filesw]" "[Temp]"
DeleteArray "[File]" "[FileCount]"

Return
User avatar
Sam Cox
 
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

Postby Neobook » Wed Feb 07, 2007 6:42 am

Thanks

It works very good

Thank you very much
Neobook
 
Posts: 131
Joined: Sat Jul 01, 2006 7:07 am


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 2 guests