Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Dr Kevorkian94

macrumors 68020
Original poster
Jun 9, 2009
2,179
83
SI, NY
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:
 

Attachments

  • Screen Shot 2011-09-25 at 7.56.23 PM.png
    Screen Shot 2011-09-25 at 7.56.23 PM.png
    36.9 KB · Views: 138
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)
 
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)

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)?
 
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)
 
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)

yea i tried this before asking and i forgot to put some things in thanks
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.