Need help editing this applescript

Discussion in 'Mac Programming' started by Dr Kevorkian94, Sep 25, 2011.

  1. Dr Kevorkian94 macrumors 68020

    Joined:
    Jun 9, 2009
    Location:
    SI, NY
    #1
    Well long story short i found some apple script to display current spotify tack info, it was only the song and artist but i was able to put in the current time and the album. But the current time has a lot of decimal places can i get rid of them somehow only leaving the whole number? here is the pic of the script:
     

    Attached Files:

  2. Red Menace macrumors 6502

    Joined:
    May 29, 2011
    Location:
    Littleton, Colorado, USA
    #2
    You can coerce the number to an integer, or if you want to round in a particular way you can use Standard Addition's round command, for example

    Code:
    set ttime to (round ttime rounding as taught in school)
     
  3. Dr Kevorkian94 thread starter macrumors 68020

    Joined:
    Jun 9, 2009
    Location:
    SI, NY
    #3
    Worked perfectly thank you so much! Not that it matters that much but that is is in seconds (as is the duration) can i somehow put it into minutes or divide that number by 60 to get it in minutes,like (3:26/4:36)?
     
  4. Red Menace macrumors 6502

    Joined:
    May 29, 2011
    Location:
    Littleton, Colorado, USA
    #4
    There are pre-defined constants for the number of seconds in a day, hour, etc that you can use, so it is just a matter of formatting your text as desired. The following bit of shorthand (OK, the statement itself is a bit long) will convert to a text string in the format mm:ss (it wraps at 60 minutes)

    Code:
    set ttime to (round ttime rounding as taught in school)
    tell (10000 + 100 * (ttime mod hours div minutes) + (ttime mod minutes)) as text to set ttime to (text -4 thru -3) & ":" & (text -2 thru -1)
     
  5. Dr Kevorkian94 thread starter macrumors 68020

    Joined:
    Jun 9, 2009
    Location:
    SI, NY
    #5
    yea i tried this before asking and i forgot to put some things in thanks
     

Share This Page