Source language: Translate to:

Error while detecting all drives connected to the PC

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Error while detecting all drives connected to the PC

Postby PaulTomo » Thu Jul 25, 2013 5:13 pm

Hello All,

I have not been here for some time, but have recently stumbled across an issue that seems to only show up once the NB pub has been compiled and then run on a Windows 7 system that has a multi card reader attached.

The issue I'm getting is when I need to generate a list of drives that are connected to the PC so the NB pub can locate a device once its been connected.
This piece of code works well, so has been created as a function, I simply call the function and it does just what I need.

Code: Select all
SetVar "[DriveList]" "CDEFGHIJKLMNOPQRSTUVWXYZ"
StrLen "[DriveList]" "[DriveListLen]"
Loop "1" "[DriveListLen]" "[Cnt]"
    SubStr "[DriveList]" "[Cnt]" "1" "[DriveLetter]"
    FileList "[DriveLetter]:" "" "[FileData]"
        If "[LastError]" "=" ""
           Math "[DriveNum]+1" "" "[DriveNum]"
           SetVar "[Arrayofdrives[DriveNum]]" "[DriveLetter]:"
        Endif
EndLoop


I have also used the following plugin to see if this would fix my issue.

Code: Select all
rlGetAllDisk "[Arrayofdrives]" "[DriveNum]"


Both the options above work fine during debug mode but once compiled and then run live, although all the connected drives are listed okay and the NB pub can locate a device once its been connected as I want it too, so I know the code is not at fault but if there is multi card reader connected that has any empty slots, I get a repeating error, I think it is generated by Windows and it states:

There is no disk in the drive. Please insert a disk into drive
\Device\Harddisk2\DR2


With options to Cancel, Try Again and Continue.

I can click any of the options and the pub then continues until the next empty slot is detected and so on until all drive letters have been added to the array.

Now that my issue has been detailed, on to my question. (Note: NeoBook v5.8.4 is being used)

Is there anything I can do, apart from making sure all the multi card reader slots are not empty! to stop this error from appearing all the time? Its a little annoying when it appears 7 or 8 times each time the function is used.

Any Thoughts :!:

Many Thanks for your time and hopefully someone may have a solution that will help. :)

Paul
User avatar
PaulTomo
 
Posts: 62
Joined: Tue Apr 28, 2009 1:15 am
Location: UK

Re: Error while detecting all drives connected to the PC

Postby CN_Iceman » Fri Jul 26, 2013 1:03 am

Check npDriveType command included in the npUtil plugin from David Esperalta.
http://neoplugins.com/?help/nputil#npDriveType

All my problems with drive units have been fixed after using this command. The idea is to know the type of drive and if sdcard type, skip verification.

Greetings.
Greetings/Saludos, Jose.
www.icemansoft.es
User avatar
CN_Iceman
 
Posts: 297
Joined: Tue Mar 01, 2011 11:04 am
Location: España

Re: Error while detecting all drives connected to the PC

Postby dec » Fri Jul 26, 2013 2:12 am

Hello,

Maybe my npNots plugin can be useful here too, since they can advise when a new drive is detected, without know if the drive previously exists or not.

P.D. Thanks Jose. ;)
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: Error while detecting all drives connected to the PC

Postby Cipolla » Fri Jul 26, 2013 4:25 am

Paul, please try the following VBScript function that i used in a project to get a list of all ready drives. I use it on a Windows 7 machine.

function (copy to your function folder, name it i.e "drivelist")

Code: Select all
{NeoBook Function}
Version=5,80
Language=VBScript
Param=[%1]|Variable|DriveList
{End}
Dim AllDrives
Dim Drive
Set AllDrives = CreateObject("Scripting.FileSystemObject")
For Each Drive In AllDrives.Drives
  If Drive.IsReady Then
    DriveList = DriveList & Drive.Path & ";"
  End If
Next
DriveList = left(DriveList, len(DriveList) - 1)
   
publication.nbSetVar "[%1]", DriveList


And in your publication:

Code: Select all
Call "drivelist" "[Result]"
StrParse "[Result]" ";" "[drives]" "[drives_count]"
Greetings from Germany
Klaus
User avatar
Cipolla
 
Posts: 166
Joined: Fri Apr 01, 2005 1:45 am
Location: Germany

Re: Error while detecting all drives connected to the PC

Postby CN_Iceman » Fri Jul 26, 2013 11:51 am

This is a nice "non-plugin" solution.
Tested and working properly.

Thank's Cipolla.
Greetings/Saludos, Jose.
www.icemansoft.es
User avatar
CN_Iceman
 
Posts: 297
Joined: Tue Mar 01, 2011 11:04 am
Location: España

Re: Error while detecting all drives connected to the PC

Postby PaulTomo » Tue Jul 30, 2013 11:31 am

Many Thanks for your replies, gives me quite a few options to try.

I'll let you know how I get on.

:P
User avatar
PaulTomo
 
Posts: 62
Joined: Tue Apr 28, 2009 1:15 am
Location: UK

Re: Error while detecting all drives connected to the PC

Postby PaulTomo » Tue Jul 30, 2013 4:07 pm

Klaus,

your VBScript option was by far the easiest to add, Good Work!

Did just what I needed and no annoying errors show now.

Many Thanks to all!

:D
User avatar
PaulTomo
 
Posts: 62
Joined: Tue Apr 28, 2009 1:15 am
Location: UK

Re: Error while detecting all drives connected to the PC

Postby Cipolla » Wed Jul 31, 2013 1:11 am

Paul, I am really pleased to hear that. That´s why i love Neobook and the community.

Many paths leading to a common goal, but there is almost always a solution.
Greetings from Germany
Klaus
User avatar
Cipolla
 
Posts: 166
Joined: Fri Apr 01, 2005 1:45 am
Location: Germany

Re: Error while detecting all drives connected to the PC

Postby CN_Iceman » Wed Jul 31, 2013 4:11 am

Cipolla wrote:Paul, I am really pleased to hear that. That´s why i love Neobook and the community.
Many paths leading to a common goal, but there is almost always a solution.


+1
Greetings/Saludos, Jose.
www.icemansoft.es
User avatar
CN_Iceman
 
Posts: 297
Joined: Tue Mar 01, 2011 11:04 am
Location: España

Re: Error while detecting all drives connected to the PC

Postby mishem » Thu Aug 01, 2013 12:07 pm

And this code will work in Windows7
Code: Select all
SetVar "[DriveList]" "C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"
StrParse "[DriveList]" "," "[Drive]" ""
Loop "1" "24" "[i]"
  FolderExists "[Drive[i]]:\" "[Result]"
  If "[Result]" "=" "False"
     ClearVariables "[Drive[i]]"
     Else
     SetVar "[J]" "[J]+1"
     SetVar "[Drive[J]]" "[Drive[i]]"
  EndIf
EndLoop
ClearVariables "[DriveList],[i],[Result],[J]"
mishem
 
Posts: 574
Joined: Mon Oct 08, 2012 1:51 pm


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest