Jump to content

SOLVED Need some little help with array to variable


 Share

Recommended Posts

Hello everybody I need som ehlp with this script to have the arrayinfo in to a variable what I want is to have $aArray[$1] in to $till and I have not this to work

perhaps anybody here cold help me what i must do.

 

Local $aArray = DriveGetDrive("ALL")
For $i = 1 To $aArray[0]
If DriveSpaceTotal(StringUpper($aArray[$i])) < "65000" And DriveSpaceTotal(StringUpper($aArray[$i])) > "0" Then
  MsgBox(4096, "", "Drive " & StringUpper($aArray[$i]) & " is my thumb drive.")
EndIf
Next

 

Edited by Borje
Link to comment
Share on other sites

Local $aArray = DriveGetDrive("ALL")
If @error Then Exit MsgBox(0, "Error", "DriveGetDrive returned an error!")
For $i = 1 To $aArray[0]
    $sDriveUpper = StringUpper($aArray[$i])
    $iDriveSpaceTotal = DriveSpaceTotal($sDriveUpper)
    If @error Then Exit MsgBox(0, "Error", "DriveSpaceTotal for " & $sDriveUpper & " returned an error!")
    If $iDriveSpaceTotal < 65000 And $iDriveSpaceTotal > 0 Then
        MsgBox(4096, "", "Drive " & $sDriveUpper & " is my thumb drive.")
    EndIf
Next

Untested, but we would at least get some error information.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

$Till = StringUpper($aArray[$i])

I hope I correctly understand what you need :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Yes you have understand me correctly i have tested this before and I have this error:

Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$Till = StringUpper($aArray[$i])
$Till = StringUpper(^ ERROR

So I dont know how to do to have this to works.

Link to comment
Share on other sites

This means that $i is invalid for this array. You try to access a non existing elment.

Did you post the whole script you run?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

You need to do this within the For <> Next loop, for example:

Local $aArray = DriveGetDrive("ALL")
For $i = 1 To $aArray[0]
    If DriveSpaceTotal(StringUpper($aArray[$i])) < "65000" And DriveSpaceTotal(StringUpper($aArray[$i])) > "0" Then
        $Till = StringUpper($aArray[$i])
        ExitLoop
    EndIf
Next
MsgBox(4096, "", "Drive " & $Till & " is my thumb drive.")

 

Edited by Subz
Link to comment
Share on other sites

That's why I asked for the whole code :) 
You never used $i outside the loop in the psoted code or code snippet.
Lessons learned: ALWAYS post the full code that raises the error!

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...