SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Mar 2002
    Location
    United States
    Posts
    193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Formatting Javascript - simple question

    This is a script which outputs the currently playing info for iTunes 4 then turns it into an image and finally uploads it to the Internet. My question comes in the formatting of the output.

    Code:
    function running() {
    	return appleScript('tell application "System Events"\nreturn number of (application processes whose name is equal to "iTunes")\nend tell\n');
    }
    
    function tell(command) {
    	return appleScript('tell application "iTunes"\n' + command + '\nend tell\n');
    }
    
    function state() {
    	return tell('return player state as string');
    }
    
    function write(artist, album, title) {
    	var target = resolvePath(preferences.target.value);
    	runCommand('echo "' + artist + '" > ' + target + ';' +
    		'echo "' + album + '" >> ' + target + ';' +
    		'echo "' + title + '" >> ' + target);
    }
    
    function update() {
    	if (running() != 0 && state() != 'stopped') {
    		var artist = tell('return artist of current track');
    		var album = tell('return album of current track');
    		var title = tell('return name of current track');
    		write(artist, album, title);
    	} else {
    		write('Nothing is currently being played.', '', '');
    	}
    }
    
    update();
    That outputs this:

    Matchbox Twenty
    Yourself or Someone Like You
    Push
    I want all the information to be displayed on one line, and in this format:

    Matchbox Twenty's "Push"
    Is this possible?

  2. #2
    SitePoint Addict
    Join Date
    Mar 2002
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Collect all the output strings into a global variable string and output that.

    Nick
    All4YourPC for all your PC needs. Custom software.
    Websites. Web marketing. Training.
    http://members.aol.com/nickjc67

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2002
    Location
    United States
    Posts
    193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem is, I have no idea how to do that.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •