Photoshop, AppleScript & the original folder

I am developing a little application that grabs the weather from the Weather Channel’s XML weather service. Now, the weather channel doesn’t provide a typical SOAP service, so I just have it download the specific URL with a zipcode like this:

set theweather to do shell script "curl [url=http://xoap.weather.com/weather/local/]http://xoap.weather.com/weather/local/"[/url] & zip & "?cc=*\&prod=xoap\&par={1004016953}\&key={f9b8f04d93ba4fb0}"

Once it downloads I have a routine that strips out the weather “icon” which tells an app which icon to use, from a selection of about 50, to depict the weather. Now, once it is all finished I get this:


I simply need a way to remove the parts of the string, and leave me with the number, so that I can use that number elsewhere. Any ideas? I’m positive that it’s possible (without any scripting additions please) to do it. Thanks ahead of time.

P.s. I realize that there could be a thread on this somewhere, but I really don’t know what to search for. Sorry.
[/quote]

This might work.

set foo to "<icon>34</icon>"
set num to text 7 thru -8 of foo

– Rob

Close, now it returns “con>34” as the “num” variable. I think that I just have to tweak around with the numbers a little. If I get it I’ll let y’all know, otherwise keep any suggestions coming. Thanks!

Got it! Thanks for the input, for some reason it worked like so:


set num to text 11 thru -8 of iconparagraph

This is the vanilla AppleScript routine I use to get substrings based on start and end delimiters:

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Given xxxx, I don’t see how it works but I’m glad that it does. There must be more to the string than is displayed on this forum.

– Rob

I think that it is treating the <, >, and / characters as multiple characters, in ASCII or something like that. There isn’t anything more to the string that I didn’t post.

The only caveat with this script, jonn, is if the end delim appears in the string before the start delim, resulting in a different substring being returned. Admittedly I can’t think of a legitimate case off-hand, but it’s possible and therefore worth noting.

A slightly more robust version of your code would be:


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

In this case it uses TIDs to find the offset of the end_delim in the second text item after stripping everything prior to the first start_delim.

You are right but there is still a problem in your code in the case that the start delimiter is not found in the text in which case there will be no text item 2 so I amended mine further:

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Finally (hopefully), here’s one more version with an extra parameter to optionally return the delimiters (if they are, in fact, found):

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Camelot, here’s a slight revision of your version that accounts for the fact that the delimiters may not be part of the string:

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Thanks for all the input everybody, I used the latest routine from Jon and it works great! Thanks!