/* This Genie applies random colours 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. Written by Don Cox © Dec 92 Not Public Domain. All rights reserved. */ trace n 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") 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 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 randcol = random(1,colournumber,time("s")) thiscolour = colours.randcol randbase = "\c<"||thiscolour||">" 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" 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