/* This Genie fits text to the Y spacing of the grid. For instance, if your grid Y setting is 1.2 picas, all the text in an article will be spaced with lines 14 points apart. This is useful for tidying up parallel columns. You need only click on one box in each article: all the text in a box or linked chain will be changed.
If the grid spacing is large, you may get two or three lines of text in each grid unit.
In this version the bounding boxes of the letters are fitted to the grid; in a later version it may be possible to place the baselines on the grid.
Written by Don Cox Aug 92 Copyright but freely usable for non-commercial purposes */
trace n
signal on error
signal on syntax
address command
call SafeEndEdit.rexx()
call ppm_AutoUpdate(0)
cr="0a"x
cpage = ppm_CurrentPage()
counter=0
do forever
box=ppm_ClickOnBox(" Click on boxes containing text to be respaced")
if box=0 then break
counter=counter+1
boxes.counter=box
call ppm_SelectBox(box)
end
if counter=0 then exit_msg("No boxes selected")
currentunits=ppm_GetUnits()
call ppm_SetUnits(2)
randval = (randu() * time(s)) % 1 /* mark boxes with random number to avoid doing them twice */
gridsize = ppm_GetGridSize()
spacing = word(gridsize,2) /* we only want the Y value */
call ppm_ShowStatus(" Respacing text...")
do i=1 to counter
box=boxes.i
boxtype = upper(word(ppm_GetBoxInfo(box), 1))
if boxtype~="TEXT" then iterate
oldbox = box
box = ppm_ArtFirstBox(box)
boxone = box
do forever /* Tops of boxes to grid */
Ypos = word(ppm_GetBoxPosition(box),2)
Xpos = word(ppm_GetBoxPosition(box),1)
oddbit = Ypos//spacing
if oddbit<= spacing/2 then call ppm_SetBoxPosition(box,Xpos, Ypos-oddbit)