Applescript and repeat?

Discussion in 'Mac Programming' started by marbo, Mar 30, 2009.

  1. macrumors newbie

    Joined:
    Mar 30, 2009
    #1
    Hello,

    Can any one tell me how i print all information on this loop?

    Its take sheculed program on eyetv.

    Here is my code.

    Code:
    tell application "EyeTV"
    	set proglist to every program whose start time is greater than (current date)
    	set n to count of proglist
    	if n is 0 then
    		return "Ei ajastettuja ohjelmia."
    	else
    		repeat with po in proglist
    			return "Ajastettu: " & name of po & " " & start time of po
    		end repeat
    	end if
    end tell
    
    I hope some one can help me. And im sorry if my english is bad.
     
  2. macrumors newbie

    Joined:
    Mar 30, 2009
    #2
    Marbo,

    You can store the result of each iteration of the repeat-loop in a set, call it ListOfResults. Then return ListOfResults at the end of the program.

    Consider the following implementation:
    Code:
    (* The list of television programs whose start time is greater than the current date and time (default: {} - the empty set). *)
    set the ListOfResults to {} 
    tell application "EyeTV"
    	set proglist to every program whose start time is greater than (current date)
    	set n to count of proglist
    	if n is 0 then
    		return "Ei ajastettuja ohjelmia."
    	else
    		repeat with po in proglist
    			set entry to "Ajastettu: " & name of po & " " & start time of po
    			set the ListOfResults to the ListOfResults & entry as list
    		end repeat
    	end if
    end tell
    return the ListOfResults
    
     
  3. thread starter macrumors newbie

    Joined:
    Mar 30, 2009
    #3
    Thanks, but now it i cant print with that info on my web page. :/

    Oh, sorry its working :) Thank you.
     

Share This Page