The culprit in your script was the instruction 'delay 1" which kills the result issued before.
Edit your instructions as :
set trashFolder to quoted form of POSIX path of (path to trash folder)
set maybe to do shell script "du -h " & trashFolder
delay 1
set trashSize to the first word of the last paragraph of maybe # No longer issue an error
set trashNumber to text 1 thru -2 of trashSize
set trashUnit to text -1 of trashSize
log "trashNumber is : " & trashNumber --> (*trashNumber is : 9.9*)
if trashNumber = "0" then
say "No files in the trash" speaking rate 260
error number -128 -- exit the script
else if trashUnit = "K" or trashUnit = "B" then
say "Less than one megabyte" speaking rate 260
else if trashUnit = "M" then
# issue an error here because "9.9" can't be coerced as integer
say ((trashNumber as integer) as text) & "megabytes" speaking rate 260
else
say "Trash size could not be calculated"
end if
display dialog "Empty trash?" with icon 0 giving up after 10
tell application "Finder" to empty trash
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 26 décembre 2019 15:27:25
It works for you because your system is ran in English.
The instruction converts the string 44.9" into the number 44.9 then convert it in the number 44.
Here, the decimal separator is not the period but the comma so “44.9” can’t be converted into a number.
I would have to use something like :
set decimalDelim to text item 2 of ((1 / 2) as text)
--> "." when the system speaks English
--> "," when the system speaks French
set aNumber to "44.9"
if decimalDelim is "," then
set aNumber to my remplace(aNumber, ".", ",") --> "44,9" which is a valid numerical string in such case
end if
say ((aNumber as integer) as text)
#=====
(*
replaces every occurences of d1 by d2 in the text t
*)
on remplace(t, d1, d2)
local oTIDs, l
set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d1}
set l to text items of t
set AppleScript's text item delimiters to d2
set t to l as text
set AppleScript's text item delimiters to oTIDs
return t
end remplace
#=====
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 26 décembre 2019 16:22:34
Happily, I never saw the shel returning values with thousands separator.
I often receive such strings from the USA.
In such case the active code would be:
set aNumber to "12,345,567.89"
if decimalDelim is "," then
set aNumber to my remplace(aNumber, ",", "") --> "12345567.89"
set aNumber to my remplace(aNumber, ".", ",") --> "12345567,89" which is a valid numerical string in such case
end if
Have you see that I sent you a mail ?
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 26 décembre 2019 16:36:52