Advertisement
rccharles

workwithasc

Apr 28th, 2019
1,100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (*
  2.   This applescript converts clipboard input into a format suited for pasting into an ASC reply.  I observed that my copies into an
  3.   ASC reply were not formated that well.  I observed that copies from a web browser were formated much better.  I went about
  4.   adjust a clipboard copy to the format expected by a web browser for best results.
  5.  
  6.  This applescript accepts the clipboard in either
  7.  -- plan text upon which the text is converted to HTML.  Conversion is limitted to adding paragraphs and links.
  8.  -- HTML which which is marked at HTML.  The detection of HTML is done by finding four less thans < and four greater thans >.
  9.      Caveat emptor.  
  10.  
  11.  to use:
  12.  1) copy command + c what data you want to convert
  13.  2) run this applascript
  14.  3) paste command + V into an ASC reply
  15.  
  16.  I have tested in Waterfox 56.2.9 in Yosemite.  I assume the process will work with other web browsers and other versions of macOS.
  17.  
  18.  Save as an Application Bundle.  Don't check anything.
  19.  
  20.  Debugging...
  21.  
  22.   Shows how to debug via on run path. Shows items added to folder. Shows log statement.
  23.  
  24.    It is easier to diagnose problems with debug information. I suggest adding log statements to your script to see what is going on.  Here is an example.
  25.  
  26.    For testing, run in the Script Editor.
  27.   1) Click on the Event Log tab to see the output from the log statement
  28.   2) Click on Run
  29.  
  30. Author: rccharles
  31.  
  32.  Copyright 2019 rccharles  
  33.  
  34.        Permission is hereby granted, free of charge, to any person obtaining a copy  
  35.        of this software and associated documentation files (the "Software"), to deal  
  36.        in the Software without restriction, including without limitation the rights  
  37.        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell  
  38.        copies of the Software, and to permit persons to whom the Software is  
  39.        furnished to do so, subject to the following conditions:  
  40.  
  41.        The above copyright notice and this permission notice shall be included in all  
  42.        copies or substantial portions of the Software.  
  43.  
  44.        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  
  45.        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  
  46.        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE  
  47.        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  
  48.        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,  
  49.        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE  
  50.        SOFTWARE.  
  51.  
  52.  *)
  53.  
  54. -- Gets invoked here when you run in AppleScript editor.
  55.  
  56. on run
  57.   global debug
  58.   set debug to 2
  59.   (*  
  60.   set the clipboard to "\"Effective defenses 111 threats\" by John Galt
  61. https://discussions.apple.com/docs/DOC-8841
  62. \"Avoid phishing emails 222 and other scams\"
  63.  
  64. https://support.apple.com/en-ca/HT204759
  65.  
  66.  
  67. blank lines
  68. also,see:http://www.google.com/ seeing again:http://www.google.com"
  69. *)
  70.  
  71.   set theList to clipboard info
  72.   printClipboardInfo(theList)
  73.  
  74.   try
  75.     set clipboardData to (the clipboard as text)
  76.     if debug ≥ 3 then
  77.       log "class clipboardData is " & class of clipboardData
  78.       log "calling displayHeader."
  79.     end if
  80.     displayHeader("clipboardData", clipboardData)
  81.   on error errStr number errorNumber
  82.     log "===> We didn't find data.   errStr is " & errStr & " errorNumber is " & errorNumber
  83.     return
  84.   end try
  85.   common(clipboardData)
  86.  
  87. end run
  88.  
  89. -- Folder actions.
  90. -- Gets invoked here when something is dropped on the folder that this script is monitoring.
  91. -- Right click on the folder to be monitored. services > Folder Action Settup...
  92.  
  93. on adding folder items to this_folder after receiving added_items
  94.  
  95.   --common(added_items)
  96.  
  97. end adding folder items to
  98.  
  99.  
  100. -- Gets invoked here when something is dropped on this AppleScript icon
  101.  
  102. on open dropped_items
  103.   global debug
  104.   set debug to 2
  105.  
  106.   log "class of dropped_items is " & class of dropped_items
  107.  
  108.   set totalFileData to ""
  109.   repeat with droppedItem in dropped_items
  110.     log "The droppedItem is "
  111.     log droppedItem
  112.     log "class = " & class of droppedItem
  113.     try
  114.       set theFile to droppedItem as string
  115.       set theFile to open for access file theFile
  116.       set allOfFile to read theFile
  117.       close access theFile
  118.     on error theErrorMessage number theErrorNumber
  119.       log theErrorMessage & "error number " & theErrorNumber
  120.       close access theFile
  121.     end try
  122.  
  123.     displayHeader("read from file ( allOfFile )", allOfFile)
  124.     set totalFileData to totalFileData & allOfFile
  125.   end repeat
  126.  
  127.   common(totalFileData)
  128.  
  129. end open
  130.  
  131. -- ------------------------------------------------------
  132. on common(clipboardData)
  133.   global debug
  134.   set lf to character id 10
  135.   -- don't let Windoze confuse us. convert Return LineFeed to lf
  136.   set clipboardData to alterString(clipboardData, return & lf, lf)
  137.   -- Write a message into the event log.
  138.   log "  --- Starting on " & ((current date) as string) & " --- "
  139.  
  140.   -- figure out what type of data we have: plan text or html text.
  141.   set paraCount to textToList(clipboardData, "<")
  142.   set endparaCount to textToList(clipboardData, ">")
  143.   if (count of paraCount)4 and (count of endparaCount)4 then
  144.     log "found HTML input"
  145.     typeHTML(clipboardData)
  146.   else
  147.     log "found Text input"
  148.     typeText(clipboardData)
  149.  
  150.   end if
  151.  
  152.   -- return code
  153.   return 0
  154. end common
  155.  
  156. -- ------------------------------------------------------
  157. (*
  158. alterString
  159.   thisText is the input string to change
  160.   delim is what string to change.  It doesn't have to be a single character.
  161.   replacement is the new string
  162.  
  163.   returns the changed string.
  164. *)
  165.  
  166. on alterString(thisText, delim, replacement)
  167.   set resultList to {}
  168.   set {tid, my text item delimiters} to {my text item delimiters, delim}
  169.   try
  170.     set resultList to every text item of thisText
  171.     set text item delimiters to replacement
  172.     set resultString to resultList as string
  173.     set my text item delimiters to tid
  174.   on error
  175.     set my text item delimiters to tid
  176.   end try
  177.   return resultString
  178. end alterString
  179.  
  180. -- ------------------------------------------------------
  181. (*
  182.   Return the text to the right of theToken.
  183. *)
  184. on answerAndChomp(theString, theToken)
  185.   set debugging to false
  186.   set theOffset to offset of theToken in theString
  187.   if debugging then log "theOffset is " & theOffset
  188.   set theLength to length of theString
  189.   if theOffset > 0 then
  190.     set beginningPart to text 1 thru (theOffset - 1) of theString
  191.     if debugging then log "beginningPart is " & beginningPart
  192.  
  193.     set chompped to text theOffset thru theLength of theString
  194.     if debugging then log "chompped is " & chompped
  195.     return {chompped, beginningPart}
  196.   else
  197.     set beginningPart to ""
  198.     return {theString, beginningPart}
  199.   end if
  200.  
  201. end answerAndChomp
  202.  
  203. -- ------------------------------------------------------
  204. (*
  205.   Delete the leading part of the string until and including theToken.
  206. *)
  207. on chompLeftAndTag(theString, theToken)
  208.   set debugging to false
  209.   --log text 1 thru ((offset of "my" in s) - 1) of s
  210.   --set rightString to offset of theToken in theString thru count of theString of theString
  211.   set theOffset to offset of theToken in theString
  212.   if debugging then log "theOffset is " & theOffset
  213.   set theLength to length of theString
  214.   if debugging then log "theLength is " & theLength
  215.   if theOffset > 0 then
  216.     set chompped to text (theOffset + (length of theToken)) thru theLength of theString
  217.     if debugging then log "chompped is " & chompped
  218.     return chompped
  219.   else
  220.     return theString
  221.   end if
  222. end chompLeftAndTag
  223.  
  224. -- ------------------------------------------------------
  225. (* Pump out the beginning of theString *)
  226. on displayHeader(theName, theString)
  227.   global debug
  228.   if debug ≥ 3 then
  229.     log "in displayHeader"
  230.     log theString
  231.     log length of theString
  232.   end if
  233.   log theName & " is " & text 1 thru (minimumPositiveNumber from {200, length of theString}) of theString & "<+++++++++++"
  234. end displayHeader
  235.  
  236. -- ------------------------------------------------------
  237. (*
  238.   http://krypted.com/mac-os-x/to-hex-and-back/
  239. *)
  240. on hexToString(hex)
  241.   log "in hexToString"
  242.   log "hex string is " & hex
  243.   set toUnix to "echo " & hex & " | xxd -r -p "
  244.   log "toUnix is " & toUnix
  245.   try
  246.     set fromUnix to do shell script toUnix
  247.     log "fromUnix is " & fromUnix
  248.   on error errMsg number n
  249.     log "convert hex string to string failed. " & errMsg & " with number " & n
  250.   end try
  251. end hexToString
  252.  
  253.  
  254. -- ------------------------------------------------------
  255. (*
  256.  
  257. https://stackoverflow.com/questions/55838252/minimum-value-that-not-zero
  258.        set m to get minimumPositiveNumber from {10, 2, 0, 2, 4}
  259.   log "m is " & m
  260.   set m to minimumPositiveNumber from {0, 0, 0}
  261.   log "m is " & m
  262.  
  263. *)
  264. on minimumPositiveNumber from L
  265.   local L
  266.  
  267.   if L = {} then return null
  268.  
  269.   set |ξ| to 0
  270.  
  271.   repeat with x in L
  272.     set x to x's contents
  273.     if (x < |ξ| and x ≠ 0) ¬
  274.       or |ξ| = 0 then ¬
  275.       set |ξ| to x
  276.   end repeat
  277.  
  278.   |ξ|
  279. end minimumPositiveNumber
  280.  
  281. -- ------------------------------------------------------
  282. on printClipboardInfo(theList)
  283.   log (clipboard info)
  284.   log class of theList
  285.   log "Data types on the clipboard ... "
  286.   printList("theList", theList)
  287.   log "... "
  288. end printClipboardInfo
  289.  
  290. -- ------------------------------------------------------
  291. (*
  292. print out the items in a list
  293.  
  294. *)
  295.  
  296. on printList(name, splits)
  297.   set theCount to 1
  298.   repeat with theEntry in splits
  299.     log "------- " & name & theCount & " is " & return & theEntry
  300.     set theCount to theCount + 1
  301.   end repeat
  302. end printList
  303.  
  304. -- ------------------------------------------------------
  305. (*
  306. splitTextToList seems to be what you are trying to do
  307.   thisText is the input string
  308.   delim is what to split on
  309.  
  310.   results returned in a list
  311.  
  312.   Total hack. We know splitTextToList strips of delim so add it back.
  313. *)
  314.  
  315. on splitTextToList(thisText, delim)
  316.  
  317.   set returnedList to textToList(thisText, delim)
  318.   set resultArray to {}
  319.   copy item 1 of returnedList to the end of the resultArray
  320.  
  321.   repeat with i from 2 to (count of returnedList) in returnedList
  322.     set newElement to delim & item i of returnedList
  323.     copy newElement to the end of the resultArray
  324.   end repeat
  325.  
  326.   return resultArray
  327. end splitTextToList
  328.  
  329. -- ------------------------------------------------------
  330. (*
  331.   Retrieved data between "begin" and "end" tag. Whatever is between the strings.
  332. *)
  333. on tagContent(theString, startTag, endTag)
  334.   log "in tabContent. " & " startTag is " & startTag & " endTag is " & endTag
  335.   set beginningOfTag to chompLeftAndTag(theString, startTag)
  336.   displayHeader("beginningOfTag", beginningOfTag)
  337.   set middleText to text 1 thru ((offset of endTag in beginningOfTag) - 1) of beginningOfTag
  338.   log "middleText is " & middleText
  339.   return middleText
  340. end tagContent
  341. (*
  342. textToList seems to be what you are trying to do
  343.   thisText is the input string
  344.   delim is what to split on
  345.  
  346.   returns a list of strings.  
  347.  
  348. - textToList was found here:
  349. - http://macscripter.net/viewtopic.php?id=15423
  350.  
  351. *)
  352.  
  353. on textToList(thisText, delim)
  354.   set resultList to {}
  355.   set {tid, my text item delimiters} to {my text item delimiters, delim}
  356.  
  357.   try
  358.     set resultList to every text item of thisText
  359.     set my text item delimiters to tid
  360.   on error
  361.     set my text item delimiters to tid
  362.   end try
  363.   return resultList
  364. end textToList
  365.  
  366. -- ------------------------------------------------------
  367. on typeHTML(theData)
  368.   log "in typeHTML" & return & "Try to send back utf8."
  369.  
  370.   set clipboardDataQuoted to quoted form of theData
  371.   log "quoted form is " & clipboardDataQuoted
  372.   set toUnix to "/bin/echo -n " & clipboardDataQuoted & " | hexdump -ve '1/1 \"%.2x\"'"
  373.   log "toUnix is " & toUnix
  374.   try
  375.     set fromUnix to do shell script toUnix
  376.     log "fromUnix is " & fromUnix
  377.     log "displaying original string ---"
  378.     hexToString(fromUnix)
  379.   on error errMsg number n
  380.     log "convert to hex string failed. " & errMsg & " with number " & n
  381.   end try
  382.   try
  383.     -- osascript -e "set the clipboard to «data HTML${hex}»"
  384.     --set toUnixSet to "osascript -e \"set the clipboard to «data HTML" & fromUnix & "»"
  385.     --set cbData to the clipboard as «class utf8»
  386.  
  387.     set toUnixSet to "osascript -e \"set the clipboard to «data HTML" & fromUnix & \""
  388.     log "toUnixSet is " & toUnixSet
  389.  
  390.     set fromUnixSet to do shell script toUnixSet
  391.     log "fromUnixSet is " & fromUnixSet
  392.  
  393.   on error errMsg number n
  394.     log "==> We tried to send back HTML data, but failed. " & errMsg & " with number " & n
  395.   end try
  396.   set theList2 to clipboard info
  397.   printClipboardInfo(theList2)
  398.  
  399. end typeHTML
  400.  
  401. -- ------------------------------------------------------
  402. on typeText(theData)
  403.   (*
  404.      Unix-like systems      LF   0A   \n
  405.         (Linux, macOS)
  406.                Microsoft Windows   CR LF   0D 0A    \r\n
  407.                classic Mac OS        CR    0D    \r
  408.          *)
  409.   set lf to character id 10
  410.   log "in typeText"
  411.   displayHeader("the input  ( theData )", theData)
  412.   -- Example: -- https://discussions.apple.com/docs/DOC-8841
  413.   -- locate links
  414.  
  415.   set theOutputBuffer to theData
  416.   set linkId to {"https://", "http://"}
  417.   repeat with lookForLink in linkId
  418.  
  419.     set splitOnHTTPS to splitTextToList(theOutputBuffer, lookForLink)
  420.     log "display splitOnHTTPS..."
  421.     set countOf to 1
  422.     repeat with theCurrentHTTPS in splitOnHTTPS
  423.       displayHeader("#" & countOf & " theCurrentHTTPS ", theCurrentHTTPS)
  424.       set countOf to countOf + 1
  425.     end repeat
  426.  
  427.     set buildHTML to beginning of splitOnHTTPS
  428.     log "buildHTML is " & buildHTML
  429.     -- delete the first item text
  430.     set splitOnHTTPS to rest of splitOnHTTPS
  431.     log splitOnHTTPS
  432.     set counti to 1
  433.     repeat with theCurrentHTTPS in splitOnHTTPS
  434.       -- find the end of the HTML URL aby splitting on blank or return  
  435.       -- <a href="https://discussions.apple.com/docs/DOC-8841" target="_blank">https://discussions.apple.com/docs/DOC-8841</a>    
  436.       -- text 1 thru ((offset of "my" in s) - 1) of s
  437.       -- -1 since offset return the first character "m" position count
  438.       set toUnix to "/bin/echo -n " & quoted form of theCurrentHTTPS & " | hexdump -C"
  439.       set fromUnix to do shell script toUnix
  440.       log "fromUnix is " & return & fromUnix
  441.  
  442.       -- the end of the clipboard string my end after the url, hence no " ", LF or CRLF.
  443.       -- ---- What about just return? ----
  444.       set endsWhere to {}
  445.       copy (offset of " " in theCurrentHTTPS) to the end of the endsWhere
  446.       copy (offset of lf in theCurrentHTTPS) to the end of the endsWhere
  447.       copy (offset of return in theCurrentHTTPS) to the end of the endsWhere
  448.       -- in case two links are adjacent
  449.       -- not sure what the standard might be, but I don't think there is a conflict
  450.       -- confuses thing.  http & https were still in search string.
  451.       --copy (offset of "https://" in theCurrentHTTPS) to the end of the endsWhere
  452.       --copy (offset of "http://" in theCurrentHTTPS) to the end of the endsWhere
  453.  
  454.       log endsWhere
  455.       set endOfURL to (minimumPositiveNumber from endsWhere) - 1
  456.  
  457.       if endOfURL = -1 then
  458.         -- We have reached the end of the input
  459.         set theURL to theCurrentHTTPS
  460.       end if
  461.       set theURL to text 1 thru endOfURL of theCurrentHTTPS
  462.       log "--------------------------- " & theURL & "--------------------------- "
  463.       -- "curl --silent --location --max-time 15 " & theURL
  464.       set toUnix to "curl --silent --location --max-time 15 " & theURL
  465.       log "toUnix  is " & toUnix
  466.       set fromUnix to do shell script toUnix
  467.       displayHeader("fromUnix", fromUnix)
  468.       try
  469.         set actualTagData to tagContent(fromUnix, "<title", "</title>")
  470.         log "actualTagData  is " & actualTagData
  471.         if actualTagData is "" then
  472.           set actualTagData to theURL
  473.         end if
  474.         -- there could be some attributes within the tag
  475.         -- an attribute could have a > in it. ignoring that for now.
  476.         set actualTagData to text ((offset of ">" in actualTagData) + 1) thru (length of actualTagData) of actualTagData
  477.  
  478.       on error errMsg number n
  479.         log "==> Error occured when looking for title. " & errMsg & " with number " & n
  480.         set actualTagData to theURL
  481.       end try
  482.       set assembled to "<a href=\"" & theURL & "\" target=\"_blank\">" & actualTagData & "</a>"
  483.       log "assembled  is " & assembled
  484.       if endOfURL = -1 then
  485.         -- We have reached the end of the input
  486.         set buildHTML to buildHTML & assembled
  487.       else
  488.  
  489.         set buildHTML to buildHTML & assembled & text from (endOfURL + 1) to (length of theCurrentHTTPS) of theCurrentHTTPS
  490.       end if
  491.       -- wrap up
  492.       set theOutputBuffer to buildHTML
  493.       log "transformed text from buildHTML is  " & return & buildHTML
  494.       log "#" & counti & " transformed text from buildHTML is  " & return & buildHTML
  495.       -- number of links found
  496.       set counti to counti + 1
  497.  
  498.     end repeat -- looking for all links of the same type in document
  499.   end repeat -- scanning for https and http links
  500.  
  501.   (* add paragraphs *)
  502.  
  503.   -- start the theOutputBuffer with a paragraph tag.  We are taking a simple approach at this time.
  504.   set theOutputBuffer to "<p>" & theOutputBuffer
  505.   -- CRLF, CR or LF
  506.   set theOutputBuffer to alterString(theOutputBuffer, return & lf & return & lf, "</p><p> </p><p>")
  507.   set theOutputBuffer to alterString(theOutputBuffer, return & return, "</p><p> </p><p>")
  508.   set theOutputBuffer to alterString(theOutputBuffer, lf & lf, "</p><p> </p><p>")
  509.  
  510.   -- Does the string end with a dangling paragraph?  
  511.   if text ((length of theOutputBuffer) - 2) thru (length of theOutputBuffer) of theOutputBuffer is "<p>" then
  512.     set theOutputBuffer to text 1 thru ((length of theOutputBuffer) - 3)
  513.   else if text ((length of theOutputBuffer) - 2) thru (length of theOutputBuffer) of theOutputBuffer is not "</p>" then
  514.     set theOutputBuffer to theOutputBuffer & "</p>"
  515.   end if
  516.  
  517.   log "theOutputBuffer is " & return & theOutputBuffer
  518.  
  519.   -- convert to html clipboard format
  520.   typeHTML(theOutputBuffer)
  521.  
  522. end typeText
  523.  
  524. (*
  525. https://www.oreilly.com/library/view/applescript-the-definitive/0596102119/re89.html
  526.  
  527. https://stackoverflow.com/questions/11085654/apple-script-how-can-i-copy-html-content-to-the-clipboard
  528.  
  529. -- user has copied a file's icon in the Finder
  530. clipboard info
  531. -- {{string, 20}, {«class ut16», 44}, {«class hfs », 80}, {«class
  532.  utf8», 20}, {Unicode text, 42}, {picture, 2616}, {«class icns», 43336},
  533. {«class furl», 62}}
  534.  
  535. textutil -convert html foo.rtf
  536.  
  537. if ((clipboard info) as string) contains "«class furl»" then
  538.     log "the clipboard contains a file named " & (the clipboard as string)
  539.   else
  540.     log "the clipboard does not contain a file"
  541.   end if
  542.  
  543. the clipboard    required
  544. as  class  optional
  545.  
  546. tell application "Script Editor"
  547.     activate
  548.   end tell
  549.  
  550. textutil has a simplistic text to html conversion
  551.     set clipboardDataQuoted to quoted form of theData
  552.   log "quoted form is " & clipboardDataQuoted
  553.  
  554.   set toUnix to "/bin/echo -n " & clipboardDataQuoted
  555.   set toUnix to toUnix & " | textutil -convert html -noload -nostore -stdin -stdout "
  556.   log "toUnix is " & toUnix
  557.   set fromUnix to do shell script toUnix
  558.   log "fromUnix  is " & fromUnix
  559.  
  560. set s to "Today is my birthday"
  561. log text 1 thru ((offset of "my" in s) - 1) of s
  562. --> "Today is "
  563.  
  564. log "beginningOfTag is " & text 1 thru (minimumPositiveNumber from {200, length of beginningOfTag}) of beginningOfTag & "<+++++++++++++++++++++++"
  565.  
  566. https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_cmds.html
  567.  
  568. *)
  569.  
  570. --mac $ hex=`echo -n "<p>your html code here</>" | hexdump -ve '1/1 "%.2x"'`
  571. --mac $ echo $hex
  572. --3c703e796f75722068746d6c20636f646520686572653c2f3e
  573. --mac $ osascript -e "set the clipboard to «data HTML${hex}»"
  574. --mac $
  575. (*  
  576. A sub-routine for encoding ASCII characters.  
  577.  
  578. encode_char("$")  
  579. --> returns: "%24"  
  580.  
  581. based on:  
  582. https://www.macosxautomation.com/applescript/sbrt/sbrt-08.html  
  583.  
  584. *)
  585. (*
  586. Lowest Numeric Value in a List
  587.  
  588. This sub-routine will return the lowest numeric value in a list of items. The passed list can contain non-numeric data as well as lists within lists. For example:
  589.  
  590. lowest_number({-3.25, 23, 2345, "sid", 3, 67})
  591. --> returns: -3.25
  592. lowest_number({-3.25, 23, {-22, 78695, "bob"}, 2345, true, "sid", 3, 67})
  593. --> returns: -22
  594.  
  595. If there is no numeric data in the passed list, the sub-routine will return a null string ("")
  596.  
  597. lowest_number({"this", "list", "contains", "only", "text"})
  598. --> returns: ""
  599.  
  600. https://macosxautomation.com/applescript/sbrt/sbrt-03.html
  601.  
  602. Here's the sub-routine:
  603.  
  604. *)
  605. (*
  606. on lowestNumber(values_list)
  607.   set the low_amount to ""
  608.   repeat with i from 1 to the count of the values_list
  609.     set this_item to item i of the values_list
  610.     set the item_class to the class of this_item
  611.     if the item_class is in {integer, real} then
  612.       if the low_amount is "" then
  613.         set the low_amount to this_item
  614.       else if this_item is less than the low_amount then
  615.         set the low_amount to item i of the values_list
  616.       end if
  617.     else if the item_class is list then
  618.       set the low_value to lowest_number(this_item)
  619.       if the the low_value is less than the low_amount then ¬
  620.         set the low_amount to the low_value
  621.     end if
  622.   end repeat
  623.   return the low_amount
  624. end lowestNumber
  625. *)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement