@David Do I guess right you have only ever used JHS? If so, your question is perfectly understandable, and I have total sympathy. If I'm wrong, then what I'm going to say will look crashingly obvious.
Try using either jgtk701 or jcon701 to create and save a script instead of jhs701 and all your queries will go away. The fact is you can compose a script from scratch by hand using Notepad (or Textedit on the Mac). It is nothing but a TXT file (or more generally utf-8) which happens to have the extension IJS instead of TXT. The trick is to find the right directory (=folder) to put it in. Once found, you can make a shortcut on the desktop to the folder (or on the Mac: an alias), or else see it via http://127.0.0.1:65001/jfile . This isn't much different from how Javascript or Python does things. jhs701, jgtk701, jcon701 -all see and use the same folders of scripts. These in principle can be any folders you like, but in general is one of these two (type the expressions into J to see the full paths): jpath '~user' jpath '~temp' or it is a specially-created project folder. For your first fully handwritten script, just copy/paste random lines from the J session into Notepad, and save it in (jpath '~user') as 'myscript.ijs' Thus: smoutput ((10 <. p: i.10) = p: i.10) # p: i.10 as Björn suggested to you. Load it with: load '~user/myscript.ijs' and you will see the result: 2 3 5 7 You need the preceding 'smoutput' because 'load' suppresses incidental output ('loadd' doesn't). On Thu, Oct 13, 2011 at 12:16 PM, David Vaughan <[email protected]> wrote: > What I mean, is that I would like to be able to write some J in an external > file, and then run it from the browser window. I don't currently have a > specific purpose - I would just like to know for future reference. > > On 13 Oct 2011, at 12:11, Raul Miller wrote: > >> On Thu, Oct 13, 2011 at 6:46 AM, David Vaughan >> <[email protected]> wrote: >>> Hi, how do I go about writing a script? How does it differ from writing >>> your code in the browser? For example, say I wanted a script to test the >>> primality of i.10, how would it look? >> >> "script" is a potentially ambiguous term. >> >> One meaning of script is a multi-line definition in J: >> >> example=: 3 :0 >> smoutput 'this is a script' >> y >> ) >> >> If this is not what you want, please describe what you are trying to >> achieve and where it goes awry. >> >> Thanks, >> >> -- >> Raul >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
