Message Boards Message Boards

0
|
3175 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Unexpected result from WolframScript command line

Posted 2 years ago
num = ToExpression[$ScriptCommandLine[[2]]];
        num2 = ToExpression[$ScriptCommandLine[[3]]];
        rs0=x^2;
        D[rs0,x];
        ff[x_]=%
        aa=ff[num+num2]
        Print[aa]

Command line:
wolframscript -file second.wls 2 3
The result is Out[0], I don't know why. Thank you!

POSTED BY: Cao Bb
4 Replies
Posted 2 years ago

The output from D[rs0,x]; is suppressed, so % defaults to Out[0]. Best to avoid %.

num = ToExpression[$ScriptCommandLine[[2]]];
num2 = ToExpression[$ScriptCommandLine[[3]]];
rs0=x^2;
d=D[rs0,x];
ff[x_]:=Evaluate@d
aa=ff[num+num2];
Print[aa]
POSTED BY: Rohit Namjoshi
Posted 2 years ago

Why is it suppressed when using command line, thank you very much!

POSTED BY: Cao Bb
Posted 2 years ago

Not command line specific. The ; and the end of the expression suppresses output even in a notebook.

POSTED BY: Rohit Namjoshi
Posted 2 years ago

Ok, thank you!

POSTED BY: Cao Bb
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract