Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2 questions (Q1: file attributes and Q2: variable in regex)
#1
Question 1
I have an array that consists of files and folders.
I want to cycle through each array item (file/folder-path) and get the following
  • Date modified
  • Date created
  • Date accessed

I have tried this:
Date Pic Taken
I have windows 7 and set the corresponding "iDetails" correctly, but is there an easier/updated way to approach this using an array?

An example of an array I use

Macro Macro24
Code:
Copy      Help
ARRAY(str) arr_paths
arr_paths.create(4)
arr_paths[0]="f:\__windows_folders\_user\desk\qm_testdirs\1" ;;folder
arr_paths[1]="f:\__windows_folders\_user\desk\qm_testdirs\2" ;;folder
arr_paths[2]="f:\__windows_folders\_user\desk\qm_testdirs\3.txt" ;;textfile
arr_paths[3]="f:\__windows_folders\_user\desk\qm_testdirs\4.txt" ;;textfile


Question 2

I have a path "c:\1\2\3\4" and I have an regular expression F"^((.*?)\\){limit}" , where "limit" is an integer.
If I want "c:\1\2\" I set the 'limit' to 3, so the regex becomes likes this: ^((.*?)\\){3}

The problem is I can't get the variable "limit" included in the regex when using \Q\E sequence.
If I hardcode the "limit" whitin the regex (example: "^((.*?)\\){3}") then I get the wanted result.
I also tried the 's.escape' method but then all the curly braces get escaped.
I had an similair problem here: beginner: regex ini-like file and variable within regex but the problem now lies within the combination of the 'F-operator' and the curly braces.


Macro Macro23
Code:
Copy      Help
int limit=3
str path_depth_rgex=F"^((.*?)\\){limit}" ;; => must add /Q and /E
;str path_depth_rgex="^((.*?)\\){3}" ;;when hardcoding the "limit" within the regex, it works
str path="f:\__windows_folders\_user\desk\qm_testdirs\abc_test_folder_6\test_subfolder_6\abc_test_subtext_6.txt"
str s

if(findrx(path path_depth_rgex 0 0 s)>=0)
,out s

;; output when limit=3:
;; f:\__windows_folders\_user\

I found a way around using the following method

Macro Macro23
Code:
Copy      Help
str path_depth_rgex p1 p2 p3
p1="^((.*?)\\){"
p2=F"{textdir_depth}"
p3="}"
;
path_depth_rgex.from(p1 p2 p3)

But is there a better method to approach this?
#2
1. floating toolbar -> files -> file info.

Code:
Copy      Help
int i
for i 0 a.len
,Dir d
,if d.dir(a[i] 0) ;;if exists
,,DateTime tm=d.TimeModified
,,out tm.ToStr
,,DateTime tc=d.TimeCreated
,,out tc.ToStr
,,DateTime ta=d.TimeAccessed
,,out ta.ToStr

2. QM Help -> Strings with variables -> As escape sequence for { can be used {{.

Code:
Copy      Help
int limit=9
out F"...{{{limit}}"
;or
out _s.format("...{%i}" limit)
#3
Ok, thank you!!!


Forum Jump:


Users browsing this thread: 1 Guest(s)