What's wrong with this macro. It only performs the operation on the first line.
#include "slick.sh"
_command format_HTML() name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_MDI_EDITORCTL)
{
_macro('R',1);
top_of_buffer()
while ( !down() ) {
begin_line()
last_event(name2event('<'));html_lt();
keyin("p");
last_event(name2event('>'));html_gt();
last_event(name2event(' '));html_space();
end_line();
last_event(name2event(' '));html_space();
last_event(name2event('<'));html_lt();
keyin('/');
keyin("p");
last_event(name2event('>'));html_gt();
}
}
This code is to format regular text into HTML paragraphs, however it only works on the first line.
What's wrong with this macro. It only performs the operation on the first line.
#include "slick.sh"
_command format_HTML() name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_MDI_EDITORCTL)
{
_macro('R',1);
top_of_buffer()
while ( !down() ) {
begin_line()
last_event(name2event('<'));html_lt();
keyin("p");
last_event(name2event('>'));html_gt();
last_event(name2event(' '));html_space();
end_line();
last_event(name2event(' '));html_space();
last_event(name2event('<'));html_lt();
keyin('/');
keyin("p");
last_event(name2event('>'));html_gt();
}
}
This code is to format regular text into HTML paragraphs, however it only works on the first line.
The issue with your macro is that the while (!down())
loop condition will exit after the first line because down()
returns 0 when it successfully moves to the next line (and your loop continues while !down()
is true, i.e., while moving down fails).
#include "slick.sh"
_command void format_HTML() name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_MDI_EDITORCTL)
{
_macro('R',1);
top_of_buffer();
while (1) {
begin_line();
last_event(name2event('<')); html_lt();
keyin("p");
last_event(name2event('>')); html_gt();
last_event(name2event(' ')); html_space();
// Move to end of line
end_line();
last_event(name2event(' ')); html_space();
last_event(name2event('<')); html_lt();
keyin('/');
keyin("p");
last_event(name2event('>')); html_gt();
// Try to move down
if (down()) break;
}
}