Jump to content

_ArrayDisplay and FileGetTime


gius
 Share

Recommended Posts

Hello everyone,
I apologize for my English.

I am developing a small application
with _ArrayAdd

Local $aFileList = _FileListToArray (@DesktopCommonDir)
Local $aFileList1 = _FileListToArray (@DocumentsCommonDir)
Local $aFileList2 = _ArrayAdd ($aFileList, $aFileList1)
_ArrayDisplay ($aFileList2)

but is not nothing in _ArrayDisplay,
  why?

Then, how I can see the file, the date of modification?

FileGetTime ($aFileList, $ FT_MODIFIED, 1)
and
FileGetTime ($aFileList1, $ FT_MODIFIED, 1)

Where I can add?

Thanks for your help

Link to comment
Share on other sites

Read again help file over _ArrayDisplay _ArrayAdd, and you'll discover that it uses a ByRef first parameter and returns something distinct from what you expect it to.

Yet my answer isn't quite right as Melba rightly stressed just now. I badly need a second coffee for the other eye...

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

  • Moderators

gius,

Welcome to the AutoIt forums. :)

You need to concatenate the arrays. Here is an example which shows you how to do what you want:

#include <Array.au3>
#include <File.au3>

Local $aFileList = _FileListToArray (@DesktopCommonDir)
; Add a column
_ArrayColInsert($aFileList, 1)
; And loop through the elements to get the time stamp
For $i = 1 To $aFileList[0][0]
    $aFileList[$i][1] = FileGetTime(@DesktopCommonDir & "\" & $aFileList[$i][0], $FT_MODIFIED, 1)
Next
; Here is the result
_ArrayDisplay($aFileList, "@DesktopCommonDir", Default, 8)

; Now do the same for the other list
Local $aFileList1 = _FileListToArray (@DocumentsCommonDir)
; Add a column
_ArrayColInsert($aFileList1, 1)
; And loop through the elements to get the time stamp
For $i = 1 To $aFileList1[0][0]
    $aFileList1[$i][1] = FileGetTime(@DocumentsCommonDir & "\" & $aFileList1[$i][0], $FT_MODIFIED, 1)
Next
; Here is the result
_ArrayDisplay($aFileList1, "@DocumentsCommonDir", Default, 8)

; Use concatenate to join arrays - note we do not concatenate the count from the second array
_ArrayConcatenate ($aFileList, $aFileList1, 1)
; But we add it here
$aFileList[0][0] += $aFileList1[0][0]

;And here you have the result
_ArrayDisplay($aFileList, "Concatenated", Default, 8)
Please ask if you have any questions. :)

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

Thank You Melba23,

your commented code, it is really clear and very well explained.

I have a small problem:
if I insert address as a folder on the Desktop,
example folder "Test"
I have an error

is no longer visible the last modification

Local $aFileList = _FileListToArray (@DesktopDir "Test")
$aFileList [$i] [1] = FileGetTime (@DesktopDir "Test" & $aFileList [$i] [0], $FT_MODIFIED, 1)

where I am wrong?


thanks again

 

I apologize, I realized that I had not entered "" after the address of the folder "Test"

Local $aFileList = _FileListToArray (@DesktopDir "Test")
$aFileList [$i] [1] = FileGetTime (@DesktopDir "Test"  & "" & $aFileList [$i] [0], $FT_MODIFIED, 1)

Sorry and thanks again

Edited by gius
Link to comment
Share on other sites

Sure. Please have a look at StringRegExpReplace or search the forum for "date formatting" or something similar.

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

; Method 1, with an array
$aTime = FileGetTime (@ScriptFullPath)
$sRes = $aTime[0] & "/" & $aTime[1] & "/" & $aTime[2] & "[" & $aTime[3] & ":" & $aTime[4] & ":" & $aTime[5] & "]"
ConsoleWrite($sRes & @CRLF)

; Method 2, with string manipulation
$sTime = FileGetTime (@ScriptFullPath, 0, 1)
$sRes = StringRegExpReplace($sTime, "^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})", "$1/$2/$3[$4:$5:$6]")
ConsoleWrite($sRes & @CRLF)

Link to comment
Share on other sites

Thank You jguinch and water

for your help,
but in this code 
#include <Array.au3>
#include <File.au3>

Local $aFileList = _FileListToArray (@DesktopCommonDir)
; Add a column
_ArrayColInsert($aFileList, 1)
; And loop through the elements to get the time stamp
For $i = 1 To $aFileList[0][0]
    $aFileList[$i][1] = FileGetTime(@DesktopCommonDir & "\Test" & "\" & $aFileList[$i][0], $FT_MODIFIED, 1)
Next
; Here is the result
_ArrayDisplay($aFileList, "@DesktopCommonDir", Default, 8)
I can not understand where to insert
$sRes = $aTime[0] & "/" & $aTime[1] & "/" & $aTime[2] & "[" & $aTime[3] & ":" & $aTime[4] & ":" & $aTime[5] & "]"

You can still help me?
thank you

Link to comment
Share on other sites

  • Moderators

gius,

You need to do something like this: :)

For $i = 1 To $aFileList[0][0]
    ; Get file timestamp as an array
    $aTime = FileGetTime(@DesktopCommonDir & "\Test\" & $aFileList[$i][0], $FT_MODIFIED)
    ; Format the array elements as required
    $aFileList[$i][1] = $aTime[0] & "/" & $aTime[1] & "/" & $aTime[2] & "[" & $aTime[3] & ":" & $aTime[4] & ":" & $aTime[5] & "]"
Next
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

Thank You Melba23,

I put your help

#include <Array.au3>
#include <File.au3>
Local $aFileList = _FileListToArray (@DesktopCommonDir & "\Test\") ; Add a column
_ArrayColInsert($aFileList, 1) ; And loop through the elements to get the time stamp
For $i = 1 To $aFileList[0][0]     ; Get file timestamp as an array
$aTime = FileGetTime(@DesktopCommonDir & "\Test\" & $aFileList[$i][0], $FT_MODIFIED)
; Format the array elements as required
 $aFileList[$i][1] = $aTime[0] & "\" & $aTime[1] & "\" & $aTime[2] & "[" & $aTime[3] & ":" & $aTime[4] & ":" & $aTime[5] & "]"
Next

_ArrayDisplay($aFileList, "@DesktopCommonDir", Default, 8)

but I returns this error:

Subscript used on non-accessible variable.:
For $i = 1 To $aFileList[0][0]
For $i = 1 To $aFileList^ ERROR

I have done something wrong?

thank you

Link to comment
Share on other sites

  • Moderators

gius,

That would mean that the function has not found any files in the folder. So you need to add some errorchecking, perhaps like this: :)

#include <Array.au3>
#include <File.au3>

Local $aFileList = _FileListToArray (@DesktopCommonDir & "\Test")
If Not @error Then
    ; Add a column
    _ArrayColInsert($aFileList, 1)
    ; And loop through the elements to get the time stamp
    For $i = 1 To $aFileList[0][0]
        $aTime = FileGetTime(@DesktopCommonDir & "\Test" & "\" & $aFileList[$i][0], $FT_MODIFIED)
        $aFileList[$i][1] = $aTime[0] & "/" & $aTime[1] & "/" & $aTime[2] & "[" & $aTime[3] & ":" & $aTime[4] & ":" & $aTime[5] & "]"
    Next
    ; Here is the result
    _ArrayDisplay($aFileList, "@DesktopCommonDir", Default, 8)
Else
    MsgBox($MB_SYSTEMMODAL, "Error", "No files found")
EndIf
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

Thank You Melba23,
Your code works fine.

I have tried to add a second column, $ FT_CREATED,

#include <Array.au3> 
#include <File.au3> 
Local $aFileList = _FileListToArray (@DesktopCommonDir & "\Test") 
If Not @error Then     
; Add a column     
   _ArrayColInsert($aFileList, 2)     
; And loop through the elements to get the time stamp     
   For $i = 1 To $aFileList[0][0]         
      $aTime = FileGetTime(@DesktopCommonDir & "\Test" & "\" & $aFileList[$i][0], $FT_MODIFIED,$FT_CREATED)        
      $aFileList[$i][2] = $aTime[0] & "/" & $aTime[1] & "/" & $aTime[2] & "[" & $aTime[3] & ":" & $aTime[4] & ":" & $aTime[5] & "]"    
   Next     ; Here is the result    
   _ArrayDisplay($aFileList, "@DesktopCommonDir", Default, 8) 
Else     
MsgBox($MB_SYSTEMMODAL, "Error", "No files found") 
EndIf

but I'm wrong in something,

where?

thank you

Link to comment
Share on other sites

  • Moderators

gius,

You need to read the Help file when you try to change function parameters - what you did made no sense at all when you look how the functions work. ;)

If you want another column with the created time you need to do something like this: :)

#include <Array.au3>
#include <File.au3>

Local $sPath = @DesktopCommonDir & "\Test"
Local $aFileList = _FileListToArray($sPath)
If Not @error Then
    ; Add 2 columns <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    _ArrayColInsert($aFileList, 1)
    _ArrayColInsert($aFileList, 2)
    ; And loop through the elements to get the different time stamps
    For $i = 1 To $aFileList[0][0]
        $sFile = $sPath & "\" & $aFileList[$i][0]
        $aTime_Mod = FileGetTime($sFile, $FT_MODIFIED)    ; Modified time
        $aTime_Created = FileGetTime($sFile, $FT_CREATED) ; Created time
        ; Now add these values to the array
        $aFileList[$i][1] = $aTime_Mod[0] & "/" & $aTime_Mod[1] & "/" & $aTime_Mod[2] & "[" & $aTime_Mod[3] & ":" & $aTime_Mod[4] & ":" & $aTime_Mod[5] & "]"
        $aFileList[$i][2] = $aTime_Created[0] & "/" & $aTime_Created[1] & "/" & $aTime_Created[2] & "[" & $aTime_Created[3] & ":" & $aTime_Created[4] & ":" & $aTime_Created[5] & "]"
    Next ; Here is the result
    _ArrayDisplay($aFileList, "@DesktopCommonDir", Default, 8)
Else
    MsgBox($MB_SYSTEMMODAL, "Error", "No files found")
EndIf
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...