Re: The Pyramid - a challenge...
Re: The Pyramid - a challenge...
- Subject: Re: The Pyramid - a challenge...
- From: Martin Orpen <email@hidden>
- Date: Sun, 24 Apr 2005 11:03:22 +0100
on 23/4/05 17:52, Nigel Garvey at email@hidden wrote:
> However, this version seems to do better in AS 1.9.1, especially with
> larger pyramids:
[snip]
Thanks Nigel.
Time to build the pyramid!
What follows is one of my sketchy messes:
-- the pyramid in html with mod 5 highlights
-- take care with the line breaks for this html stuff
property theHeader : "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\">
<html>
<head>
<title>The Pyramid - mod 5</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
</head>
<body>"
property theFooter : "</body>
</html>"
property t1 : "<table width=\""
property t2 : "\" border=\"0\" align=\"center\"><tr>
"
property t3 : "</tr>
</table>"
property d1 : "<td width=\"60\"> <div align=\"center\"><font size=\"1\">"
property d1a : "<td width=\"60\" bgcolor=\"#999999\"> <div
align=\"center\"><font size=\"1\">"
property d2 : "</font></div></td>
"
set l1 to {{1}, return}
repeat 20 times
set end of my l1 to nextStep(item -2 of my l1)
set end of my l1 to return
end repeat
set end of l1 to nextStep(item -2 of my l1)
set h to ""
set h to h & theHeader
repeat with n from 1 to 43 by 2
set woo to item n of l1
set h to makeTable(woo, h)
end repeat
set h to h & theFooter
writeFile(h, "PyramidM5.html")
on makeTable(c, h)
set d to count of c
set h to h & t1
set h to h & ((d) * 20)
set h to h & t2
repeat with n from 1 to d
if ((item n of c) mod 5) is equal to 0 then
set h to h & d1a
else
set h to h & d1
end if
set h to h & item n of c
set h to h & d2
end repeat
set h to h & t3
return h
end makeTable
on nextStep(x)
script o
property p : x
property foo : {1}
end script
set n to (count x)
repeat with y from 2 to n div 2 + 1
set end of o's foo to (item (y - 1) of o's p) + (item y of o's p)
end repeat
return o's foo & reverse of items 1 thru (n mod 2 - 2) of o's foo
end nextStep
on writeFile(fD, fN)
set t to path to desktop
set posixT to POSIX path of t
set f to open for access file ((t as string) & fN) with write permission
write fD to f
close access f
end writeFile
Hope that works. I tried to send it as HTML, but it kept breaking in
Entourage.
--
Martin Orpen
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden