home *** CD-ROM | disk | FTP | other *** search
- /*
- @BAutoImport @P@ICopyright Gold Disk Inc. Jan, 1993
-
- This Genie will import text into a page and create as many copies of the current page as necessary to fit the text.
- */
-
- call SafeEndEdit.rexx()
- call ppm_AutoUpdate(0)
- address command
-
- currentpage = ppm_CurrentPage()
-
- if currentpage ~= 0 then
- do
- /*
- * Page exists, select box
- */
- filename = ppm_GetFileName("Open Text File:", "", "")
- if filename = '' then call exit_msg()
- box = ppm_ClickOnBox("Click on box in which to import text")
- end
- else
- do
- /*
- * No page exists, make from default
- */
- filename = ppm_GetFileName("Open Text File:", "", "")
- if filename = '' then call exit_msg()
- currentpage = ppm_CreatePage(1,1,1,1,0)
- box = ppm_PageFirstBox(currentpage)
- if box = '' then call exit_msg("No box on default page, cannot import text.")
- end
-
- if box = 0 then exit
- info = ppm_GetBoxInfo(box)
- fword = upper(word(info, 1))
- lword = word(info, words(info))
-
- if fword ~= "EMPTY" & lword ~= "0" then exit_msg("You must select an empty text box to use this Genie")
- if word(info, 3) = 1 | word(info, 1) = word(info, 3) then leave
-
- prevbox = box
- outbox = 0
-
- do forever
- prevbox = ppm_ArtNextBox(prevbox)
- if prevbox = 0 | ppm_BoxPage(prevbox) ~= currentpage then leave
- outbox = prevbox
- end
-
- /*
- * Box must be empty
- */
- if ~ ppm_ImportText( box, filename ) then
- call exit_msg("Could not import "filename)
-
- todo = ppm_TextOverFlow( box )
-
- if ~todo then exit_msg("Done")
- boxoff = boxoffset(box, currentpage)
- if outbox = 0 then
- do
- outbox = box
- outboxoff = boxoff
- end
- else
- outboxoff = boxoffset(outbox, currentpage)
-
- do while todo
- call ppm_CopyPage(currentpage, currentpage, 1)
- call ppm_MovePage(currentpage, currentpage + 1)
- currentpage = currentpage + 1
- box = ppm_PageFirstBox(currentpage)
- fbox = box
- do boxoff
- box = ppm_PageNextBox(box)
- end
- call ppm_DeleteContents(box)
- call ppm_LinkBox(outbox, box)
- outbox = fbox
- do outboxoff
- outbox = ppm_PageNextBox(outbox)
- end
- todo = ppm_TextOverFlow( outbox )
-
- if todo then
- do
- info = ppm_GetBoxInfo(box)
- b_width = word(info,5)
- if (b_width = 0) then exit_msg("Word too wide for box.")
- end
- end
-
- call exit_msg("Done")
-
- /*
- * Box Offset Procedure
- */
- boxoffset: procedure
- do
- arg box, page
- cbox = ppm_PageFirstBox(page)
- bcount = 0
- do while cbox ~= 0
- if cbox = box then return(bcount)
- cbox = ppm_PageNextBox(cbox)
- bcount = bcount + 1
- end
- exit_msg("An internal error has occured. Please try again")
- end
-
- /*
- * Exit Msg Procedure
- */
- exit_msg: procedure
- do
- parse arg message
- if message ~= '' then call ppm_Inform(1, message,)
- call ppm_AutoUpdate(1)
- exit
- end
-
-