ดังนั้นฉันจึงพยายามสร้างสคริปต์ง่ายๆที่จะใช้ไฟล์เพื่อเก็บจำนวนเต็ม เมื่อสคริปต์ถูกเรียก (ในกรณีของฉันเป็นส่วนหนึ่งของมาโครคีย์บอร์ด) มันจะดรอปจำนวนเต็มปัจจุบัน (โดยที่ฉันกำลังพิมพ์) ด้วยจำนวนที่ต้องการของศูนย์นำหน้า จากนั้นมันจะเพิ่มจำนวนเต็ม (ไม่มีศูนย์นำหน้า) แล้วเขียนกลับเข้าไปในไฟล์
ส่วนศูนย์นำทำงานได้ แต่สำหรับชีวิตของฉันฉันไม่สามารถหาวิธีเก็บค่าของตัวแปร 'counter' ในไฟล์เพื่อที่ในภายหลังเมื่อฉันเรียกสคริปต์อีกครั้ง ปิด
ความช่วยเหลือใด ๆ ที่จะได้รับการชื่นชมอย่างมาก.
นี่คือข้อความแสดงข้อผิดพลาดที่ฉันได้รับ:
    error "Can’t make \"z:Users:zachphillips:Dev:AppleScripts:counter\"  
    into type file." number -1700 from
    "z:Users:zachphillips:Dev:AppleScripts:counter" to file
และนี่คือรหัส:
    set theFile to "z:Users:zachphillips:Dev:AppleScripts:counter"
        open for access theFile
        set fileContents to read theFile
        close access theFile
        set counter to fileContents as integer
        on add_leading_zeros(counter, max_leading_zeros)
        set the threshold_number to (10 ^ max_leading_zeros) as integer
        if counter is less than the threshold_number then
            set the leading_zeros to ""
            set the digit_count to the length of ((counter div 1) as string)
            set the character_count to (max_leading_zeros + 1) - digit_count
            repeat character_count times
                set the leading_zeros to (the leading_zeros & "0") as string
            end repeat
            return (leading_zeros & (counter as text)) as string
        else
            return counter as text
        end if
    end add_leading_zeros
    add_leading_zeros(counter, 2)
    open for access newFile with write permission
    set eof of newFile to 0
    write counter + 1 to newFile
    close access newFile