home *** CD-ROM | disk | FTP | other *** search
Wrap
/* This Genie applies random colours and/or baseline shifts to a selected block of text. Warnings: it is slow, it increases the length of the selected text by a factor of 8 or 9 (because of all the style codes needed), and it slows ProPage down to a crawl. So only do it at the end when you have got everything else right. Note that any other style codes inside the block will be removed. Written by Don Cox © August 93, bug fix Apr 94. Not Public Domain. */ /* $VER: Jumpy&MulticolouredText April 94 */ signal on error signal on syntax address command if word(ppm_GetState(), 1) ~= 3 then exit_msg("You must be in edit mode to use this Genie") text = ppm_GetBlockText(0) if text = '' then exit_msg("No text selected") effect = ppm_Inform(3,"Select required effect","Jumpy","Both", "Multicoloured") if effect = -1 then exit_msg("Something went wrong") if effect<=1 then do factor = ppm_GetUserText(8,"Maximum shift (points)") if factor = "" then effect=2 if ~(datatype(factor,n)) then exit_msg("Invalid entry") if factor>600 then factor = 600 end if effect >=1 then do collist = ppm_GetColorList() collist = substr(collist, pos('0a'x, collist) + 1) /* It begins with a number */ chosen = ppm_SelectFromList("Select colours",36,24,1,collist) if chosen = "" then exit_msg("No colours chosen") n=1 do forever /* put colours into a compound variable */ parse var chosen acolour "0a"x chosen if acolour = "" then break colours.n = acolour n=n+1 end colournumber = n-1 end call ppm_ShowStatus(" Processing text...") /* Split into sections to avoid trouble with ARexx's limit of 64k on length of strings */ sections = (length(text)%2000)+1 do i=1 to sections texts.i.endofsection = 2000 if i = sections then texts.i.endofsection = length(text)//2000 texts.i.thisSection = substr(text, (2000*(i-1))+1, texts.i.endofsection) end do i = 1 to sections position = 1 newtext = "" do until position = texts.i.endofsection+1 if effect >= 1 then do randcol = random(1,colournumber,time("s")) thiscolour = colours.randcol randbase = "\c<"||thiscolour||">" end if effect = 0 then randbase = "\ls<"||randu()*factor||">" if effect = 1 then randbase = "\c<"||thiscolour||">\ls<"||randu()*factor||">" nextchar = substr(texts.i.thisSection, position, 1) newtext = newtext||randbase||nextchar position = position+1 end if i = 1 then call ppm_SaveText("PPage:textfile.temp",newtext) if i>1 then call ppm_SaveMoreText("PPage:textfile.temp",newtext) end call ppm_ShowStatus(" Removing old text...") success = ppm_Cut() if success ~= 1 then exit_msg("Cut failed") call ppm_ShowStatus(" Inserting new text...") success = ppm_InsertFile("PPage:textfile.temp") if success~=1 then exit_msg("Failed inserting altered text") "delete PPage:textfile.temp quiet" call exit_msg() end /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ error: syntax: do exit_msg("Genie failed due to error: "errortext(rc)) end exit_msg: do parse arg message if message ~= "" then call ppm_Inform(1,message,"Resume") call ppm_ClearStatus() exit end