home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of A1200
/
World_Of_A1200.iso
/
programs
/
text
/
textra
/
scripts
/
singlespace.textra
< prev
next >
Wrap
Text File
|
1995-02-27
|
3KB
|
131 lines
/*******************************************************************
* TEXTRA AREXX script -- Mike Haas, 1991, All Rights Reserved. *
* Freely distributable ONLY as a component of the TEXTRA package. *
* This banner may not be removed or altered (improvements to the *
* actual program welcome). Please document and send to me. *
*******************************************************************/
/* Usage: SingleSpace
*
* This script deletes any blank lines between each text-bearing line
* in the select range. No parameters are required.
*
*/
/* 00001 mdh 10-nov-92 Added ability to cancel script */
/* 00002 mdh 20-nov-92 check version (cause of 'CheckCancel') */
OPTIONS results
rex = 0; result = "NOTSUPPORTED" /*00002*/
textraversion
parse var result maj min rex
if (result == "NOTSUPPORTED") | (rex < 3) then do
notify "Textra V1.13 or later required for this script."
exit
end
/* temporarily make sure auto indent is off */
prefs autoindent read; autoistate = result
prefs autoindent off
get select position /* get the select boundary, if any */
if (result == "NO SELECT") then /* is nothing selected? */
do
get cursor position /* nothing selected, get cursor pos */
parse var result cursx ' ' cursy
LinesSelected = 0 /* means 'just cursor' */
end
else
do
/* yes, there is a selection, get it's boundaries */
parse var result startx ' ' starty ' ' endx ' ' endy
LinesSelected = (endy - starty)
/* if only the 'eol' of the previous line is selected
(nothing on this line is actually included, i.e. x==0),
then don't include it.
*/
if (endx > 0) then LinesSelected = LinesSelected + 1
end
if (LinesSelected == 0) then
do
currline = cursy
call CheckDoCurrLine
if (DoCurrLine == 1) then
do
selectline cursy+1
del
end
end
else
do
currline = starty; numLeft = LinesSelected
do while (numLeft > 0)
CheckCancel; if (result == CANCEL) then exit /*00001*/
do
call CheckDoCurrLine
if (DoCurrLine == 1) then
do
selectline currline+1
del
/*numLeft = numLeft - 1*/
end
else
currline = currline + 1
numLeft = numLeft - 1
end
end
/* gotoxy 0 starty
selectto 0 starty+LinesSelected */
gotoxy 0 currline
end
/* restore autoindent */
prefs autoindent autoistate
exit
CheckDoCurrLine:
ThisLine = currline + 1
call CheckThisLine
lineplusone = DoCurrLine
ThisLine = currline
call CheckThisLine
if ((DoCurrLine == 1) & (lineplusone == 0)) then
DoCurrLine = 1
else
DoCurrLine = 0
return
CheckThisLine: /*DoCurrLine set to 1 if non-white there*/
DoCurrLine = 0
gotoxy 0 ThisLine
get cursor char
do while (result ~= -1)
do
if ((result ~= ' ') & (result ~= ' ')) /*TAB*/ then
do
DoCurrLine = 1
leave
end
right 1
get cursor char
end
end
return