I’m trying to split some text separated with periods (IP addresses) that are listed in a Numbers spreadsheet but setting a Delimiter doesn’t have an effect.
Here’s my script:
set TestFile to “Macintosh HD:Users:Me:Documents:IP Addresses.numbers”
set MySheet to “Sheet1”
set x to 2
tell application “Numbers”
set MyDoc to open TestFile
tell MyDoc to tell sheet MySheet to tell table 1
set TblRows to get row count
set AppleScript's text item delimiters to "."
--repeat with x from x to TblRows
set MyData to value of cell ("A" & x)
set IP_Net to items 1 thru 3 of MyData
--end repeat
end tell
end tell
With this script, using “29.52.135.92 as test data, IP_Net will equal {“2”,“9”,”."}
I want {“29”,“52”,“135”}
If I remove “AppleScript’s” from the line “set AppleScript’s text item delimiters to “.”” I just get an error.
Is there anyway to use delimiter’s in Numbers?
Or is there a different way to do this?
I’m using Big Sur and the latest version of Numbers.
It seems that text items only works outside the tell block as “Keynote” doesn’t understand and only returns individual characters
set MySheet to "Sheet1"
set x to 2
set text item delimiters to "."
tell application "Numbers"
set MyDoc to document 1
tell MyDoc to tell sheet MySheet to tell table 1
set TblRows to get row count
set AppleScript's text item delimiters to "."
--repeat with x from x to TblRows
set MyData to value of cell ("A" & x)
--end repeat
end tell
end tell
set IP_Net to text items 1 thru 3 of MyData -- outside of tell block
oddly, even if I used a “tell me” line inside the tell block, it still doesn’t work
set MySheet to "Sheet1"
set x to 2
set text item delimiters to "."
tell application "Numbers"
set MyDoc to document 1
tell MyDoc to tell sheet MySheet to tell table 1
set TblRows to get row count
set AppleScript's text item delimiters to "."
--repeat with x from x to TblRows
set MyData to value of cell ("A" & x)
tell me to set IP_Net to text items 1 thru 3 of MyData -- THIS DON'T WORK
--end repeat
end tell
end tell
EDIT – I just figured out by reading the dictionary for Numbers that “text item” is a different thing in Numbers that to pure AppleScript.