seSetLine()

Inserts a text in a specific line in the script editor. If a text already exists in this line, it will be replaced.

Synopsis

int seSetLine(int line, string text);

Parameters

Parameter Description
line The line number
text The text, which shall be inserted.

Return value

0, when the text was set successfully.

If an error occurs, -1 will be returned.

Description

Inserts a text in a specific line in the script editor. If a text already exists in this line, it will be replaced.

This function is an expansion to the script editor and cannot be used 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 the <proj_dir>/scripts/scriptEditor directory and have the extension "_ext.ctl". The Scripts can only be loaded and executed from this directory.

The entered line number doesn't correspond with the number in the script editor. This function starts to search for the specified line number at the position 0, which is shown as line 1 in the script editor. To enforce the consistency of 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, "InsertLi
  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, colum
  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