Solved

Apple Script that directs users to a page if a code is entered that is not specified

Posted on 2006-07-20
3
242 Views
Last Modified: 2013-12-26
     Im using the following script to ask users to enter a code and direct them a local HTML page according to what they enter.  what I need to do now is direct them to a "default page" if the user enters a code that I have not specified, a "catch all."

so if a user entered "gfkhjygfk" I would send them to "default.html."  The code I have now does not do anything if an unrecognized code is entered, it just just closes.

I would also like to a version that could display an error message such as " you have entered an un recognizable code, please try again"

here is part of the code I have so far:

        if gowhere is equal to " " then
            open location "file:///site/index01.html"
      else if gowhere is equal to "aaa" then
            open location "file:///site/index02.html"
      else if gowhere is equal to "bbb" then
            open location "file:///site/index02.html"
      else if gowhere is equal to "ccc" then
            open location "file:///site/index003.html"
      else if gowhere is equal to "admin" then
            open location "file:///site/admin/index04.html"
      end if
0
Comment
Question by:arobquinna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 24

Accepted Solution

by:
slyong earned 500 total points
ID: 17150836
Hi,

This is the modified script for you:

set iamnotdone to true
tell application "Finder"
  activate
  display dialog "Where do you want to go today?" default answer ""
  set gowhere to text returned of result
end tell

repeat while iamnotdone
  tell application "Safari"
    activate
    if gowhere is equal to "apple" then
      open location "http://www.apple.com/"
      set iamnotdone to false
    else if gowhere is equal to "yahoo" then
      open location "http://www.yahoo.com/"
      set iamnotdone to false
    else if gowhere is euqal to "google" then
      open location "http://www.google.com/"
      set iamnotdone to false
    end if
  end tell

  if iamnotdone then
    tell application "Finder"
      activate
      display dialog "I can't send you there, try again" default answer ""
      set gowhere to text returned of result
    end tell
  end if
end repeat
0
 

Author Comment

by:arobquinna
ID: 17150860
yes!! that is it bro!

Thanks again!!
0
 
LVL 24

Expert Comment

by:slyong
ID: 17150865
no worries glad to be of help
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question