• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Slow code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Slow code


  • Subject: Slow code
  • From: Brian Christmas <email@hidden>
  • Date: Mon, 11 Sep 2017 15:42:42 +1000

G’day scripters

Is there any method of speeding up this handler, please? ATM  it’s taking 17
seconds.

Regards

Santa

        on checkthecode1()
                set (my EnteringCode) to true
                say "Please wait" without waiting until completion
                set l to ""
                set f1 to 19480822
                set f2 to 19471206
                set m to "239360062088" as text
                random number 1.0E+11 to 9.99999999999E+11 with seed
11111111111111 # Not real seed
                repeat with x from 1 to 10000
                        set y to x as text
                        set f1 to f1 + (random number from 10 to 100)
                        set f2 to f2 + (random number from 10 to 100)
                        set m to random number from 1.00000000001E+11 to
9.99999999999E+11 as text
                        set temp to number_to_string(m)
                        set l to l & f1 & "-" & f2 & "-" & characters 1 through
6 of temp & "-" & characters 7 through -1 of temp & return as text
                end repeat
                set (my PassCodes) to l
                set (my windowMainFlag) to false
                windowMainMM's orderOut:me
                windowCode's makeKeyAndOrderFront:me
                set focus of Entry1 to true
        end checkthecode1

        on number_to_string(this_number)
                set this_number to this_number as string
                if this_number contains "E+" then
                        set x to the offset of "." in this_number
                        set y to the offset of "+" in this_number
                        set z to the offset of "E" in this_number
                        set the decimal_adjust to characters (y - (length of
this_number)) thru ¬
                                -1 of this_number as string as number
                        if x is not 0 then
                                set the first_part to characters 1 thru (x - 1)
of this_number as string
                        else
                                set the first_part to ""
                        end if
                        set the second_part to characters (x + 1) thru (z - 1)
of this_number as string
                        set the converted_number to the first_part
                        repeat with i from 1 to the decimal_adjust
                                try
                                        set the converted_number to ¬
                                                the converted_number &
character i of the second_part
                                on error errmsg number errnum
                                        set the converted_number to the
converted_number & "0"
                                end try
                        end repeat
                        return the converted_number
                else
                        return this_number
                end if
        end number_to_string


Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Slow code
      • From: Takaaki Naganoya <email@hidden>
  • Prev by Date: Re: Change a aJSON list to an Applescript list?
  • Next by Date: Re: Slow code
  • Previous by thread: 2 tricky questions
  • Next by thread: Re: Slow code
  • Index(es):
    • Date
    • Thread