• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
boolean cruelty
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

boolean cruelty


  • Subject: boolean cruelty
  • From: Joshua Whalen <email@hidden>
  • Date: Tue, 27 Jan 2009 19:18:15 -0500

The following script is tormenting me.

I need to read a list of files in a folder, and convert the list to a page of links to those files. 

everything works fine, except when I try to concatenate "<a href="">" and linkname and "</a>"

I get "cant make "<a href="">" or anything else, for that matter) into a boolean.

Now, it's getting expensive! I've thrown 3 laptops out the window already, and sooner or later one of them is going to hit a passerby, and then it's going get real expensive (I live on the 5 floor in nyc), or worse.

Any help? Or should I just imitate my laptops?

Here's the script:

global filelist
global this_file
global prefix
global suffix
global item_a
global closetag
on run
set filelist to (list folder "Macintosh HD:Users:joshua:Sites:demo:" without invisibles) as list
set prefix to "<a href="">
set suffix to ">"
set closetag to "</a>"
do shell script "touch /Users/joshua/Sites/demo/articles.html"
set this_file to "Macintosh HD:Users:joshua:Sites:demo:articles.html"
open for access this_file with write permission
repeat with i from 1 to count of filelist
set docname to item i of filelist
set item_a to (a reference to prefix and docname and suffix and docname and closetag)
my WriteNow(item_a, this_file, true, text)
end repeat
close access file this_file
end run

on WriteNow(this_data, this_file, append_data, MyFormat)
try
set this_file to this_file as string
if append_data is false then
set eof of file this_file to 0
set MyAppend to false
else
set MyAppend to true
end if
if MyFormat is text then
write this_data to alias this_file starting at eof
log " I wrote it as text " & MyAppend & " " & return & this_data & return & return
return true
else
if MyFormat is not text then
write this_data to alias this_file as «class utf8» starting at eof
log " I wrote it as utf8 " & MyAppend & " " & return & this_data & return & return
return true
end if
end if
on error
try
close access file this_file
beep 12
end try
return false
end try
end WriteNow

Joshua Whalen
email@hidden
email@hidden
http://www.panix.com/~joshua/resume.html

"Vision without action is a day dream,
Action without vision is a nightmare."
-- Japanese proverb




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: boolean cruelty
      • From: "Mark J. Reed" <email@hidden>
    • Re: boolean cruelty
      • From: Michelle Steiner <email@hidden>
  • Prev by Date: RE: run script error
  • Next by Date: Re: boolean cruelty
  • Previous by thread: RE: run script error
  • Next by thread: Re: boolean cruelty
  • Index(es):
    • Date
    • Thread