Jump to content
Borje

SOLVED Need some little help with array to variable

Recommended Posts

Borje
Posted (edited)

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

Share this post


Link to post
Share on other sites
water
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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Borje

Thanks water but that not works what I want is the info from the array into in this example $till, example if i have e: i want to have this in $till

 

 

Share this post


Link to post
Share on other sites
water
$Till = StringUpper($aArray[$i])

I hope I correctly understand what you need :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Borje

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.

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Borje

Yes this is the whole script in the first post and I have same error.

Share this post


Link to post
Share on other sites
Subz
Posted (edited)

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

Share this post


Link to post
Share on other sites
Borje

Thank you very much Subz i test this and it worked i have to learn from your example thanks again.

Share this post


Link to post
Share on other sites
water
Posted (edited)

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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

×