PDF Explorer > General

Archive Extension grid column

(1/2) > >>

Padanges:
Hi,
I would like to create a "dynamically calculated column" by using "eval expression" which would hold Archive column entry filename extensions, that is, to create a column "Archive Extension". What syntax should I use?


Thanks in advance.

Padanges:
On the other hand, a column of zeros/ones for Archive indication would be sufficient. Can I create that using the dynamic calculation? Could you give an example?

Padanges:
Found the answer within documentation pages  ;D
"Dynamically calculated column expression to return the file extension. Useful to sort by file type (zip, rar, pdf, chm, ...)"

--- Code: ---begin
var 'i','s' end;
$s:=an;
if $s='' then
$s:=f;
endif;
$i:=pos('.',reversestr($s));
if $i>0 then
return(lowercase(rightstr($s,$i-1)));
else
return('');
endd;
end

--- End code ---
Is this syntax based on any language?

Padanges:
OK, let's change a question a bit. Here we have a code to find the first match of a Grid filename which has a character "!" (#33) using function pos().

--- Code: ---begin
var 'i','n' end;
$n:=grid.numrows;
for $i:=0;$i<$n; $i++ do
if pos(#33, grid.cell(fn,$i))<>0 then
// check file names for "!"
return($i+1+#32+grid.cell(f,$i)+#32);
// ASCII code for space is #32
endif;
next;
return('-');
end

--- End code ---
But the code gives no answer. Could you help with this? Documentation description for the pos() function is quite minimal. I guess that's where the problem lies.

Padanges:
If one would like to match, for example, file names which have words "and" in it, would it be possible to do that using: pos(#97#110#100, grid.cell(lowercase(fn),$i))<>0; as in the previous script?

Navigation

[0] Message Index

[#] Next page

Reply

Go to full version