Notifications
Clear all

[Closed] Fast search through text file

Few minutes ago I wrote a script which, after I select the line number in Maxscript listener(where the error occur) will go to the line in the currently opened script.

local g = (dotNetClass "Autodesk.Max.GlobalInterface").Instance
	local mxse = g.TheMxsEditorInterface
	local editorHandle = mxse.EditorGetMainHWND
	local currentlyOpenTab = mxse.EditorGetEditHWND
	local SCI_GOTOLINE = 2024
	local SCI_GETLINEENDPOSITION = 2136
	local SCI_SETSEL = 2160
	local SCI_POSITIONFROMLINE = 2167
	local windowsSendMessage = windows.SendMessage
	
	
	if (selText = (getListenerSelText())) != "" do
	(
		_lineIdx = selText as integer
		windowsSendMessage currentlyOpenTab SCI_GOTOLINE _lineIdx 0
		
		nStart = SendCommandToScintilla SCI_POSITIONFROMLINE (_lineIdx - 1) 0
		nEnd = SendCommandToScintilla SCI_GETLINEENDPOSITION (_lineIdx - 1) 0
		windowsSendMessage currentlyOpenTab SCI_SETSEL nStart nEnd
	)

Still can’t run it while the Maxscript listener is in focus, but clicking in the viewport and executing the script does the job.

I am doing something wrong, but I can’t figure out what.
Here is part of the code:


string re_with = (\"with\\\\\");
			
			var spaces = new char[]{' ','	'};
			
			using (System.IO.StringReader sr = new System.IO.StringReader(doc))
			{
				string line;
				int line_index = 0;
				string word;
				while ((line = sr.ReadLine()) != null)
				{
					line_index++;
					
					word = line.TrimStart(spaces);
					int len  = word.IndexOfAny( spaces );
					word = word.Substring( 0, len < 0 ? word.Length : len ).ToLower();
					
					if ( re_with == word )
					{
						_defWithArr.Add(line);
						_defWithLineNumArr.Add(line_index);
					}

The if statement is always false. When I collect all word there is “with” inside the collection, but all If statements are always false.

Update

Fixed. It has to be string re_with = (\"with\");

… nevermind

Page 10 / 10