How to use text Delimiters with Numbers

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.

Thanks in advance!

Jason

set IP_Net to items 1 thru 3 of MyData

are the first three characters, but you want the text items

set IP_Net to text items 1 thru 3 of MyData

Even with that I get the same result :frowning:

Jason

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.

Calling a subroutine or function from the script such as

 set IP_Net to my getTextItemsOf:MyData

and adding the following subroutine or function

on getTextItemsOf:MyData
	set AppleScript's text item delimiters to "."
	set IP_Net to text items 1 thru 3 of MyData
end getTextItemsOf:

resolved the dilemma for me.

For reasons not clear to me, Numbers.app interprets the term text items differently than does AppleScript’s Text Item Delimiters.

Fantastic !!!
This works perfectly!
You just made my life easier :wink:

Jason