From owner-aurora-editor@sfu.ca Sat May 3 06:25:13 1997 Date: Sat, 3 May 1997 03:09:01 -0700 Message-Id: <199705031009.DAA07982@fat.doobie.com> To: aurora-editor@sfu.ca From: nobody@huge.cajones.com (Huge Cajones Remailer) Comments: Please report misuse of this automated remailing service to Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: =AML= Jump to Position (also re: Macro: opening files) For a previous macro I posted (involving file-opening), I forgot to delete one function call: maxfurther. I use that function to resize the window a certain way. So in case you tried to use that macro, you should just delete "maxfurther". Now, here's another external macro I've finally completed: {---BEGIN----------------------------------------------------} //-------------------------------------------------------------------- // NEWPOS.AML (this macro has been tested with Aurora v3.0c) // // Jumps to a relative or absolute row or column in the file. // Can handle percentages (floating-point numbers are allowed). // // Format of Input: row,col OR percentage // e.g., "100" = go to 100th row // ",560" = go to 560th column // "1,23" = go to first row, and 23rd column // "+1,-23" = go down 1 row, and move 23 columns to left // "1,+23" = go to 1st row, and move 23 columns to right // "15.34%" = go to the line which is 15.34% into the file // "100%" = go to the last line // "+10.6%" = move down by 10.6% of the file's length // "-5%" = move up by 5% of the file's length // // The 'newpos' function does the following error checks on the input: // Quit if a letter (or anything not related to a number) was entered. // If a percentage is input, then quit if a comma was also input. // If no percentage is input, then quit if a decimal point shows up. // // Usage: // Select this macro from the Macro List (on the Macro menu), or run it // from the macro picklist . //-------------------------------------------------------------------- // compile time macros and function definitions include bootpath "define.aml" // test for edit windows if not wintype? "edit" then msgbox "Edit windows only!" return end // make cursor position undo-able undocursor function newpos (coord) coord = sub ' ' '' coord // remove all spaces if posnot ',.%1234567890+-' coord then return elseif pos '%' coord then // go to a new line based on a percentage if pos ',' coord then return end coord = sub '%' '' coord // remove the percentage sign // This multiplies a percentage with the number of lines in a file. // It can handle percentages such as "34%", "50.2%", and "1.0045%". decplaces = if? (pos '.' coord) ((length coord) - (pos '.' coord)) 0 product = (getlines) * (sub '\\.|\\-|\\+' '' coord 'x') if (length product) > (decplaces + 2) then lastdigitpos = (length product) - decplaces - 2 percentage = (product [1: lastdigitpos]) + 1 else percentage = 1 end if percentage > getlines then percentage = getlines end case coord [1] when '+' down percentage when '-' up percentage otherwise row percentage end else // go to a new row or column if pos '.' coord then return end commapos = pos ',' coord if commapos then if coord [1] <> ',' then newrow = ( coord [1 : commapos - 1] ) else newrow = '' end newcol = coord [commapos + 1 : -1] case newcol [1] when '+' right newcol [2:-1] when '-' left newcol [2:-1] otherwise col newcol end else newrow = coord end if newrow then case newrow [1] when '+' down newrow [2:-1] when '-' up newrow [2:-1] otherwise row newrow end end end end askx "Jump to a position in file" '_newposhist' "newpos" // use 'onfound' (in Ext.aml) to adjust the window view if needed send "onfound" {---END------------------------------------------------------} Glenn -- HP200LX EO P=X MI -- 1997.05.03 0244.46 PST PGP 0xB7764059 777bits 1D 3C 6B F9 B2 47 2A 12 48 D7 18 56 17 7F 80 8C