This genie gives a name to all the boxes in the document. The box number is added to the end of the name. Existing names are not altered, except for having the number added.
Written by Don Cox July 92 */
trace n
signal on error
signal on syntax
call ppm_AutoUpdate(0)
cr = "0a"x
address command
call SafeEndEdit.rexx()
oldmode = ppm_GetColorMode()
call ppm_SetColorMode(0)
call ppm_ShowStatus(" Naming Boxes ...")
thispage = ppm_CurrentPage()
pages = ppm_NumPages()
do p = 1 to pages
newpage = ppm_GoToPage(p)
totalboxes = ppm_NumBoxes(newpage)
box = ppm_PageFirstBox()
do i = 1 to totalboxes
number = right(ppm_BoxNum(box),3,"0")
info = ppm_GetBoxInfo(box)
boxtype = word(info,1)
boxname = createboxname(box)
call ppm_SetBoxName(box, boxname)
box = ppm_PageNextBox(box)
end
end
call ppm_GoToPage(thispage)
exit_msg("Boxes now all named.")
error:
syntax:
do
exit_msg("Genie failed due to error: "errortext(rc))
end
exit_msg:
do
parse arg message
if message ~= "" then
call ppm_Inform(1,message)
call ppm_ClearStatus()
call ppm_SetColorMode(oldmode)
call ppm_AutoUpdate(1)
exit
end
createboxname: procedure
parse arg box
number = right(ppm_BoxNum(box),3,"0")
info = ppm_GetBoxInfo(box)
boxtype = word(info,1)
boxname = ppm_GetBoxName(box)
if upper(left(boxname,5))="EMPTY" then boxname = ""
numbered = 0
if boxname ~="" then do
endbit = right(boxname,5)
if verify(endbit,"()0123456789")=0 then numbered = 1
end
select
when upper(boxtype) = "TEXT" then do
boxtext = ppm_GetBoxText(box,0)
shorttext = substr(boxtext,1,16)
shorttext = '"'||shorttext||'"'
if boxname = "" then boxname = shorttext
end
when upper(boxtype) = "BITMAP" then do
filename = word(info,5)
endofpath = lastpos("/",filename)
if endofpath = 0 then endofpath = pos(":",filename)
filename = substr(filename, endofpath+1)
if boxname = "" then boxname = filename
end
when upper(boxtype) = "EPSF" then do
filename = word(info,3)
endofpath = lastpos("/",filename)
if endofpath = 0 then endofpath = pos(":",filename)
filename = substr(filename, endofpath+1)
if boxname = "" then boxname = filename
end
when upper(boxtype) = "CLIP" then do
objects = "Clip, "||word(info,2)||" objects"
if word(info,2)=1 then objects = "Clip, 1 object"
if boxname = "" then boxname = objects
end
when upper(boxtype) = "STRUCTURED" then do
objects = "Struct., "||word(info,2)||" objects"
if word(info,2)=1 then objects = "Struct., 1 object"
if boxname = "" then boxname = objects
end
when upper(boxtype) = "EMPTY" then do
if boxname = "" then boxname = "Empty"
end
otherwise boxname = "Unknown type of box"
end
if numbered = 0 then boxname = boxname||" ("number")"