home *** CD-ROM | disk | FTP | other *** search
Wrap
/* @B@LPageGenie.pgen General purpose template filler This is the main engine of most PageGenies */ parse arg sourcedir call pragma(d,"rexx:") if ~show(l, "gdarexxsupport.library") then if ~addlib("gdarexxsupport.library", 0, -30) then exit_msg("Please install the gdarexxsupport.library in your libs: directory before running PageGenies!") cr = '0a'x call SafeEndEdit.rexx() units = ppm_GetUnits() if units = 3 then call ppm_SetUnits(1) call SetClip(ppgenie_units, units) signal on halt signal on break_c signal on break_e signal on break_d functions = "EXECUTEGENIE INSERTPERSONALINFO IMPORTGRAPHIC SETTEXTSTYLE SETSIZE ENDEDITMODE LINKBOXES PROMPT UPDATESCREEN ZOOM REPLACETEXT JUSTIFY SELECTBOX LOADPAGE DONE MAKECOLUMNS ZOOM IMPORTTEXT SETFONT DELETEBOXCONTENTS" functions = functions" EDITARTICLE REPLACESTRING GOTOPAGE" list = getdirlist.rexx(sourcedir, "_pgtp") if list = '' then exit_msg("Page Genies not installed properly. Please reninstall") list = ppm_SelectFromList("Select type of Genie..", 30, 5, 0, list) if list = '' then exit_msg() lastdir = '' filename = sourcedir'/'list'_pgtp' if ~open(file, filename, "r") then exit_msg("An error has occured reading the PageGenie template file!") /* Initialize font list */ font = FontList.rexx() call ppm_SetBoxOutlines(1) currentbox = 0 gutter = .25 cols = 3 update = 1 if ppm_Inform(2, "Would you like to turn off the auto update to speed up screen refresh? Some text updates may appear to lag a step behind.", "No", "Yes") then do call ppm_AutoUpdate(0) update = 0 end do while ~eof(file) line = readln(file) parse var line command ';' . command = strip(upper(command)) if pos(command, functions) ~= 0 then interpret "call "command"(line)" else if line ~= '' & pos('/*', line) = 0 & pos('*/', line) = 0 then call ppm_Inform(1,"Could not understand line: "line,) end exit_msg("") EXECUTEGENIE: procedure expose sourcedir units do parse arg line parse var line command ';' geniename ';' extension if pos(".pgen", geniename) ~= 0 then do pgen = 1 root = sourcedir'/' end else root = '' if geniename = '' then do list = getdirlist.rexx(sourcedir, extension) if list = '' then return geniename = ppm_SelectFromList("Select a Genie..", 30, 5, 0, list) if geniename = '' then return geniename = geniename||extension end if ~exists(root||geniename) then do call ppm_Inform(1,"Unable to locate Genie: "geniename,) return end if pgen = 1 then currdir = pragma('d', sourcedir) else do currdir = pragma('d', splitroot(geniename)) geniename = '"'splitpath(geniename)'"' end address command if pgen = 1 then interpret "call "'"'geniename'"'"(sourcedir)" else interpret "call "geniename"()" call pragma('d', currdir) call ppm_SetUnits(1) return end ZOOM: procedure expose units do parse arg line parse var line command ';' percentage if ~datatype(percentage, n) then return call SafeEndEdit.rexx() call ppm_ShowStatus("Zooming to %"percentage) call ppm_SetMagMode(percentage) call ppm_UpdateScreen() return end DONE: procedure expose units do parse arg line parse var line command ';' message ';' boxes call SafeEndEdit.rexx() pages = 0 do while boxes ~= '' parse var boxes boxname ';' boxes if boxname = '' then iterate if boxname = 'PAGENAMES' then pages = 1 if pages then do page = ppm_PageNum(boxname) if page ~= 0 then call ppm_SetPageName(page, "") end else do box = ppm_BoxNum(boxname) if box ~= 0 then call ppm_SetBoxName(box, "") end end call exit_msg(message) end LOADPAGE: procedure expose sourcedir units do parse arg line parse var line command ';' pagename ';' extension call SafeEndEdit.rexx() if strip(pagename) = '' then do list = getdirlist.rexx(sourcedir, extension) if list = '' then abort("Unable to open appropriate templates") do forever pagename = ppm_SelectFromList("Select template..", 30, 5, 0, list) if pagename = '' then abort() pagename = sourcedir'/'pagename||extension if ~ppm_LoadPage(ppm_CurrentPage() + 1, pagename, 1) then abort("An error has occured loading page:" pagename) call ppm_UpdateScreen() resp = ppm_Inform(3,"Use this template?", "Abort Genie","Try Another", "Yes") if resp = 0 then abort("Genie Aborted!") else if resp = 2 then return call ppm_DeletePage(ppm_CurrentPage(),1) end end else do /* look for pagename in current directory, if we cant find it * assume its in the source directory */ if ~exists(pagename) then pagename = sourcedir'/'pagename if ~exists(pagename) then abort("Unable to open appropriate templates") end call ppm_Showstatus("Attempting to load page: "pagename) if ~ppm_LoadPage(ppm_CurrentPage() + 1, pagename, 1) then abort("An error has occured loading page:" pagename) call ppm_UpdateScreen() return end SELECTBOX: procedure expose currentbox update units do parse arg line parse var line command ';' boxname ';' edit call SafeEndEdit.rexx() box = ppm_BoxNum(boxname) if box = 0 then do if ~ppm_Inform(2, "Unable to find a box in current template. This Page Genie may not function properly. Continue?", "No", "Yes") then abort() else return end boxpos = ppm_GetBoxPosition(box) call ppm_SetPagePosition(word(boxpos, 1), word(boxpos, 2)) if edit = 1 then call SafeSetEdit.rexx(box) currentbox = box bpage = ppm_BoxPage(box) if bpage ~= ppm_CurrentPage() then do call ppm_GotoPage(bpage) if update then call ppm_UpdateScreen() end return end REPLACETEXT: procedure expose currentbox update units do parse arg line parse var line command ';' insert ';' prompt ';' prompt2 if currentbox = 0 then return call SafeEndEdit.rexx() info = upper(word(ppm_GetBoxInfo(currentbox), 1)) if info ~= "TEXT" & info ~= "EMPTY" then return do forever typo = ppm_GetBoxText(currentbox, 0) if typo ~= '' then typo = left(typo, skipcodes(typo, 1) - 1) if insert = 1 then do text = left(ppm_GetBoxText(currentbox,0), 50) cr = pos('0a'x, text) if cr ~= 0 then text = left(text, max(1, cr - 1)) text = strip(text) end else text = '' rtext = ppm_GetForm(prompt, 40, prompt":"text) if rtext = '' then return call ppm_DeleteContents(currentbox) call ppm_TextIntoBox(currentbox, rtext) if SETTEXTSTYLE(1) = 2 then return call SafeEndEdit.rexx() insert = 1 end end SETSIZE: procedure expose currentbox units do parse arg line parse var line command if currentbox = 0 then return if ppm_GetState() ~= "3 99" then call SafeSetEdit.rexx(currentbox) call ppm_SelectAllText() do forever size = ppm_GetSize() size = ppm_Getform("Set font size..", 8, "Size:"size) if size = '' then leave if ~datatype(size, n) then do call PromptUser("Invalid entry") iterate end call ppm_SetSize(size) if ~ppm_TextOverflow() then leave if ppm_Inform(2, "Is this OK?", "Try Again", "Yes") then leave end return end SETFONT: procedure expose currentbox units do parse arg line parse var line command if currentbox = 0 then return if ppm_GetState() ~= "3 99" then call SafeSetEdit.rexx(currentbox) call ppm_SelectAllText() do forever font = ppm_GetFont() font = ppm_SelectFromList("Select Font..", 30, 10, 0, FontList.rexx(font)) if font = '' then leave call ppm_SetFont(font) if ppm_Inform(2, "Is this OK?", "Try Again", "Yes") then leave end return end JUSTIFY: procedure expose currentbox units do parse arg line parse var line command ';' justification if currentbox = 0 then return if ppm_GetState() ~= "3 99" then call SafeSetEdit.rexx(currentbox) call ppm_SelectAllText() if ~datatype(justification, n) then return call ppm_SetJustification(justification) return end MAKECOLUMNS: procedure expose currentbox gutter cols units do cr = '0a'x if currentbox = 0 then return call SafeEndEdit.rexx() if units = 3 then gutter = ppm_ConvertUnits(1, 3, gutter) do forever user = ppm_GetForm("How many colums will you need?", 8, "Columns 1 - 6:"cols||cr"Gutter:"gutter) if user = '' then return parse var user cols '0a'x gutter if ~(datatype(cols, n) & datatype(gutter, n)) | cols > 6 | cols < 1 then do call PromptUser("Invalid Entry") iterate end break end if units = 3 then gutter = ppm_ConvertUnits(3, 1, gutter) list = ppm_SelectFromList("Select column options..", 30, 2,1, "Vertical Dividers"cr"Borders") if pos('Vertical', list) ~= 0 then vert = y else vert = n if pos('Borders', list) ~= 0 then borders = y else borders = n name = ppm_GetBoxName(currentbox) box = MakeBoxIntoColumns.pprx(currentbox, cols, gutter, vert, borders, "Y") call ppm_SetBoxName(box, name) currentbox = box return end IMPORTTEXT: procedure expose currentbox update lastdir units do if currentbox = 0 then return call SafeEndEdit.rexx() info = upper(word(ppm_GetBoxInfo(currentbox), 1)) if info ~= "TEXT" & info ~= "EMPTY" then return typo = ppm_GetBoxText(currentbox, 0) if typo ~= '' then typo = left(typo, skipcodes(typo, 1) - 1) do forever call SafeEndEdit.rexx() if ppm_Inform(2, "Import a text file?", "No", "Yes") then do filename = ppm_GetFileName("Select Text File..", lastdir, "") if filename = '' then return lastdir = splitroot(filename) call ppm_ShowStatus("Attempting to import "filename) call ppm_DeleteContents(currentbox) call ppm_TextIntoBox(currentbox, typo) if ~ppm_ImportText(ppm_ArtFirstBox(currentbox),filename) then do call ppm_Inform(1, "Unable to import "filename,) return end if SETTEXTSTYLE(1) = 2 then return call SafeEndEdit.rexx() end else return end end UPDATESCREEN: procedure expose units do call SafeEndEdit.rexx() call ppm_UpdateScreen() return end PROMPT: procedure expose units do parse arg line parse var line command ';' string if string ~= '' then do if length(string) > 1000 then do zbox = ppm_CreateBox(-2, -2, .001, .001, 0) call SafeSetEdit.rexx(zbox) call ppm_InsertText(string) call ppm_EditWithAE() call SafeEndEdit.rexx() call ppm_DeleteContents(zbox) end else call ppm_Inform(1,string,) end return end break_d: break_e: break_c: halt: call abort("User aborted Genie!") exit_msg: procedure expose units do parse arg message call SafeEndEdit.rexx() if message ~= '' then call ppm_Inform(1,message,) call ppm_AutoUpdate(1) call ppm_SetUnits(units) call ppm_ClearStatus() exit end LINKBOXES: procedure expose currentbox units do parse arg line parse var line command ';' box1 ';' box2 call SafeEndEdit.rexx() if box1 = '' | box2 = '' then return boxnum1 = ppm_BoxNum(box1) boxnum2 = ppm_BoxNum(box2) info1 = upper(word(ppm_GetBoxInfo(boxnum1), 1)) info2 = upper(word(ppm_GetBoxInfo(boxnum2), 1)) if verify(info1, "EMPTYTEXT") ~= 0 then return call ppm_DeleteContents(boxnum2) call ppm_ShowStatus("Linking boxes..") if boxnum1 ~= 0 & boxnum2 ~= 0 then call ppm_LinkBox(ppm_ArtLastBox(box1), box2) return end ENDEDITMODE: procedure expose units do call SafeEndEdit.rexx() return end IMPORTGRAPHIC: procedure expose currentbox lastdir units do cr = '0a'x if currentbox = 0 then return call SafeEndEdit.rexx() list = ppm_SelectFromList("Select type of graphic to import..", 30, 5, 0, "BitMap"cr"ProDraw Clip"cr"Aegis Draw"cr"EPSF") if list = '' then return do forever call ppm_DeleteContents(currentbox) if list = 'ProDraw Clip' then res = ppm_ImportClip(currentbox,"","") else do graphic = ppm_GetFileName("Please Select a "list" graphic", lastdir, "") if graphic = '' then return lastdir = splitroot(graphic) if list = 'Aegis Draw' then res = ppm_ImportAegis(currentbox, graphic) else if list = 'BitMap' then res = ppm_ImportBM(currentbox, graphic) else if list = 'EPSF' then res = ppm_ImportEPSF(currentbox, graphic) end if res = 0 then do if ~ppm_Inform(2,"Unable to load file. Try again?", "No", "Yes") then return end else return end end INSERTPERSONALINFO: procedure expose currentbox update units do if currentbox = 0 then return call SafeEndEdit.rexx() info = upper(word(ppm_GetBoxInfo(currentbox), 1)) if info ~= "TEXT" & info ~= "EMPTY" then return call SafeSetEdit.rexx(currentbox) if ~ppm_Inform(2,"Would you like to insert your Personal info?", "No","Yes") then return call InsertPersonalInfo.pprx() call SETTEXTSTYLE(0) return end SETTEXTSTYLE: procedure expose currentbox update units do parse arg earlyreturn if currentbox = 0 then return cr = '0a'x call SafeEndEdit.rexx() info = upper(word(ppm_GetBoxInfo(currentbox), 1)) if info ~= "TEXT" & info ~= "EMPTY" then return do forever call SafeSetEdit.rexx(currentbox) call ppm_SelectAllText() size = ppm_GetSize() size = ppm_GetForm("Select font size..", 8, "Size:"size) if datatype(size, n) then do call ppm_ShowStatus("Setting text size..") call ppm_SetSize(size) if update then do call SafeEndEdit.rexx() call SafeSetEdit.rexx(currentbox) call ppm_SelectAllText() end end else if size ~= '' then do call PromptUser("Invalid Entry") iterate end font = ppm_SelectFromList("Select font..", 30, 10, 0, FontList.rexx(ppm_GetFont())) if font ~= '' then do call ppm_SetFont(font) if update then do call SafeEndEdit.rexx() call SafeSetEdit.rexx(currentbox) call ppm_SelectAllText() end end style = ppm_GetStyle() if pos("B", style) ~= 0 then style = "Bold" else if pos("B", style) ~= 0 then style = "Bold" else if pos("N", style) ~= 0 then style = "Plain" else if pos("U", style) ~= 0 then style = "Underline" else if pos("I", style) ~= 0 then style = "Italic" else if pos("O", style) ~= 0 then style = "Outline" style = ppm_SelectFromList("Select Style..", 25, 4, 1, ItemToFront.rexx(style,"Plain"cr"Italic"cr"Outline"cr"Bold"cr"Underline")) tstyle = '' if pos("Bold", style) ~= 0 then tstyle = 'b' if pos("Italic", style) ~= 0 then tstyle = tstyle'i' if pos("Underline", style) ~= 0 then tstyle = tstyle'u' if pos("Outline", style) ~= 0 then tstyle = tstyle'o' if pos("Plain", style) ~= 0 then tstyle = 'n' if tstyle ~= '' then do call ppm_ShowStatus("Setting text style..") call ppm_SetStyle(tstyle) if update then do call SafeEndEdit.rexx() call SafeSetEdit.rexx(currentbox) call ppm_SelectAllText() end end justify = ppm_GetJustification() if justify = 0 then justify = "Left" else if justify = 1 then justify = "Right" else if justify = 2 then justify = "Center" else if justify = 3 then justify = "Flush" justify = ppm_SelectFromList("Select justification..", 25, 4, 0, ItemToFront.rexx(justify,"Left"cr"Center"cr"Right"cr"Flush")) if justify ~= '' then do call ppm_ShowStatus("Setting text justification..") if justify = "Left" then call ppm_SetJustification(0) if justify = "Right" then call ppm_SetJustification(1) if justify = "Center" then call ppm_SetJustification(2) if justify = "Flush" then call ppm_SetJustification(3) if update then do call SafeEndEdit.rexx() call SafeSetEdit.rexx(currentbox) call ppm_SelectAllText() end end resp = ppm_Inform(3, "Is this OK?", "Abort Genie", "Try Again", "Yes") if resp = 0 then call abort() if earlyreturn = 1 then return(resp) if resp = 2 then return end end DELETEBOXCONTENTS: procedure expose currentbox units do if currentbox = 0 then return call SafeEndEdit.rexx() call ppm_DeleteContents(currentbox) return end EDITARTICLE: procedure expose currentbox units do if currentbox = 0 then return call SafeEndEdit.rexx() info = upper(word(ppm_GetBoxInfo(currentbox), 1)) if info ~= TEXT & info ~= "EMPTY" then return if ppm_GetState() ~= "3 99" then call SafeSetEdit.rexx(currentbox) call ppm_EditWithAE() return end REPLACESTRING: procedure expose currentbox units do parse arg line parse var line command ';' searchstring ';' case if currentbox = 0 then return if searchstring = '' then return call SafeEndEdit.rexx() info = upper(word(ppm_GetBoxInfo(currentbox), 1)) if info ~= "TEXT" & info ~= "EMPTY" then return if ppm_GetState() ~= "3 99" then call SafeSetEdit.rexx(currentbox) if ~datatype(case, n) | verify(case, "01") ~= 0 then case = 1 if ~ppm_Find(searchstring, 0, case) then return repstring =ppm_GetForm("Enter replacement string..", 30,"String:"searchstring) call ppm_InsertText(repstring) return end PromptUser: do parse arg message call ppm_Inform(1, message,) return end GOTOPAGE: procedure expose units do parse arg line parse var line command ';' page cpage = ppm_PageNum(page) if cpage = 0 then do call Prompt("Unable to identify page named: "page". Genie may not function properly.") return end call ppm_ShowStatus("Going to page named "page) call ppm_GotoPage(cpage) return end splitpath: procedure expose units do parse arg path colon = lastpos('/', path) if colon = 0 then colon = lastpos(':', path) if colon = 0 then return(path) else return(substr(path, colon + 1)) end splitroot: procedure expose units do parse arg root colon = lastpos('/', root) if colon = 0 then colon = pos(':', root) if colon = 0 then return("") else return(left(root, colon)) end abort: procedure expose file units do parse arg message if message ~= '' then call ppm_Inform(1,message,) do while ~eof(file) line = readln(file) parse var line command ';' . command = strip(upper(command)) if command = "DONE" then call DONE(line) end exit_msg("Done") end