name stars; -- insert a rectangle of stars Property CurrentFile = 0; -- shared global variable Property CurrentSel = 0; sub CheckFileOpen flag = false; file = qedit.activefile; -- we need an object to insert into if typeof(file)=qedit.typeundefined result=dialog("You must have a file open"); else CurrentFile = file; -- update shared Global variable flag = true; endif return flag; endsub sub CheckSelection flag = false; if CheckFileOpen() s = CurrentFile.selection; r=dialog(string(s)); if length(s) = 1 then -- Oops, only a caret is active r = dialog("You must have an active selection to fill."); else CurrentSel = s; flag = true; endif endif return flag; endsub if CheckSelection() then startsel = CurrentSel.start; r=dialog(string(startsel)); startl = startsel.line; startc = startsel.column; endsel = CurrentSel.end; -- unknown property if no selection r=dialog(string(endsel)); endl = endsel.line; endc = endsel.column; if length(CurrentSel) = 2 then --- oops, not rectangular r = dialog("STARS only works on rectangles. Use Control-Drag."); stop; endif; width= endc - startc + 1; stars = ""; repeat for x from 1 to width by 1 stars = stars + "*"; endrepeat r =dialog(stars + " for width="+string(width)); r=CurrentFile.insertcolumn(startline: startl, endline: endl, atcolumn: startc, text: stars); -- Cancel selection, Position caret at upper left corner: CurrentFile.select(startline: startl, startcolumn: startc); endif << Author: bgreen@robelle.com Date: Sept 14, 1999 Web: insert05.qsl Comments: 1. You will run this script from the Script Menu. 2. Save insert05 as a local file, stars.qsl anywhere on c:\ drive. 3. Go to Script-ManageScripts dialog. 4. If 'stars' is already there, click and Remove it. 5. Click Add and browse to stars.qsl file and select it. 6. Click Done to finish ManageScripts dialog. 7. Open any file with some text in it. 8. Create a rectangular selection using Control and mouse-drag. 9. Select Script-Stars to insert a box of stars of that size. 10. The dialog() calls are to show you what a selection object looks like when converted to a string. You can comment them out with -- before using this script in production. 11. Please note that 'if CheckFileOpen() and CheckSelection()' would call BOTH subroutines. Therefore, it is better to call CheckSelection() and let it call CheckFileOpen(). QWIN does not optimize IF execution to minimize sub calls. >>