Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


itcasgrain
2024-07-23T15:16:51Z
These scripts all worked prior to version 10 but now they all fail so we are stuck on an older version.

A simple example that shows the behavior:

$RESULTS=Import-Csv {USERVAR(dstsautosaves)}\trades_intraday.csv | where-object {($_.Customer -like "10*")}
write-output $results

That ends in error with thie message:

System.Management.Automation.ParentContainsErrorRecordException: At line:1 char:59
+ $RESULTS=Import-Csv User Variable not found: dstsautosaves)}\trades_i ...
+ ~
Unexpected token ')' in expression or statement.

At line:1 char:60
+ $RESULTS=Import-Csv User Variable not found: dstsautosaves)}\trades_i ...
+ ~
Unexpected token '}' in expression or statement.

Exception in Task: At line:1 char:59
+ $RESULTS=Import-Csv User Variable not found: dstsautosaves)}\trades_i ...
+ ~
Unexpected token ')' in expression or statement.

At line:1 char:60
+ $RESULTS=Import-Csv User Variable not found: dstsautosaves)}\trades_i ...
+ ~
Unexpected token '}' in expression or statement.

Now without the where object it runs just fine:

$RESULTS=Import-Csv {USERVAR(dstsautosaves)}\trades_intraday.csv
write-output $results

That results in the isting of the csv as desired.

Anyone having the same issue?





Sponsor
Forum information
bweston
2024-07-23T16:36:46Z
Not currently, but this looks to me like a regression, because I've seen something very similar before. I believe Visualcron used to use (and may be using again) eager parsing for variable expressions, and is finding the
)}

closest to the end of the line, and therefore looking for a user variable named
dstsautosaves)}\trades_intraday.csv | where-object {($_.Customer -like "10*"

and not finding one. (Which I would say is a good thing; that would be a terrible name for a variable.) Note that in your code that works, without the where-object block, there isn't another thing on the line that could look to Visualcron like the end of a Visualcron variable expression.

My workaround at least used to be to put a space before any closing curly brace that is supposed to be powershell syntax and not the end of a Visualcron expression. Example:
$RESULTS=Import-Csv {USERVAR(dstsautosaves)}\trades_intraday.csv | where-object {($_.Customer -like "10*") }


Also note the inverse implication: that Visualcron will probably also get mixed up if you put a space between the closing paren and the brace when they ARE supposed to end the Visualcron expression.

In your example, the parentheses in the where-object block are also superfluous, but you mentioned specifically that this was a simple example, so I assume you may have cases that do need them.

I think this may also only happen within the context of a single line, but I'm not 100% sure.
itcasgrain
2024-07-23T17:30:20Z
Hello,

well that was fast and it does indeed work; I will try and modify the actual script to see where it takes me and then report back.

Thank you very much for your help!
Scroll to Top