Author Topic: Multi-line comments in survex?  (Read 609 times)

Offline MarkS

  • Global Moderator
  • forum star
  • *****
  • Posts: 697
  • BBPC, YCC
Multi-line comments in survex?
« on: November 26, 2019, 12:10:56 pm »
I know that a semicolon acts as a comment flag for anything following it on that line in a survex file, but is there any mechanism to comment out multiple lines without adding a semicolon at the start of every line?

I have had a look in the manual and searched on here and can't seem to find anything, but it seems to be quite a basic function not to be present.

Offline alastairgott

  • forum hero
  • *****
  • Posts: 1661
  • It's Therion Month.
Re: Multi-line comments in survex?
« Reply #1 on: November 26, 2019, 12:45:20 pm »
Someone suggested to me to use Kate text editor, I think it’s possible to edit a specific column of text. And also it numbers the line of text so if your application complains about a specific line of text, you can find it easily.

https://kate-editor.org/


Edit:Ah yes [size=78%]https://kate-editor.org/2013/09/09/multi-line-text-editing-in-kate/[/size]
Scraps and Maps, Scraps and Maps, Squawk, pretty polly...

Offline MarkS

  • Global Moderator
  • forum star
  • *****
  • Posts: 697
  • BBPC, YCC
Re: Multi-line comments in survex?
« Reply #2 on: November 26, 2019, 01:04:38 pm »
Thank you for the suggestion. I do use Kate and am aware of its functionality.

Do you have an answer to the question though?  :tease:

Offline alastairgott

  • forum hero
  • *****
  • Posts: 1661
  • It's Therion Month.
Re: Multi-line comments in survex?
« Reply #3 on: November 26, 2019, 04:49:47 pm »
Looks like it could be *ref<“string”>

https://survex.com/docs/manual/datafile.htm


Page in alphabetical order of function.


Edit: A shame if it is usable but not in any of the examples where they seem to prefer using the ;
Scraps and Maps, Scraps and Maps, Squawk, pretty polly...

Offline alastairgott

  • forum hero
  • *****
  • Posts: 1661
  • It's Therion Month.
Re: Multi-line comments in survex?
« Reply #4 on: November 27, 2019, 08:46:58 am »
I have had a play with this, could not initially get it to work, but have now got it working. My problem was that I had pressed the return key between two lines. If you keep typing it as if it's all on one line, then it works.

eg.
*ref "413155   382825   390 THESE ARE THE ENT CO ORDINATES FROM HITCH N HIKE PETE WARDS[return for new line]
 ENTRANCE HEIGHT IS 404M AND APPEARS TO BE TOO HIGH IN AV"
;;;;;;Does not work;;;;;;;

*ref "413155   382825   390 THESE ARE THE ENT CO ORDINATES FROM HITCH N HIKE PETE WARDS ENTRANCE HEIGHT IS 404M AND APPEARS TO BE TOO HIGH IN AV"
;;;;;;works perfectly;;;;;;;
Scraps and Maps, Scraps and Maps, Squawk, pretty polly...

Offline MarkS

  • Global Moderator
  • forum star
  • *****
  • Posts: 697
  • BBPC, YCC
Re: Multi-line comments in survex?
« Reply #5 on: November 27, 2019, 08:52:59 am »
Thanks for checking, Alastair. Somewhat surprisingly, it looks like the answer to the original query is no.

Offline alastairgott

  • forum hero
  • *****
  • Posts: 1661
  • It's Therion Month.
Re: Multi-line comments in survex?
« Reply #6 on: November 27, 2019, 09:04:56 am »
You must be trying to comment redundant survey data then?

