Hello there,
Sorry to bother you with such questions, but here is my problem.
My grand-uncle and grand-aunt have recently received their first mac. One of the main use will be genealogy. They use a *nix tool for that, and for the while, they have to use a xterm to launch a script, then have to use a web browser (with an address like http://localhost:portnumber/). But xterm is quite hard to use - just quitting is a mess. So I’d like to write a little script for them which will · Launch the shell script · Open a browser (say, Safari) at the right page So they just have to launch the AppleScript.
But I don’t want the script to open a thousand Safari window. Let’s say that it will firstly try find if a document is already on the right page, if not found, then try to find a document with no page laden, and if still not found, open a new document. It then load the right URL in the chosen window.
The problem is how to detect if a document’s URL is already right. If one’s URL is http://localhost:portnumber/a/long/but/nice/path/, I’d like the Script to make the window in front, without changing the UR nor opening a new window.
The current version is following.
do shell script "/Volumes/Documents/Users/dou/Documents/tst_script"
tell application "Safari"
activate
set gwserver to "http://localhost:631/" as string
set search to true
repeat with i from 1 to count each document
if search then
set current_document to item i of documents
if not (exists URL of current_document) then
set URL of current_document to gwserver
set search to false
else
-> string extraction would be great in the next line
if URL of current_document = gwserver then
set search to false
end if
end if
end repeat
if search then
set current_document to make new document
set URL of current_document to gwserver
end if
end tell
Could you please help ? Thanks.
And sorry about the English, but, you know, we French have trouble with foreign languages… :oops: