Evaluator - How to use built-in variables?

This page (and others, too) states, that there are specific variables available in different contexts, like is_dir.

I've tried to use this var in an evaluator column like

if ($is_dir) { return "" as str };

However, this does not work as expected and the code following this line still get's executed and the return value is not space.

Additionally tried this code
if (is_dir) { return "" as str };
but this results in
grafik

Hence, what's the correct syntax in this case?
OTH, maybe I did not fully understood the command return. Does this stop processing and immediately immediately or does it only store the given value and proceed with the rest of the script?

Maybe worth adding the appropriate information to the documentation?

Replying myself: It seems that $is_dir is not working as expected as this line tries to prove:

Results in, folders are not recognized by the variable:
grafik

Looks right. Try it again, maybe the error messages got mixed up.

This works:

is_dir ? "dir here" : "not a dir"
1 Like

Cannot confirm this! I had to prefix with a $-sign

grafik

and the lister still shows "not a dir" for folders:
grafik

Edit: OK, you are correct, Sir!

The error message is wrong:

but the result is correct:
grafik

@Leo, @Jon maybe worth having a look into the misleading error message?

The error message is very odd. Maybe some other settings are off?

Here's my column:

Correct!

No error message in my coding when using a $-sign as a prefix, but the result is wrong.

When not using this prefix in an if condition, I get above error, however the result is correct :smiley:

Strange. I tried a few other languages, and all worked fine.

Any volunteers around who'd try the column?

XML
<?xml version="1.0"?>
<evalcolumn align="0" attrrefresh="no" autorefresh="no" foldertype="all" keyword="dirtest" maxstars="5" namerefresh="no" reversesort="no" title="dirtest" type="0">is_dir ? &quot;dir here&quot; : &quot;not a dir&quot;</evalcolumn>

lxp's code works just fine here.

2 Likes

Sorry for confusion, don't get me wrong, but @lxp coding works for me too:
grafik

This applies to an if-condition like here, too
grafik

But not when using an example file in the Evaluator Columns definition dialog. This throws an error:

The result in a lister is still correct:
grafik

Ah, yes, correct, that does throw up an error.

...and for some reasons, when prefixing the is_dir variable (with that $-sign), it does not throw this error

Short explanation: I've added the $-sign initially because it was not clear to me how to use such variables like is_dir and others, hence I've tested around a bit.

OTH, it may confuse if anyone else does such constructs that obviously do not result in any error. So, this may be worth fixing, if applicable.

staying away from evaluator columns for now. After installing some simple columns from this post Evaluator column data disappears on refresh - Opus 13 Public Beta - Directory Opus Resource Centre (dopus.com) and changing about 10 folder formats I discovered that the columns were not populating sometimes (cannot find what triggers this) so changed them back. Will wait till the evaluator columns become more stable. Evaluator Groups on the other hand (have set up many) seem to be working mostly alright.

No one else has reported a similar problem, as far as I'm aware, and we've never seen it ourselves either. It's not something we can look into unless there's a way to reproduce it or more information.

My little issues with evaluators aside (not usable in label filter assigments), I did not see that kind of problem so far.

I've set up only two eval columns so far, to be honest and all rows and columns have been populated with the expected values so far.

Looks like the is_dir and file_name variables aren't being provided in that context. We'll fix it in the next beta.

2 Likes