Monday, November 08, 2010 at 12:00 AM.

system.verbs.apps.cardEditor.examples.randomLoop

on randomitem () {
	ct = cardeditor.countselectedobjects ();
	if ct == 0 {
		scripterror ("There must be at least one selected object")};
	return (cardeditor.getnthselectedobject (random (1, ct)))};
on randomcolor () {
	on randomgun () {
		return (random (-32000, 32000))};
	return (rgb.set (randomgun (), randomgun (), randomgun ()))};
on randomfont () {
	case random (1, 3) {
		1 {
			return ("Geneva")};
		2 {
			return ("Palatino")};
		3 {
			return ("Chicago")}}};
on randomfontsize () {
	case random (1, 3) {
		1 {
			return (9)};
		2 {
			return (12)};
		3 {
			return (24)}}};
on randomfontstyle () {
	case random (1, 3) {
		1 {
			return (plain)};
		2 {
			return (bold + outline)};
		3 {
			return (italic + underline)}}};
on randomrect () {
	local (t, l, b, r);
	t = random (0, 100);
	l = random (0, 100);
	b = t + random (15, 35);
	r = l + random (30, 75);
	return (rectangle.set (t, l, b, r))};
on randomstate () {
	return (states.nthstate (random (1, 50)))};
loop {
	local (item = randomitem ());
	cardeditor.setobjectfillcolor (item, randomcolor ());
	cardeditor.setobjectfont (item, randomfont (), randomfontsize (), randomfontstyle ());
	cardeditor.setobjectflag (item, random (0, 1));
	<<cardeditor.setobjectseethru (item, random (0, 1))
	cardEditor.setObjectJustification (item, random (0, 2));
	<<cardEditor.setObjectType (item, random (1, 12))
	cardeditor.setobjectrect (item, randomrect ());
	cardEditor.setObjectText (item, randomstate ());
	cardeditor.cleanobject (item);
	<<cardeditor.setcardbackcolor (randomcolor ())
	<<cardeditor.updateobject (item)
	cardeditor.setobjecttext ("memavail", cardeditor.memavail ())}



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.