/* This genie creates new style tags automatically by examining all the text in a document. If any text is in a style which does not match an existing tag, a new tag is created and the text is set to that tag. Tags are named with a simplified description of the typeface; you can alter any of these names to anything you wish (using the "Style Tags Modify" menu item). If you modify the tag, its typeface name might no longer suit it.
Don Cox ⌐ Sept 92 Not Public Domain. All rights reserved. */
/* Method: load in typographic data from article texts. If an existing style is used, see if it is modified (further data after the style name). Ignore any data for text after the first letter. If no existing style is used, assemble the data and compare with all existing styles to see if there is a match. If not, suggest a name for a new style, create it and apply it to the block. */
trace n
if ~show(l, "gdarexxsupport.library") then
if ~(exists("libs:gdarexxsupport.library") & addlib("gdarexxsupport.library", 0, -30)) then
exit_msg("Please install the gdarexxsupport.library in your libs: directory before running this Genie")
address command
call SafeEndEdit.rexx()
call ppm_AutoUpdate(0)
prevdoc = ppm_GetDocName()
if ppm_DocChanged() then
do
if ppm_SavedDate() = "Not Saved" then prevdoc = ""
if ppm_Inform(2, "You must save the document first. Save and continue?", "Cancel", "Ok") then
call ppm_SaveDocument(prevdoc)
else
exit_msg(0,)
prevdoc = ppm_GetDocName()
end
colormode = ppm_GetColorMode()
call ppm_SetColorMode(0)
cpage = ppm_CurrentPage()
tolerant = ppm_Inform(2,"Ignore bold, italic and underline?","No","Yes")
call ppm_ShowStatus("Working..")
existing = 0 /* flag for style matching existing style */
randval = (randu() * time(s)) % 1 /* mark boxes with random number to avoid doing them twice */
box = ppm_DocFirstBox()
do while box ~= 0
info = upper(word(ppm_GetBoxInfo(box), 1))
if (info = "TEXT") & (ppm_GetBoxUserData(box) ~= randval) then do
oldbox = box
box = ppm_ArtFirstBox(box)
text = ppm_GetArticleText(box, 1)
call ppm_ShowStatus(" Analysing article that begins in box "box)
if text = '' then iterate
paraname = ""
paracode = ""
stylename = ""
stylecode = ""
fontname = ""
typestyle = ""
fontsize = ""
bold = ""
italic = ""
underline = ""
outline = ""
kerning = ""
hyphenation = ""
linespace = ""
linespacecode = ""
lineshift = ""
tracking = ""
colour = ""
justification = ""
position = 1
trace n
do x = 1 to 10000 /* big number - go right through article */
change = 0
notcode = 0
position = parsecodes(position) /* parse a block of codes in text */