Syntax question with repeat

Hi Folks,

Could you please help me with the syntax:


if Q does not contain "T-Mobile A" then

repeat

if Q contains "A1" then set Q to "T-Mobile A" and exit repeat
if Q contains "one" then set Q to "T-Mobile A" and exit repeat
if Q contains "3" then set Q to "T-Mobile A" and exit repeat

try 

 tell current application
   display dialog "Do you want to connect with " & Q  buttons {"Cancel", "OK"}
   set the requested_status to the button returned of the result
 end tell
end try
end repeat
end if



The Goal is the following:

Sometimes the Simcard is not presenting the correct provider - here in austria we have 4 of them: T-Mobile A, A1, one, 3 - If the displayed provider is one of the 3, then it should set the Q to “T-Mobile A” if you are outside of Austria then the Application should show the Provider even if it is not T-Mobile…

I forgot to say that currently there is a problem with exit repeat and set to …

Thanks for your help!

Stefan

Hi Stefan

the boolean operators and and or can only be used for comparisons
not to include an additional command in the same line

This does it:

if Q does not contain "T-Mobile A" then
	
	repeat
		if Q contains "A1" then
			set Q to "T-Mobile A"
			exit repeat
		else if Q contains "one" then
			set Q to "T-Mobile A"
			exit repeat
		else if Q contains "3" then
			set Q to "T-Mobile A"
			exit repeat
		end if
		try
			
			tell current application
				display dialog "Do you want to connect with " & Q buttons {"Cancel", "OK"}
				set the requested_status to the button returned of the result
			end tell
		end try
	end repeat
end if

or easier:

if Q does not contain "T-Mobile A" then
	repeat
		if Q contains "A1" or Q contains "one" or Q contains "3" then
			set Q to "T-Mobile A"
			exit repeat
		end if
		try
			tell current application
				display dialog "Do you want to connect with " & Q buttons {"Cancel", "OK"}
				set the requested_status to the button returned of the result
			end tell
		end try
	end repeat
end if

Hi Stefan,

you are a magician…

Thanks a lot!

Stefan

Not at all, I’ve just studied the language :wink: