I have a test.wl file containing say
l= 5+2
I click on execute button of .wl file, but nothing happens. Some days ago this used to reply 7
I click on update and then call it from a main :
SetDirectory[NotebookDirectory[]];
AppendTo[$Path, Directory[]];
Clear["Global`*"];
Get["test.wl"]
l
but nothing happens. There is no error message, the file is found alright, but not executed.
Now, the documentation of Get says "<<name reads in a file, evaluating each expression in it and returning the last one". This used to be true on my computer some days ago, but not anymore, unless I shift-enter each cell of the .wl.
I can fix the problem by: 1) Quit kernel 2) execute the cells of .wl file by SHIFT-ENTER 3) "Help the .nb file find the .wl file" as below.
SetDirectory[NotebookDirectory[]];
AppendTo[$Path, Directory[]];
FindFile["test`"]
Get[%]
l
So, things do not happen anymore on my new Windows 11 computer, conforming to the DOCUMENTATION (and they seemed to work correctly, in the past). Clearly, the way things work now for me, with coaxing the .nb to find the .wl, shift-enter each cell of the .wl, quitting the kernel when it gets groggy, is not the way scripts are supposed to work. What could be the problem?
Directoryneeds[]. Also What does FilePrint @ "test.wl" show? my guess is a commented code because Print isn't a Code cell. – Kuba Nov 25 '22 at 11:49FindFile["test.wl"]? And what if you doImport["test.wl", "Text"]? – Lukas Lang Nov 27 '22 at 13:15(* ::Input:: ) (l=5+2*) But l remains undefined in the .nb file
– florin Nov 27 '22 at 14:48Importstatement was just to see the contents of the file for debugging purposes, not to execute anything. From yourFilePrintoutput, it looks like your cell is not marked as Code/Initilization cell, which is why it is commented out in your.wl. To confirm tgis, can you share a screenshot of the.wlfile opened in Mathematica? – Lukas Lang Nov 27 '22 at 16:12