04-22-2016, 08:37 PM
Macro Macro6
How can you sort on filesize and date using ARRAY a?
EDIT: I found out (I think) , and sorry for the wrong path in "str folder" I corrected it.
I have put the explanation in green code, but I do not know if it is correct:
Macro Macro2
What confuses me is in the example (when you press F1 in QM editor on the "GetFilesInFolder" function)
Or here:
Copy most recent file
You see:
Macro Macro2
The "_i" represents:
Neither in the QM helpfile example as well as in the topic link, the container _i get's a value, it's always zero.
Also in my example but the code works... Is there something I missed.
Or when _i=0, the "val" function starts processing from the most left position of the provided string until it receivers a none-numeric character??
(That would explain that it works, but I could be totally off...)
int i
ARRAY(str) a
str folder="e:\test"
GetFilesInFolder a folder "" 2 1 ;; getprop 1 = size (3=time created)
for i 0 a.len
,out a[i]
How can you sort on filesize and date using ARRAY a?
EDIT: I found out (I think) , and sorry for the wrong path in "str folder" I corrected it.
I have put the explanation in green code, but I do not know if it is correct:
Macro Macro2
ARRAY(str) a
str folder="e:\test"
GetFilesInFolder a folder "" 2 1 ;; last number: 1 = size / 3 = time created
int i
;a[] contains paths like this
;45624 e:\test\file2.txt
;124 e:\test\file2.txt
;1940 e:\test\file3.doc
;130 e:\test\file4.doc
;You can now sort array becuase each item in array begins with integer value
;To output the PATH only, use the following in for loop (i=counter in 'for-loop').
;long t=val(a[i] 1 _i) => it seems to extract the INTEGER value only.
;To output the path only, put the NUMERIC-part (integer value) in a string container with the command:
;_s=t
;Then the following command only outputs the path
;str sPath=a[i]+_s.len+1
;It seems the number after the a[i] => a[i]+[NUMBER] is the characterposition from where the
;actual path begins. The +1 just takes into account the empty space.
a.sort(8)
for i 0 a.len
,long t=val(a[i] 1) ;; Convert the NUMBER part only to long ?
,_s=t
,str sPath=a[i]+_s.len+1 ;;a[i]+# , # is character position number where PATH begins
,out sPath
What confuses me is in the example (when you press F1 in QM editor on the "GetFilesInFolder" function)
Or here:
Copy most recent file
You see:
Macro Macro2
The "_i" represents:
Quote:length - int variable that receives the number of characters from the beginning of s to the end of the part of s that contains the number. Receives 0 if s does not begin with a number or the number is too big.
Neither in the QM helpfile example as well as in the topic link, the container _i get's a value, it's always zero.
Also in my example but the code works... Is there something I missed.
Or when _i=0, the "val" function starts processing from the most left position of the provided string until it receivers a none-numeric character??
(That would explain that it works, but I could be totally off...)