I thought about using characters, however, I will be encountering code such as:
“12+16-”
that needs to be coerced into:
{“12”, “+”, “16”, “-”}
EVERYTHING else works the way you would think, EXCEPT for the “-” sign. It’s really going to make for a lot of extra coding to handle this and it needs to work FAST because this code will be utilitized during input. I’d hate to have to wait a while between each input is entered.
set x to "12+16-"
set x to my minus_cleanup(x)
return x -->{"12", "+", "16", "-"}
on snr(the_string, search_string, replace_string)
set old_delim to AppleScript's text item delimiters
set AppleScript's text item delimiters to search_string
set the_string to text items of the_string
set AppleScript's text item delimiters to replace_string
set the_string to the_string as string
set AppleScript's text item delimiters to old_delim
return the_string
end snr
on minus_cleanup(x)
if x does not contain "-" then return words of x
set x to my snr(x, "-", ":minus:")
set x to words of x
repeat with i from 1 to (count x)
if item i of x = "minus" then set item i of x to "-"
end repeat
return x
end minus_cleanup
I’m sure there’s some thing to consider or ignore (punctuation, white space, etc.) to get AppleScript to treat the minus sign appropriately but I’m not sure what it is.
The minus sign is a hyphen which also seperates words. Here are some other things that aren’t words:
tab
line feed
carriage return
space
exclamation mark
double quote
single quote
left parenthesis
right parenthesis
comma
hyphen
period
forward slash
colon
semi colon
question mark
left square bracket
right square bracket
left curly bracket
right curly bracket
Excuse miss spellings and made up words :-). Note that parenthesis will group your math stuff. You need to take into account order of operation.
I was one track minded and saw your post after I posted. But when I posted there was an error so I didn’t think it posted. Anyway, great idea you got there.