minutes is how many hours in applescript

Discussion in 'Mac Programming' started by bob5731, Jan 25, 2010.

  1. bob5731 macrumors member

    Joined:
    Jun 27, 2008
    #1
    minutes is how many hours in applescript

    Code:
    set mins to ""
    display dialog "Enter Mins to HR" default answer mins
    set mins to text returned of result
    set answer to mins / 60
    display dialog answer
     
  2. GimmeSlack12 macrumors 603

    GimmeSlack12

    Joined:
    Apr 29, 2005
    Location:
    San Francisco
    #2
    I believe Applescript takes integers as seconds, therefore 3600 seconds = 1 hour.
     
  3. bob5731 thread starter macrumors member

    Joined:
    Jun 27, 2008
    #3
    can you all fix the code.
    it is not for school.
     
  4. mysterytramp macrumors 65816

    mysterytramp

    Joined:
    Jul 17, 2008
    Location:
    Maryland
    #4
    What purpose is HR? You calculate then never use it.

    mt
     
  5. bob5731 thread starter macrumors member

    Joined:
    Jun 27, 2008
  6. mysterytramp macrumors 65816

    mysterytramp

    Joined:
    Jul 17, 2008
    Location:
    Maryland
    #6
    What is there to fix? It seems to work, that is, if by working it's supposed to put up a dialog of a decimal.
     
  7. bob5731 thread starter macrumors member

    Joined:
    Jun 27, 2008
  8. mysterytramp macrumors 65816

    mysterytramp

    Joined:
    Jul 17, 2008
    Location:
    Maryland
    #8
    Hope you get an A

    Code:
    on twodigit(f)
    	if f < 10 then
    		return "0" & f as string
    	else
    		return f
    	end if
    end twodigit
    
    
    
    set mins to 0
    display dialog "Convert total minutes to HH:MM" default answer mins
    set mins to text returned of result
    set H to mins div 60
    set M to mins mod 60
    
    set Hstring to twodigit(H)
    set Mstring to twodigit(M)
    display dialog Hstring & ":" & Mstring
     

Share This Page