From owner-aurora-editor Thu Mar 20 20:27 PST 1997 Return-Path: Message-Id: <3.0.1.16.19970320232500.31b7571a@popd.ix.netcom.com> X-Sender: jawilson@popd.ix.netcom.com (Unverified) X-Mailer: Windows Eudora Light Version 3.0.1 (16) Date: Thu, 20 Mar 1997 23:25:00 To: aurora-editor@sfu.ca From: Jim Wilson Subject: autoexpd -- part 2 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Length: 4065 Status: O All; Okay, here's a new version of that AUTOEXPD macro I just posted two days ago. This one is just about a complete rewrite of the previous version for a number of reasons, not the least of which is that the other one had some quirks and it was kindofa kludge. So, with that thought in mind -- and armed with some code I swiped from Steven La (thanks Steven!) -- I rewrote this thing. Basically, it's a whole lot cleaner, works faster and fixes a bug or two. Life is good.. You should copy this version of AUTOEXPD over the top of the other one and then recompile it. As always, if you have any problems with this thing let me know. Regards, Jim Wilson (jawilson@ix.netcom.com) /* ------------------------------------------------------------------ */ /* Macro: AUTOEXPD.AML */ /* Written by: Jim Wilson */ /* */ /* Description: Macro used to automatically expand a partially */ /* typed word with the closest possible match from */ /* the text above the cursor. */ /* */ /* Usage: Assign it to key in kbd.aml. */ /* */ /* */ /* Version: 1.0 -- 1/97 */ /* Initial version. */ /* */ /* 1.1 -- 3/97 */ /* Streamlined code for efficiency. */ /* */ /* Fixed a bug that caused the search to match */ /* anywhere in a previous word, as opposed to */ /* just the begining of the word. */ /* */ /* ------------------------------------------------------------------ */ include bootpath 'define.aml' if not wintype? "edit" then // bail out if not an edit window msgbox 'Edit windows only' 'Error' 'b' return end pushcursor // save orig cursor pos left // move cursor back onto word SearchWord = send "getword" _CSet // get the chars that were typed Size = length SearchWord // save size of search string if Size == 0 // bail out if no word found popcursor say 'No valid word to search for' 'b' return end left (Size - 1) // move cursor off of search string repeat if (Found = find SearchWord 'r') then // if a match is found FoundWord = (getword) // grab the word if (SearchWord [1..Size]) == (FoundWord [1..Size]) then // see if it matches Done = TRUE // if so, we're done end end until Found == '' or Done if Found <> 0 then // if something was found... popcursor // go back to orig cursor pos left // reposition cursor markword // mark partial word typed previously deleteblock2 // delete it write FoundWord // replace it with the full word else // if nothing was found... popcursor // move cursor back to orig spot say 'Unable to match "' + SearchWord + '"' 'b' // display message end