Text Item Delimiters

Hi Folks,

sorry that I have opened this thread, but it seems that I am to stupid for the Text Item Delimiters…

I have the String - show_provider - which looks like this:

+COPS:(2,“T-Mobile A”,“TMO A”,“23203”,2),(3,“A1”,“A1,“23201”,”),(3,“3 AT”,“3 AT”,“23210”,2)

I am looking now for a way to split this string and have as result everything inside the () - the output in the end should be filled into a dropdown…

What I have at the moment is:


repeat 

set text item delimiters to "()"
set Q to text item of show_provider
set AppleScript's text item delimiters to tid
make new menu item at end of menu of popup button "provider" of window "main" with properties {title: Q, enabled: true}
-- if there is no new variable then exit repeat
end repeat


Thanks for your time - and please forgive me my stupidness…

Stefan

Here’s a plain vanilla version:


set Str to "+COPS:(2,\"T-Mobile A\",\"TMO A\",\"23203\",2),(3,\"A1\",\"A1,\"23201\",\"),(3,\"3 AT\",\"3 AT\",\"23210\",2)"
set M to {}
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "("
set T to text items 2 thru -1 of Str
set AppleScript's text item delimiters to ")"
repeat with tt in T
	set M's end to text 1 thru -3 of text item 1 of tt
end repeat
set AppleScript's text item delimiters to tid
choose from list M

Hi Adam,

thanks for your help - works really great…

Do you think wheter there is a possibility to check wheter the stuff inside the () contains a number of 5 digits and only to display
the content whithin the () where a number with 5 digits is?

Thanks for your reply…

Stefan

I’m just having a déjà vu :wink:

http://bbs.applescript.net/viewtopic.php?id=20505

Hi Folks,

only 24 hours later I solved this issue by using this:

set Str to "+COPS:(2,\"T-Mobile A\",\"TMO A\",\"23203\",2),(3,\"A1\",\"A1,\"23201\",\"),(3,\"3 AT\",\"3 AT\",\"23210\",2),(3,\"3 AT\",\"3 AT\",\"2310\",2)"
set M to {}
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "("
set T to text items 2 thru -1 of Str
set AppleScript's text item delimiters to ","
repeat with tt in T
	if length of (text item 4 of tt) > 6 then -- ist \"23210\"
		set M's end to (text item 2 of tt) as string
	end if
end repeat
choose from list M with prompt "Bitte Roaming Netz auswählen:"
set Roaming to the result

Best Regards,

Stefan