AppleScript Help

Discussion in 'Mac Programming' started by ryandask8s, Jul 15, 2008.

  1. ryandask8s macrumors newbie

    ryandask8s

    Joined:
    Jul 15, 2008
    #1
    Code:
    --Script By Ryan
    set temp to display dialog "What is you age?" default answer "" buttons {"Cancel", "Info", "That's my age"} default button 3
    set answer to button returned of temp
    if answer is equal to "info" then
    	say "Age converter created by Ryan"
    end if
    set resultAge to text returned of temp
    set Male_life to 72.95 - resultAge
    set Female_life to 79.67 - resultAge
    set ageMonths to resultAge * 12
    set ageDays to resultAge * 365
    set ageWeeks to ageDays / 7
    set ageHours to ageWeeks * 168
    set answer to button returned of temp
    if answer is equal to "That's my age" then
    	display dialog "Months: " & ageMonths
    	display dialog "Days: " & ageDays
    	display dialog "Weeks: " & ageWeeks
    end if
    set Gender_List to choose from list {"Male", "Female"} with prompt "What is you gender?"
    if answer is equal to "Male" then
    	display dialog "You are expected to live this many more years: " & Male_life
    end if
    if answer is equal to "Female" then
    	display dialog "You are expected to live this many more years: " & Female_life
    end if
    
    It is fine up until after you choose your gender. Can someone please help me so it predicts your life expectancy? :p Also can someone make it so when you press info it loops back to
    Code:
    set temp to display dialog "What is you age?" default answer "" buttons {"Cancel", "Info", "That's my age"}
    (I have no idea why I'm doing it i just started an hour ago so i just kept going)
     
  2. toddburch macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #2
    Code:
    set Gender_List to choose from list {"Male", "Female"} with prompt "What is you[color=red]r[/color] gender?"
    if [color=blue]answer[/color] is equal to "Male" then
    	display dialog "You are expected to live this many more years: " & Male_life
    end if
    
    You didn't set answer to the result of the user's choice from the list.

    Todd
     

Share This Page