Multi-line comments in survex?

MarkS

Moderator
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.
 

MarkS

Moderator
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:
 

alastairgott

Well-known member
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"
;;;;;;)oes 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;;;;;;;
 

MarkS

Moderator
Thanks for checking, Alastair. Somewhat surprisingly, it looks like the answer to the original query is no.
 

alastairgott

Well-known member
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?)
 

MarkS

Moderator
alastairgott said:
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.
 

Benfool

Member
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
 

Mike Hopley

New member
MarkS said:
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.
 

andrewmcleod

Well-known member
Mike Hopley said:
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
 

Mike Hopley

New member
andrewmc said:
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.
 

alastairgott

Well-known member
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
 

alastairgott

Well-known member
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
static void

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

Steve Clark

Well-known member
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.
 

alastairgott

Well-known member
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
 
Top