home *** CD-ROM | disk | FTP | other *** search
- /*
- @BInsertDoc @P@ICopyright Gold Disk Inc., Jan, 1993
-
- This Genie will insert a previously saved document into the current document while maintaining all links between boxes.
-
- */
- cr = '0a'x
- call SafeEndEdit.rexx()
- call ppm_AutoUpdate(0)
- call ppm_SetBatchMode(1)
-
- prevdoc = ppm_GetDocName()
-
- if ppm_DocChanged() then
- do
- if ppm_SavedDate() = "Not Saved" then prevdoc = ""
-
- if ppm_Inform(2, "You must save the current document first. Should I save and continue?", "Cancel", "Ok") then
- call ppm_SaveDocument(prevdoc)
- else
- exit_msg(0,)
-
- prevdoc = ppm_GetDocName()
- end
-
- doc = ppm_GetFileName("Select Document to insert", "", "")
- if doc = '' then exit
-
- if ~ppm_LoadDocument(doc, 0, 0) then
- exit_msg(0, "Unable to open document: "doc)
-
- boxes = 0
-
- call ppm_ShowStatus("Working..")
-
- npages = ppm_NumPages()
-
- box = ppm_DocFirstBox()
-
- oldnames = 0
- text = 1
- count = 3
- article = 0
-
- /* cycle through all the boxes in the document */
- do while box ~= 0
-
-
- info = upper(ppm_GetBoxInfo(box))
- fname = word(ppm_GetBoxName(box), 1)
-
- /* check if this is a box within a text link */
- if word(info, 1) = 'TEXT' & word(info, 3) ~= 1 & fname ~= "PGLNK" then
- do
- cbox = ppm_ArtFirstBox(box)
- article = article + 1
- links.article.oldnames = links.article.oldnames || '0a'x || fname
- links.article.text = ppm_GetArticleText(cbox, 1)
- call ppm_DeleteContents(cbox)
-
- call ppm_SetBoxName(cbox, "PGLNK "article" 0")
-
- nextbox = ppm_ArtNextBox(cbox)
- counter = 0
-
- do while nextbox ~= 0
-
- counter = counter + 1
- boxname = ppm_GetBoxName(nextbox)
- links.article.oldnames = links.article.oldnames || '0a'x || boxname
-
- call ppm_SetBoxName(nextbox, "PGLNK "article" "counter)
- nextbox = ppm_ArtNextBox(nextbox)
-
- end
-
- links.article.count = counter
-
- end
-
- box = ppm_DocNextBox(box)
-
- end
-
- /* save all of the pages */
- do page = 1 to npages
-
- if ~ppm_SavePage(page, "Ram:temppage"page) then
- exit_msg(page, "An error has occured while saving the pages to the Ram Disk.")
-
- end
-
- prevpage = page - 1
-
- if ~ppm_LoadDocument(prevdoc, 1, 0) then
- exit_msg(prevpage, "An error has occured reloading the original document")
-
- cpage = ppm_DocLastPage()
- startpage = ppm_GetForm("Insert after Page", 8, "Page:"cpage)
- if startpage = '' then exit_msg(prevpage, "")
-
- if ~datatype(startpage, n) then exit_msg("Invalid Input")
-
- do page = 1 to prevpage
-
- if ~ppm_LoadPage(startpage + 1, "Ram:temppage"page, 1) then
- exit_msg(prevpage, "Error opening saved page")
-
- startpage = startpage + 1
- end
-
- /* relink boxes */
- do art = 1 to article
-
- prefix = "PGLNK "art
- prevbox = ppm_BoxNum(prefix" 0")
- if prevbox = 0 then exit_msg("Error! Unable to re-establish links!")
-
- firstbox = prevbox
-
- parse var links.art.oldnames junk '0a'x fbname '0a'x links.art.oldnames
-
- call ppm_SetBoxName(prevbox, fbname)
-
- do boxcount = 1 to links.art.count
-
- nextbox = ppm_BoxNum(prefix" "boxcount)
- if boxcount = 0 then
- exit_msg("Error! Unable to re-establish links!")
-
- call ppm_LinkBox(prevbox, nextbox)
-
- parse var links.art.oldnames boxname '0a'x links.art.oldnames
- call ppm_SetBoxName(nextbox, boxname)
-
- prevbox = nextbox
-
- end
-
- call ppm_TextIntoBox(firstbox, links.art.text)
-
- end
-
- exit_msg(prevpage, "Done")
-
-
- exit_msg: procedure
- do
- parse arg pages, message
-
- do pg = 1 to pages
- call Delete("ram:temppage"pg)
- end
-
- if message ~= '' then
- call ppm_Inform(1, message, )
-
- call ppm_AutoUpdate(1)
- call ppm_ClearStatus()
- call ppm_SetBatchMode(1)
- exit
- end
-
-