I have never written anything in AppleScript but I recently got a MBP and started playing around with it just to tweak the touchbar. In a downloaded preset I saw this line:
set theArray to every text item of theString
I assume that this line appends the entire string (every single character element) to the array.
How I can choose to append only a fixed n number of characters from that string/item, say maybe the first 10 characters of that string?
Best Answer
Here's an example:
Since you are new to AppleScript, I encourage you to take the time to read though: AppleScript Language Guide
Just so you know, AppleScript does not have object designated with the name
array
, it useslist
instead. It's a minor technicality however, since you're just starting to learn, its best you know what it's called within the AppleScript Language.So, instead of using the variable
theArray
, I'd choose to name ittheList
, or more specifically I'd add an additional qualifier. For example,theCharList
, or whatever is appropriate so as I read through the code I write, I readily know what the variable is for.