Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- on make_numlist(charlist)
- set numlist to {}
- repeat with i1 from 1 to (count of charlist)
- set numlist to numlist & (ASCII number (item i1 of charlist))
- end repeat
- return numlist
- end make_numlist
- on make_string(numlist)
- set charlist to ""
- repeat with i1 from 1 to (count of numlist)
- set charlist to charlist & (ASCII character (item i1 of numlist))
- end repeat
- return charlist
- end make_string
- on window_shift(numlist, tol, int)
- set idx1 to 1
- set idx2 to 10
- set temp to 0
- if (int < 1) then
- set int to 1
- end if
- repeat
- --display dialog (idx1 as string)
- set idx2 to idx1 + (random number from -tol to tol)
- if ((idx2 > (count of numlist)) or (idx2 ≤ 0)) then
- -- invalid, do nothing
- else
- set temp to (item idx1 of numlist)
- set (item idx1 of numlist) to (item idx2 of numlist)
- set (item idx2 of numlist) to temp
- end if
- if (idx1 = (count of numlist)) then
- exit repeat
- else
- if ((random number from 1 to int) ≤ 1) then
- set idx1 to idx1 + 1
- end if
- end if
- end repeat
- return numlist
- end window_shift
- on paulstretch(pre_stretch)
- --send_debug("~ps " & (pre_stretch as string))
- set pre_stretch to remove_html_code(pre_stretch)
- set repeat_size to repeat_amount(count of pre_stretch)
- set post_stretch to ""
- set pre_stretch_val to (string_char_value(pre_stretch))
- set sum1 to 0
- if repeat_size < 1 then
- return ""
- end if
- repeat with i1 from 1 to (count of pre_stretch)
- set add1 to (pre_stretch_val) / (repeat_size * (string_char_value(item i1 of pre_stretch)))
- repeat while sum1 < 1
- set post_stretch to post_stretch & (item i1 of pre_stretch)
- set sum1 to sum1 + add1
- end repeat
- set sum1 to sum1 - (1 + add1)
- end repeat
- set num_stretch to make_numlist(post_stretch)
- set num_stretch to window_shift(num_stretch, 5, 2)
- set post_stretch to make_string(num_stretch)
- return post_stretch
- end paulstretch
- on remove_html_code(html_)
- --http://www.ascii.cl/htmlcodes.htm
- set txtout to ""
- set html_list to {¬
- {"quot;", "\""}, ¬
- {"apos;", "'"}, ¬
- {"lt;", "<"}, ¬
- {"gt;", ">"}, ¬
- {"amp;", "&"}}
- set check to ""
- set i to 1
- repeat while i ≤ (count of html_)
- if (item i of html_ is "&") then
- --display dialog "found something at " & (i as string)
- repeat while ((item i of html_ is not ";") and (i < (count of html_)))
- set i to i + 1
- set check to (check & (item i of html_))
- end repeat
- --display dialog "check is " & check
- repeat with j from 1 to (count of html_list)
- if (item 1 of (item j of html_list)) is check then
- --display dialog "found it at " & (j as string) & " which is " & (item 2 of (item j of html_list))
- set txtout to txtout & (item 2 of (item j of html_list))
- exit repeat
- end if
- end repeat
- set check to ""
- else
- set txtout to txtout & (item i of html_)
- end if
- set i to i + 1
- end repeat
- return txtout
- end remove_html_code
- on repeat_amount(size1)
- set botmax to 453
- set total_length to upper_circle((botmax - size1), botmax)
- if total_length < 0 then
- return -1
- else
- return total_length
- end if
- end repeat_amount
- on abs1(in1)
- if in1 ≥ 0 then
- return in1
- else
- return -in1
- end if
- end abs1
- on upper_circle(x, r)
- if abs1(x) > r then
- return -1
- end if
- return (-(x ^ 2) + r ^ 2) ^ 0.5
- end upper_circle
- on string_char_value(string1)
- set return_val to 0
- set cvlist to {¬
- {"A", 8}, ¬
- {"B", 3}, ¬
- {"C", 3}, ¬
- {"D", 3}, ¬
- {"E", 10}, ¬
- {"F", 3}, ¬
- {"G", 3}, ¬
- {"H", 3}, ¬
- {"I", 7}, ¬
- {"J", 3}, ¬
- {"K", 3}, ¬
- {"L", 4}, ¬
- {"M", 4}, ¬
- {"N", 3}, ¬
- {"O", 8}, ¬
- {"P", 5}, ¬
- {"Q", 2}, ¬
- {"R", 5}, ¬
- {"S", 6}, ¬
- {"T", 5}, ¬
- {"U", 8}, ¬
- {"V", 3}, ¬
- {"W", 4}, ¬
- {"X", 2}, ¬
- {"Y", 6}, ¬
- {"Z", 2}, ¬
- {" ", 1}}
- --set foundswitch to false
- repeat with i1 from 1 to (count of string1)
- repeat with i2 from 1 to (count of cvlist)
- if (item 1 of (item i2 of cvlist)) = (item i1 of string1) then
- set return_val to return_val + (item 2 of (item i2 of cvlist))
- exit repeat
- end if
- end repeat
- end repeat
- if return_val > 0 then
- return return_val
- else
- --error here
- return 1
- end if
- end string_char_value
Advertisement
Add Comment
Please, Sign In to add comment