flyingboz Posted February 13, 2005 Share Posted February 13, 2005 Thought that this would be easy and as straightforward as LUA ever is, and am now frustrated at how much time I've wasted.... Hoping that one of our Scite/LUA experts can point me the right way.To get the currentline, one uses the editor.CurrentPos value, and converts it to a line number. CurrentLine = editor:LineFromPosition(editor.CurrentPos)However, when trying to find the other end of the selection, and determine start / end positions (user could drag from top to bottom or bottom to top), the following fails with the error: Pane function / readable property / indexed writable property name expectedAnchorLine = editor:LineFromPosition(editor.GetAnchor)From the docs....# Returns the position of the caret. get position GetCurrentPos=2008(,) # Returns the position of the opposite end of the selection to the caret. get position GetAnchor=2009(,) Reading the help file before you post... Not only will it make you look smarter, it will make you smarter. Link to comment Share on other sites More sharing options...
MHz Posted February 13, 2005 Share Posted February 13, 2005 # Returns the position of the caret. get position GetCurrentPos=2008(,) # Returns the position of the opposite end of the selection to the caret. get position GetAnchor=2009(,)These are functions, and need to be used as such. No parameters are shown (,), so none are needed.GetCurrentPos()GetAnchor() Link to comment Share on other sites More sharing options...
flyingboz Posted February 13, 2005 Author Share Posted February 13, 2005 (edited) CurrentLine = editor:LineFromPosition(editor.CurrentPos) This code exactly as written, returns the line number where the caret is. (if you try it in scite, it's actually 1 less than the display, 'coz scite line and row numbering begin are zed indexed. IT WORKS. Poking around, I found a reference on the web that the get/set functions were converted to properties of the editor class, such that they aren't functions at all any more. As the doc syntax is identical for both functions, I assumed that the syntax used to call them would be identical, as well. I have tried calling the line below AnchorLine = editor:LineFromPosition(editor.GetAnchor) AnchorLine = editor:LineFromPosition(editor.GetAnchor()) Both fail: error msg:Pane function / readable property / indexed writable property name expected. A lack of argument error looks like this: C:\Program Files\autoit3\scite\AutoIt3.lua:309: bad argument #1 to `LineFromPosition' (number expected, got no value) Edited February 13, 2005 by flyingboz Reading the help file before you post... Not only will it make you look smarter, it will make you smarter. Link to comment Share on other sites More sharing options...
MHz Posted February 13, 2005 Share Posted February 13, 2005 Looks to me, that you have retrieved the line from the caret position. But now, you want to know the end of the line. That would mean something other than editor:LineFromPosition(position pos,)? So, you want some kind of info? from the home position on the line to the end. So much to choose from. The iface.api file has the list also. Link to comment Share on other sites More sharing options...
Valik Posted February 13, 2005 Share Posted February 13, 2005 Getters/Setters have the Get/Set stripped from the name. It should be editor.Anchor. Link to comment Share on other sites More sharing options...
flyingboz Posted February 13, 2005 Author Share Posted February 13, 2005 (edited) It should be editor.Anchor.That did the trick. New LUA script available - Au3Trace only selected text.Thanks to Valik for his timely and accurate response, and many. many thanks to JdeB , the guru of Scite4Au3 ,and (I believe) the author of Au3Trace(), and a key agitator for the ConsoleWrite() functionality which makes life so much better. If I've left anyone out or got credit wrong, pls let me know, I'll update this post gladly to ensure proper credit. Edited February 13, 2005 by flyingboz Reading the help file before you post... Not only will it make you look smarter, it will make you smarter. Link to comment Share on other sites More sharing options...
Developers Jos Posted February 13, 2005 Developers Share Posted February 13, 2005 I have added your idea to the http://www.autoitscript.com/fileman/users/jdeb/test/autoit3.lua that i am currently working on for the FuncList.I solved it this way:function Au3Trace() editor:BeginUndoAction() local sels = editor.Selectionstart local sele = editor.Selectionend -- when nothing is selected then WHole script if sels==sele then sels = 0 sele = editor.Length end local FirstLine = editor:LineFromPosition(sels) local LastLine = editor:LineFromPosition(sele) local CurrentLine = FirstLine editor:GotoLine(FirstLine) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now