seInsertLine()

Inserts a new line with the corresponding line number and a specific text into the script editor.

Synopsis

int seInsertLine(int line, string text);

Parameters

Parameter Description
line Line number of the new line.
text The text, which shall be inserted into the new line.

Return value

0, when the line could be inserted.

If an error occurs, -1 will be returned.

Description

Inserts a new line with the corresponding line number and a specific text into the script editor. If a text already exists in the new line, so it will be moved into the next line. Thus all text lines move one position downwards.

This function allows to expand the script editor and it is not allowed to use it in another context. To retrieve the script from the Editor, use the existing function getScript() and to set it back, use the existing function setScript(). The extension scripts have to be located in <proj_dir>/scripts/scriptEditor directory and an saved with the extension "_ext.ctl". From there only they can be loaded and executed.

The entered line number doesn't agree with the number in the script editor. This function starts to search for the specified line number at the position 0, which is shown in the script editor as line 1. To enforce the agreement of the both line numbers, the parameter line has to be decremented by one.

Example

In the following example a new menu will be added to the script editor. The menu contains actions, which retrieve and execute the se* functions. That means that the functions can retrieved via the script editor menu.

Figure: Result -> "MyTools" menu with executable se* functions

main()
{
  int id = moduleAddMenu("MyTools");
  int tb = moduleAddToolBar("toolbar1");
  DebugN(id, tb);
  int id1 = moduleAddAction("Return Cursor Position", "", "", id,
  tb, "GetCursorPosition");
  int id2 = moduleAddAction("Set Cursor Position [3,3]", "", "",
  id, tb, "SetCursorPosition");
  int id3 = moduleAddAction("Replace Line by 'Line removed'", "",
  "", id, tb, "SetLine");
  int id4 = moduleAddAction("Read Content", "", "", id, tb,
  "GetLine");
  int id5 = moduleAddAction("Insert Line with Text", "", "", id,
  tb, "InsertLine");
  int id6 = moduleAddAction("Remove Cursor Position Line ", "",
  "", id, tb, "RemoveLine");
}
void GetCursorPosition()
{
  int line;
  int column;
  seGetCursorPos(line, column);
  DebugN(line, column);
}
void SetCursorPosition()
{
  int line = 3;
  int column = 3;
  seSetCursorPos(line - 1, column - 1);
  DebugN("Cursor position set:", line, column);
}
void SetLine()
{
  int line;
  int column;
  seGetCursorPos(line, column);
  seSetLine(line, "Line removed");
  DebugN("Line replaced:", line, column);
}
void GetLine()
{
  int line;
  int column;
  seGetCursorPos(line, column);
  DebugN(line, column);
  DebugN("Line content: ", seGetLine(line));
}
void InsertLine()
{
  int line;
  int column;
  string text = "New line with text";
  seGetCursorPos(line, column);
  seInsertLine(line, text);
  DebugN(line, column);
  DebugN("Text in line ", line, " added: ", text);
}
void RemoveLine()
{
  int line;
  int column;
  seGetCursorPos(line, column);
  DebugN(line, column);
  seRemoveLine(line);
  DebugN("Removed line with the line number:", line);
}

Assignment

Script Editor Extensions

Availability

UI