Solved

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

Posted on 2006-07-20
3
240 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
  • 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Perl Awk Need Help 3 129
How do you programatically show and hide the Windows 10 On-Screen-Keyboard? 3 804
sum13 challenge 24 123
Is there a simple front-end menu system. 9 104
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

827 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