Applescript CGI Counter
Applescript CGI Counter
- Subject: Applescript CGI Counter
- From: List Guy <email@hidden>
- Date: Sat, 14 Apr 2001 07:07:05 -0700
Michelle wrote: "With the number incrimenting every time the page is
accessed."
Have you considered using a set of jpegs or gifs? That is, the web page has
img tags that point to the current number, where each digit is a separate
img. You'll need separate img for ones, tens, hundreds, thousands, etc. THEN
instead of using the applescript to send the html, use the applescript to
copy the current counter value over the old value.
Here's a rough example, using only 1-10
<img src="counter/tens.jpg><img src="counter/ones.jpg">
if tens.jpg is the image of a "1" and ones.jpg is the image of a "2", then
two consecutive images that read 12 will be displayed.
when the counter is incremented, the applescript will copy the image
three.jpg to the "counter" folder renaming "three.jpg" to "ones.jpg" and
replacing the old "ones.jpg" image. Of course, you'll need to keep a
separate property or text file that tracks the proper counter value, but
this way your web page will always include the correct html code.
If you don't want to use images, your script will have to assembles the page
in three parts; e.g.
set html_page to read file top_of_page
set html_page to html_page & counter_markup
set html_page to html_page & bottom_of_page
return html_page
Now:"So, the return value is all the html code that would display a web
page?"
Yes. Always. Whatever the server returns is the full html page. With
languages like Perl & Applescript, the html code must be embedded in the
script; with languages like PHP and VBS, the language is embedded in the
html code. In Perl & Applescript, the main program calls subroutines which
assemble the page; in VBS, the main page transfers to subsidiary pages. No
matter which you use, it's easy to lose track of the whole appearance of
your page. Neither is better than the other, though the differences in
approach mean sometimes users have strong preferences.