You'll already know this (i'm sure), but you could separate the ones you want to remove into a separate .svx file then bring them all together in a higher .svx file? (removing the data you don't want?)
Scraps and Maps, Scraps and Maps, Squawk, pretty polly...

Offline MarkS

  • Global Moderator
  • forum star
  • *****
  • Posts: 697
  • BBPC, YCC
Re: Multi-line comments in survex?
« Reply #7 on: November 27, 2019, 10:05:05 am »
You must be trying to comment redundant survey data then?

Yes, kind of. It just seems a bit clumsy either having to add comment symbols on every line or splitting files etc. when I'm used to using multi-line comments for similar situations in other contexts! There are plenty of workarounds, but I wondered if I had missed anything.

Offline Benfool

  • obsessive maniac
  • ***
  • Posts: 427
Re: Multi-line comments in survex?
« Reply #8 on: November 27, 2019, 10:19:24 am »
Survex is open source, so I suspect it wouldn't be too difficult to modify it to accept multi line comments.

Something like ;*this is a comment*; as you do in C/C++

B

Offline Mike Hopley

  • obsessive maniac
  • ***
  • Posts: 447
Re: Multi-line comments in survex?
« Reply #9 on: November 27, 2019, 10:58:49 am »
It just seems a bit clumsy either having to add comment symbols on every line or splitting files etc. when I'm used to using multi-line comments for similar situations in other contexts!

A decent code editor (e.g. Sublime Text) removes the issue. You can select a bunch of lines and comment/uncomment them with a keypress.

This does require the editor to "recognise" the language though, and Survex is pretty obscure code. You could always write your own syntax plugin...!

I use PHP and javascript quite a lot. They both have multi-line comments, but I only use single-line comments. I find them more convenient. HTML is the annoying one, as it only has multi-line comments.

Offline andrewmc

  • junky
  • ****
  • Posts: 784
  • EUSS, BEC, YSS, prov. SWCC...
Re: Multi-line comments in survex?
« Reply #10 on: November 27, 2019, 01:06:49 pm »
A decent code editor (e.g. Sublime Text) removes the issue. You can select a bunch of lines and comment/uncomment them with a keypress.

As already mentioned, you can do this in Kate via block editing. Press ctrl-shift-b to move into block editing mode (I think; same to get back to normal mode). Drag down a zero-width column along the left hand edge of each line you wish to comment and press the semicolon key (once) to add a semicolon on every row at once position (commenting all the lines with a single keystroke). Select all the semicolons and press delete/backspace to uncomment. Block mode is crazy though :p

Offline Mike Hopley

  • obsessive maniac
  • ***
  • Posts: 447
Re: Multi-line comments in survex?
« Reply #11 on: November 27, 2019, 01:22:16 pm »
As already mentioned, you can do this in Kate via block editing.

Yes, that works too, and the same feature is available in Sublime and other editors. The Sublime version is particularly slick.

It's a lot faster to use the dedicated shortcut though. It doesn't require precise selection -- any part of a line will do, and empty lines are ignored. And it automatically adds/removes the comment characters and a space.

...but naturally that only works if you have syntax integration.

Offline alastairgott

  • forum hero
  • *****
  • Posts: 1661
  • It's Therion Month.
Re: Multi-line comments in survex?
« Reply #12 on: November 27, 2019, 01:34:19 pm »
There is the Set function.

You could use:
*set EOL markpimms
to be your end of line code rather than the standard return <EOL (x0Ax0D)>

but then I think you would have to put markpimms on every line you want to include.

As Benfool says it's in C/C+ so if you have an experience you could suggest an upgrade for Olly Betts.

The C code used to define the variables is as follows:

   t['\t'] |= SPECIAL_BLANK;
   t[' '] |= SPECIAL_BLANK;
   t[','] |= SPECIAL_BLANK;
   t[';'] |= SPECIAL_COMMENT;
   t['\032'] |= SPECIAL_EOL; /* Ctrl-Z, so olde DOS text files are handled ok */
   t[EOF] |= SPECIAL_EOL;
   t['\n'] |= SPECIAL_EOL;
   t['\r'] |= SPECIAL_EOL;
   t['*'] |= SPECIAL_KEYWORD;
   t['-'] |= SPECIAL_OMIT;
   t['\\'] |= SPECIAL_ROOT;
   t['.'] |= SPECIAL_SEPARATOR;
   t['_'] |= SPECIAL_NAMES;
   t['-'] |= SPECIAL_NAMES; /* Added in 0.97 prerelease 4 */
   t['.'] |= SPECIAL_DECIMAL;
   t['-'] |= SPECIAL_MINUS;
   t['+'] |= SPECIAL_PLUS;
#if 0 /* FIXME */
   t['{'] |= SPECIAL_OPEN;
   t['}'] |= SPECIAL_CLOSE;
#endif

https://trac.survex.com/
Feature requests can be made https://trac.survex.com/newticket

the above commands can be found here:
https://github.com/ojwb/survex/blob/master/src/commands.c
Scraps and Maps, Scraps and Maps, Squawk, pretty polly...

Offline alastairgott

  • forum hero
  • *****
  • Posts: 1661
  • It's Therion Month.
Re: Multi-line comments in survex?
« Reply #13 on: November 27, 2019, 02:55:52 pm »
Perhaps the *ref command could be expanded (and called *refmulti) to include an if statement to Ignore end of lines until the end of the *ref command. maybe adding a new *endref command?

From my lack of knowledge I think it would be a change to the read_string command http://eclipseclp.org/doc/bips/kernel/iochar/read_string-5.html
by changing the SepChars to "*endref"

but in the code Olly seems to use just two variables in his read string, which seems to count (_len) until the end of the line
read_string(&ref, &ref_len);



https://github.com/ojwb/survex/blob/master/src/commands.c
Quote
static void

cmd_ref(void)
{
   /* Just syntax check for now. */
   char *ref = NULL;
   int ref_len;
   read_string(&ref, &ref_len);
   s_free(&ref);
}

Scraps and Maps, Scraps and Maps, Squawk, pretty polly...

Offline Steve Clark

  • Newbie
  • *
  • Posts: 4
Re: Multi-line comments in survex?
« Reply #14 on: November 28, 2019, 02:02:50 pm »
Therion uses # instead of ; but also has 'comment' .... 'endcomment' tags to comment out a whole block of text. You can then #comment .... #endcomment to turn it on and off really quickly.

Would be a nice, and presumably simple, addition to survex on a future update.

Offline alastairgott

  • forum hero
  • *****
  • Posts: 1661
  • It's Therion Month.
Re: Multi-line comments in survex?
« Reply #15 on: November 30, 2019, 02:52:30 pm »
some back and forth separately and I've been informed that flagging stations is "on the list".

"The list" being about 3 pages long! https://survex.com/todo.html

'legs: "commented out" flag? syntax check data but otherwise ignore'
Flags are commonly used, so it may be an option but would require someone to code it.
http://cave-registry.org.uk/svn/NorthernEngland/FountainsFell/survexdata/HammerPot/hammerlastpitch.svx

We've tried the *set EOL as well but that doesn't work for either of us.

https://trac.survex.com/ticket/114
Scraps and Maps, Scraps and Maps, Squawk, pretty polly...