I sometimes need this too. If so, and if you're JQt, it's easy to
select all the unwanted
lines and switch on comments with ctrl-/ . You can later uncomment all
those lines with
another ctrl-/ on the same selection.
However, that can be a bit awkward, and thanks to your message I've
just written
this fairly verbose and none-too elegant if not disgraceful function,
loadtomark, to do what
I often need, and which might fit your requirement.
The idea is to place one or more marker/s in your script, starting in
the first column. I've tried )))
but that raises an error if/when you load the whole script;
"NB. )))" would be ok, but you'd need to specify that exact string as
I've written it, ie with the NB. .
Alternatively, plant a number of markers, eg 0001, 0002 ... 1234
etc; the search string would be
whichever marker you wish to stop at. The load doesn't include the marker.
It can be tedious to type the script's name in full, but it's easy
enough to first do a load
of the whole script using ctrl-L, and capture the terminal message
load '....' ,
then copy and modify it in the terminal session to read
search-string loadtomark '....'
As I've only just written this in response to your enquiry, it's hardly
tested; no doubt some problems
will arise with experience! I'll embed it in my startup script, and try
to remember to use it when I
need to do a partial load.
NB. ====================================================================
NB. selective script load from y - up to but not including a left
justified marker in x
NB. not as convenient as ctrl-L etc, but needs minimal modification in
script
loadtomark =: 3 : 0
load y NB. nothing to look for - just load script as is
:
assert. fexist y
require'files'
NB. look for first string x at beginning of lines of script
mark=. x
q =. fread y
iq =. mark {.@:I.@E. q, mark
if. iq >: # q do. NB. mark not found, so load script as is
echo mark,' not found; loading script as is'
echo 'load ', y
load y
return.
end.
q =. iq {. q
NB. string found; create temporary script; should work!!!
while. fexist rsc =. '~user/temp/', '.ijs',~ a.{~ 97 + 26?26 do.
end.
try. NB. if something goes wrong, keeps the temporary script
q fwrite rsc
scr =. 'load''', rsc, ''''
echo scr NB. not very useful as temp script will be erased!
". scr
ferase rsc NB. should be ok unless script is extremely long
catch.
echo 'failed... scratch file = ',rsc
end.
)
NB. ==============================================================
Any use?
Mike
On 31/08/2021 13:27, 'Rudolf Sykora' via Programming wrote:
Dear list,
if I load a (longer) script, I sometimes want to ignore a part of it
beyond a certain line. Is there a way to achieve that gracefully? (I
sometimes just add something syntactically wrong to stop there, on an
error).
Thank you.
Ruda
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm