I can offer 3 solutions. The first one is a macro which I quickly recorded and then modified a little (IfColNum block inserted).
- Code: Select all
InsertMode
ColumnModeOff
HexOff
UltraEditReOn
Clipboard 9
SelectAll
Copy
NewFile
Paste
IfColNum 1
Key BACKSPACE
EndIf
Top
ColumnModeOn
ColumnInsert "#"
Top
ColumnInsertNum 0 1 LeadingZero
ColumnModeOff
Bottom
InsertLine
Top
Find RegExp "%^([0-9 ]+^)#^(*^)$"
Replace All "oSeminarDe[^1] = "^2";"
ClearClipboard
Clipboard 0
The LeadingZero parameter is optional. You could remove it if the array index should be with spaces between number and closing square bracket
]. This macro could be also coded as script. It uses column mode editing feature and a
tagged regular expression replace.
A similar macro without tagged regular expression.
- Code: Select all
InsertMode
ColumnModeOff
HexOff
UltraEditReOn
Clipboard 9
SelectAll
Copy
NewFile
Paste
IfColNum 1
Key BACKSPACE
EndIf
Top
ColumnModeOn
ColumnInsert "oSeminarDe[] = ""
Key Ctrl+RIGHT ARROW
Key RIGHT ARROW
ColumnInsertNum 0 1 LeadingZero
ColumnModeOff
Bottom
InsertLine
Top
Find RegExp "$"
Replace All "";"
ClearClipboard
Clipboard 0
The third solution is a script based on what you thought about, but optimized to do as much as possible (= everything) in RAM. No leading zeros or trailing spaces applied for aligning the array index numbers, although that would be also possible with some extra code.
- Code: Select all
UltraEdit.activeDocument.selectAll();
var sEntireText = UltraEdit.activeDocument.selection;
UltraEdit.activeDocument.top();
var asLines = sEntireText.split("\r\n");
if (asLines[asLines.length-1] == "") asLines.pop();
var sArrays = "";
for (var nIndex = 0; nIndex < asLines.length; nIndex++) {
sArrays += "oSeminarDe[" + nIndex.toString() + "] = \"" + asLines[nIndex] + "\";\r\n";
}
UltraEdit.newFile();
UltraEdit.activeDocument.write(sArrays);
UltraEdit.activeDocument.top();
The script is written for DOS terminated lines.