Jump to content

Subscript used on non-accessible variable


Go to solution Solved by Melba23,

Recommended Posts

Hi there!

I am trying to modify a script (based on a script that I found in the forum - '?do=embed' frameborder='0' data-embedContent>>) that goes through a list of folders using _FileListToArrayRec, but when I try to retrieve the "modified date" of the folderd for my log, I keep getting a message:

(27) : ==> Subscript used on non-accessible variable.:
$sDate = $aDate[0] & "/" & $aDate[1] & "/" & $aDate[2]
$sDate = $aDate^ ERROR
 
I understand that there is an issue with retrieving the details from the array, but I can't quite figure out where my problem is.
I Wonder if anyone can help me identify the problem? Thanks!!
#include <Array.au3>
#include <File.au3>
#include <Date.au3>


; ***** Create local logs
$log = FileOpen (@ScriptDir & "\masterlog.log",2+256)
_FileWriteLog ($log,"*********************STARTING OPERATIONS*********************")

; put the root in a variable
$sRoot = (@ScriptDir)

; Retrieve a list of all the folders in $sRoot, and store them as an array in $aList
Global $aList = _FileListToArrayRec ($sRoot, "*", 2, 0) ; _FileListToArray("path" [, "Filter" [, Flag]])
; Look at what _FileListToArray() puts into $aList
_ArrayDisplay($aList)

; This is a loop that runs from 1 to the number of items listed in the first element of the returned array
For $i = 1 To $aList[0]
; For each folder, get the modified date/time and store its individual parts in array $aDate
$aDate = FileGetTime($sRoot & $aList[$i], 0, 0) ; FileGetTime("filename" [, option [, format]])

; Look at what FileGetTime() puts into $aDate
_ArrayDisplay($aDate)

; Build the properly formatted date string for _DateDiff()'s needs
$sDate = $aDate[0] & "/" & $aDate[1] & "/" & $aDate[2] ;0 index stores the year, 1 index stores month, 2 index stores day

; Look at what we made into $sDate
;msgbox(0,"Check Output", $sDate)

; Use _DateDiff() to see if the difference is greater than 90 days, and if it's true, then delete (for now just log) the folder and all its subfolders
If _DateDiff("D", $sDate, _NowCalcDate()) > 90 Then _FileWriteLog ($log,$sRoot & $aList[$i] & "  " & $sDate, 1)
Next
_FileWriteLog ($log,"*********************Script Completed Successfully*********************")
Link to comment
Share on other sites

  • Moderators
  • Solution

Tsiyoshi,

@ScriptDir does not have a trailing " " so you need to add it yourself: ;)

$aDate = FileGetTime($sRoot & "\" & $aList[$i], 0, 0)
M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...