If Clause - Combining of 2 Elements

HI Folks,

I hope you can help me again with a syntax problem:

setting a button do false can be done with:


set enabled of button "Connect" of window "main" to false
	set enabled of button "Disconnect" of window "main" to true

the if clause will sound like this:


if then
else if
end if

the Connection state of the Internet will go like this


tell aplication "Internet Connect"
set conn_status to state of status as string
		--set conn_status to 1
		set conn_list to {"Not Connected", "Dialing", "Connecting...", "Error", "Connected", "Disconnecting...", "n/a", "Connected", "Connected", "Disconnecting...", "Could not connect"}
		set conn_status to item (conn_status) of conn_list
end tell

The State will return a 0, 1, 2, 3,4,7,8,9,10

How can I set the state of the button to false if the returned state of the connection is p.ex. 8?

Thanks for your help and best regards,

Stefan

Model: iBook G4 with 1.2GHZ
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Hi Stefan,

you can do it like this:

tell application "Internet Connect"
set conn_status to state of status 
		--set conn_status to 1
		set conn_list to {"Not Connected", "Dialing", "Connecting...", "Error", "Connected", "Disconnecting...", "n/a", "Connected", "Connected", "Disconnecting...", "Could not connect"}
		if conn_status is 8 then 
		set enabled of button "Connect" of window "main" to false
		end if
		set conn_status to item (conn_status) of conn_list
end tell

or in this case you can put the if - then statement into one line without the end if statement

if conn_status is 8 then set enabled of button "Connect" of window "main" to false

Hi Stefan,

thanks again for your help, but as I have tried this I got the following error message:

A " can’t go after this identifier.

the mark (for the error) goes around " button “Connect” "


tell application "Internet Connect"
set conn_buttons to state of status 	
 if conn_buttons is 8 then 
       set enabled of button "Connect" of window "main" to false
set enabled of button "Disconnect" of window "main" to true
else if conn_buttons is 0 then
set enabled of button "Disconnect" of window "main" to false
set enabled of button "Connect" of window "main" to true
       end if

Thanks for your time and effort…

Best regards,

Stefan

the fault is, there is no property “button” of class “window” in Internet Connection’s dictionary.

Maybe you want to “talk” to another application

Hi Stefan, Stefan,

Does this work?:

tell application "Internet Connect"
	set connectionState to state of status
end tell

set connectedFlag to connectionState is 8
set enabled of button "Connect" of window "main" to not connectedFlag
set enabled of button "Disconnect" of window "main" to connectedFlag

Hi Qwerty,

this works perfect - but I have to play a little with the if clause because this
is not working at the moment…

I will post my feedback…

Best Regards and thanks a lot…

Stefan

Hi Stefan, hi Qwerty,

this works fine:


tell application "Internet Connect"
		set connectionState to state of status
	end tell
	
	set connectedFlag to connectionState is not 8
	
	set enabled of button "Connect" of window "main" to connectedFlag
	set enabled of button "Disconnect" of window "main" to not connectedFlag

The next goals are:

Password protection of the file
Refresh of the connection state
Selection of the modem

Thanks again for your effort and help…

Best regards,

Stefan