在applescript中大于或等于怪异

在applescript中大于或等于怪异,applescript,Applescript,我在applescript中有一行: if start_period ≤ currentDay and currentDay ≤ end_period then --create the appointment 这是开始时段=1和结束时段=15时的结果: tell application "AppleScript Editor" display dialog "Current day: 1" --> {button returned:"OK"}

我在applescript中有一行:

    if start_period ≤ currentDay and currentDay ≤ end_period then

--create the appointment
这是开始时段=1和结束时段=15时的结果:

    tell application "AppleScript Editor"
    display dialog "Current day:  1"
        --> {button returned:"OK"}
end tell
tell application "iCal"
    make new event at end of calendar "Manpower" with properties {summary:"CD", start date:date "Sunday, January 1, 2012 12:00:00 AM", end date:date "Sunday, January 1, 2012 12:00:00 AM", allday event:true}
        --> event id "D6FC11E3-17EB-4F49-8491-ECF8F08E5B56" of calendar id "7DC7F2B9-EF4C-4BFC-9D25-6061D71704F0"
end tell
tell application "AppleScript Editor"
    display dialog "Current day:  2"
        --> {button returned:"OK"}
    display dialog "Current day:  3"
        --> {button returned:"OK"}
    display dialog "Current day:  4"
        --> {button returned:"OK"}
    display dialog "Current day:  5"
        --> {button returned:"OK"}
    display dialog "Current day:  6"
        --> {button returned:"OK"}
    display dialog "Current day:  7"
        --> {button returned:"OK"}
    display dialog "Current day:  8"
        --> {button returned:"OK"}
    display dialog "Current day:  9"
        --> {button returned:"OK"}
    display dialog "Current day:  10"
        --> {button returned:"OK"}
end tell
tell application "iCal"
    make new event at end of calendar "Manpower" with properties {summary:"Duty", start date:date "Tuesday, January 10, 2012 12:00:00 AM", end date:date "Tuesday, January 10, 2012 12:00:00 AM", allday event:true}
        --> event id "5C52EFAA-287A-4879-B549-FDDD225853DA" of calendar id "7DC7F2B9-EF4C-4BFC-9D25-6061D71704F0"
end tell
tell application "AppleScript Editor"
    display dialog "Current day:  11"
        --> {button returned:"OK"}
然后从11点开始,我认为它应该这样做。谁能告诉我我做错了什么

谢谢你的帮助

罗兰

编辑(添加代码):


问题在于,如果开始时间为,则将这一行中的数字文本进行比较≤ 当前日期和当前日期≤ 然后结束时段

将currentDay设置为dutyTwo的文本项1作为字符串
-->currentDay是字符串

将开始时段设置为(开始日)
-->开始时段为整数,结束时段为整数


使用此
将currentDay设置为(dutyTwo的文本项1)作为整数

循环停止,因为达到了条件。不看剧本就不可能给你确切的原因。发布脚本后,日志在这种情况下没有帮助。
set theDoc to (choose file with prompt "Choose source files" with multiple selections allowed without invisibles) as string

-- choose destination folder
set sourceFolder to choose folder with prompt "Choose a folder to contain files:"

display dialog "Date to begin import" default answer "First Day..."
set start_day to date (text returned of result)

display dialog "Date to complete import" default answer "Last Day…"
set end_day to date (text returned of result)

--remove all current appointments
tell application "iCal"
    set theCalendars to title of every calendar
    tell calendar "Manpower" -- your calendar here
        set theEvents to every event whose (start date is greater than or equal to start_day) and (start date is less than or equal to the end_day)

        repeat with current_event in theEvents
            delete current_event
        end repeat
    end tell
end tell

--display dialog "delete complete"

--set the returned_events to every event of calendar 1 ¬ 
--whose (start date is greater than or equal to start_day) and ¬ 
--(start date is less than or equal to the end_day) 
--remove all csv files from source folder
tell application "Finder"
    delete (files of sourceFolder)
end tell


--Get user name
display dialog "What's your last name?" default answer "My last name is..."
set theName to (text returned of result)

--save csv files
tell application "Microsoft Excel"
    open file theDoc
    tell workbook 1
        repeat with a from 1 to 12
            tell sheet a
                set myFileName to sourceFolder & "month" & a & ".csv" as string

                save in myFileName as CSV file format
            end tell
        end repeat
        close without saving
    end tell
end tell

    repeat with b from 1 to 12
    set start_month to (month of (start_day)) * 1
    set end_month to (month of (end_day)) * 1

    if b ≥ start_month then
        if b ≤ end_month then

            tell application "Finder"

                set curFileName to (sourceFolder as text) & "month" & (b as text) & ".csv"
                set workingFile to read file (curFileName)

                -- break the file down into rows
                set AppleScript's text item delimiters to {ASCII character 13}
                -- theContents is a list of all the rows
                set theContents to text items of workingFile as list
            end tell


            --rowTwo is the list of names
            set rowTwo to item 2 of theContents
            set AppleScript's text item delimiters to {","}
            set rowParts to (every text item in rowTwo)

            --Find the name entered by the user and return its number (nameNumber
            set nameNumber to findName(rowParts, theName)

            try

                repeat with j from 1 to the count of theContents

                    if j > 2 then
                        set AppleScript's text item delimiters to {","}
                        set currentItem to text item j of theContents
                        set currentRow to text items of currentItem

                        set rowCount to count (currentRow)

                        --if we have passed the first two row (pass info and column headers) then start gathering duty information
                        if rowCount > 2 then
                            --dutyStat is duty status
                            set dutyStat to item nameNumber of currentRow
                            set statCount to count (dutyStat)


                            set dutyDate to text item 1 of currentRow
                            set myCount to count (dutyDate)

                            --to ensure that we have an actual date in the field
                            if myCount > 4 then

                                set AppleScript's text item delimiters to "-"
                                set dutyDateT to text items of dutyDate as list
                                set dutyTwo to text items of dutyDateT
                                set datePartC to count (dutyDateT)
                                set currentDay to text item 1 of dutyTwo as string
                                set currentMonth to text item 2 of dutyTwo as string
                                set AppleScript's text item delimiters to {","}
                                set dutyDateToo to date ((b as text) & " " & currentDay & " " & "2012")
                                set start_period to (day of (start_day))
                                set end_period to (day of (end_day))

                                display dialog "Current day:  " & currentDay
                                --if (currentDay as text) ≥ (start_period as text) then
                                --display dialog "Larger than the start.  Current day:  " & currentDay & ".  Start period:  " & (start_period as text)
                                --if (currentDay as int) ≤ (end_period as text) then
                                --display dialog "smaller than the complete…creating appt Current day:  " & currentDay & ".  End period:  " & (end_period as text)
                                if start_period ≤ currentDay and currentDay ≤ end_period then
                                    --create the appointment
                                    tell application "iCal"
                                        tell calendar "Manpower"

                                            make new event at end with properties {summary:dutyStat, start date:dutyDateToo, end date:dutyDateToo, allday event:true}
                                        end tell
                                    end tell
                                    --end if
                                end if
                            end if
                        end if
                    end if

                end repeat
            on error errMsg
                display dialog "ERROR on date:  " & item 1 of currentRow & ".  The error is:  " & errMsg


            end try
        end if
    end if
end repeat

    on findName(rowList, theItem)
    repeat with i from 1 to the count of rowList
        if item i of rowList is theItem then return i

    end repeat

end findName