home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d7xx / d724 / donsgenies.lha / DonsGenies / DonsGenies.lha / Don'sGenies / BoxesNameAll.pprx < prev    next >
Text File  |  1992-08-05  |  3KB  |  109 lines

  1. /* Boxes Name All
  2. 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.
  3. Written by Don Cox    July 92  */
  4.  
  5. trace n
  6.  
  7. signal on error
  8. signal on syntax
  9. call ppm_AutoUpdate(0)
  10. cr = "0a"x
  11.  
  12. address command
  13. call SafeEndEdit.rexx()
  14. oldmode = ppm_GetColorMode()
  15. call ppm_SetColorMode(0)
  16.  
  17. call ppm_ShowStatus("   Naming Boxes ...")
  18. thispage = ppm_CurrentPage()
  19. pages = ppm_NumPages()
  20. do p = 1 to pages
  21.     newpage = ppm_GoToPage(p)
  22.  
  23.     totalboxes = ppm_NumBoxes(newpage)
  24.     box = ppm_PageFirstBox()
  25.     do i = 1 to totalboxes
  26.         number = right(ppm_BoxNum(box),3,"0") 
  27.         info = ppm_GetBoxInfo(box)
  28.         boxtype = word(info,1)
  29.         boxname = createboxname(box)
  30.         call ppm_SetBoxName(box, boxname)
  31.         box = ppm_PageNextBox(box)
  32.         end
  33. end
  34. call ppm_GoToPage(thispage)
  35. exit_msg("Boxes now all named.")
  36.  
  37. error:
  38. syntax:
  39.     do
  40.     exit_msg("Genie failed due to error: "errortext(rc))
  41.     end
  42.  
  43. exit_msg:
  44.     do
  45.     parse arg message
  46.     if message ~= "" then
  47.     call ppm_Inform(1,message)
  48.     call ppm_ClearStatus()
  49.     call ppm_SetColorMode(oldmode)
  50.     call ppm_AutoUpdate(1)
  51.     exit
  52.     end
  53.  
  54.  
  55. createboxname: procedure
  56. parse arg box
  57. number = right(ppm_BoxNum(box),3,"0") 
  58. info = ppm_GetBoxInfo(box)
  59. boxtype = word(info,1)
  60. boxname = ppm_GetBoxName(box)
  61.  
  62. if upper(left(boxname,5))="EMPTY" then boxname = ""
  63. numbered = 0
  64. if boxname ~="" then do
  65.     endbit = right(boxname,5)
  66.     if verify(endbit,"()0123456789")=0 then numbered = 1
  67.     end
  68.  
  69. select
  70.     when upper(boxtype) = "TEXT" then do
  71.         boxtext = ppm_GetBoxText(box,0)
  72.         shorttext = substr(boxtext,1,16)
  73.         shorttext = '"'||shorttext||'"'
  74.         if boxname = "" then boxname = shorttext
  75.         end
  76.     when upper(boxtype) = "BITMAP" then do
  77.         filename = word(info,5)
  78.         endofpath = lastpos("/",filename)
  79.         if endofpath = 0 then endofpath = pos(":",filename)
  80.         filename = substr(filename, endofpath+1)
  81.         if boxname = "" then boxname = filename
  82.         end
  83.     when upper(boxtype) = "EPSF" then do
  84.         filename = word(info,3)
  85.         endofpath = lastpos("/",filename)
  86.         if endofpath = 0 then endofpath = pos(":",filename)
  87.         filename = substr(filename, endofpath+1)
  88.         if boxname = "" then boxname = filename
  89.         end
  90.     when upper(boxtype) = "CLIP" then do
  91.         objects = "Clip, "||word(info,2)||" objects"
  92.         if word(info,2)=1 then objects = "Clip, 1 object"
  93.         if boxname = "" then boxname = objects
  94.         end
  95.     when upper(boxtype) = "STRUCTURED" then do
  96.         objects = "Struct., "||word(info,2)||" objects"
  97.         if word(info,2)=1 then objects = "Struct., 1 object"
  98.         if boxname = "" then boxname = objects
  99.         end
  100.     when upper(boxtype) = "EMPTY" then do
  101.         if boxname = "" then boxname = "Empty"
  102.         end
  103.     otherwise boxname = "Unknown type of box"
  104. end
  105.  
  106. if numbered = 0 then boxname = boxname||" ("number")"
  107.  
  108. return boxname
  109.