What's wrong with "it" ??
Posted: Thu Jan 03, 2019 6:06 pm
I'm not a complete beginner, but this seems like such a simple issue that I thought this forum would be best. I have code that works and has been running on the Windows platform for a couple of years. I'm finally doing a MAC version and for some reason the same code will not run.
My business is in remote support. We have a server running the remote support software. That software makes a permanent connection to the server, which a lot of our customers are not fond of. So I wrote this program to connect and disconnect (start/stop the service) to our server at will.
First it checks the state of the connection and the GUI displays that status along with the appropriate buttons.
Then user action connects or disconnects
Then it checks the state again and the GUI displays the current status and the appropriate buttons.
Now the good news. Almost everything ran fine on the MAC with minor changes in syntax. What doesn't work is checking the status of the connection.
On both Windows and Mac I do all the work of the program by shelling out to a hidden command window/terminal. The script I use to check the state of the connection on the Mac actually works. It returns the correct information (either "yes" or "no") and it puts that information into the "it" variable. However... the following code will NEVER evaluate appropriately. It will ALWAYS evaluate to "else". I've tested it multiple different ways and it just seems this bit of code will never evaluate properly despite the correct information appearing in the "it" variable. By the way... this bit of code has not changed from Win to Mac, but I don't think that's the problem.
I am happy to provide as much of the background code as you'd like to see, such as the bash script that checks the state of the connection. But that works fine, so I don't know if you need it or not.
I'm hoping this is just some simple "Oh yeah, you have to do such and such on a mac" problem.
command cmdGetState
put the mprState of me into tvScript -- bash script stored in custom property
get Shell(tvScript)
put it into tvState -- at this point either "Yes" or "No" will appropriately be in "it" and "tvState"
if tvState is "No" then
set the visible of image connected.png to false
set the visible of image disconnected.png to true
set the visible of button btnConnect to true
set the visible of button btnDisconnect to false
set the visible of button ckShutdown to false
set the prYesNo of me to "No"
else -- This second section will run every time regardless of the state
set the visible of image connected.png to true
set the visible of image disconnected.png to false
set the visible of button btnConnect to false
set the visible of button btnDisconnect to true
set the visible of button ckShutdown to true
set the prYesNo of me to "Yes"
end if
end cmdGetState
My business is in remote support. We have a server running the remote support software. That software makes a permanent connection to the server, which a lot of our customers are not fond of. So I wrote this program to connect and disconnect (start/stop the service) to our server at will.
First it checks the state of the connection and the GUI displays that status along with the appropriate buttons.
Then user action connects or disconnects
Then it checks the state again and the GUI displays the current status and the appropriate buttons.
Now the good news. Almost everything ran fine on the MAC with minor changes in syntax. What doesn't work is checking the status of the connection.
On both Windows and Mac I do all the work of the program by shelling out to a hidden command window/terminal. The script I use to check the state of the connection on the Mac actually works. It returns the correct information (either "yes" or "no") and it puts that information into the "it" variable. However... the following code will NEVER evaluate appropriately. It will ALWAYS evaluate to "else". I've tested it multiple different ways and it just seems this bit of code will never evaluate properly despite the correct information appearing in the "it" variable. By the way... this bit of code has not changed from Win to Mac, but I don't think that's the problem.
I am happy to provide as much of the background code as you'd like to see, such as the bash script that checks the state of the connection. But that works fine, so I don't know if you need it or not.
I'm hoping this is just some simple "Oh yeah, you have to do such and such on a mac" problem.
command cmdGetState
put the mprState of me into tvScript -- bash script stored in custom property
get Shell(tvScript)
put it into tvState -- at this point either "Yes" or "No" will appropriately be in "it" and "tvState"
if tvState is "No" then
set the visible of image connected.png to false
set the visible of image disconnected.png to true
set the visible of button btnConnect to true
set the visible of button btnDisconnect to false
set the visible of button ckShutdown to false
set the prYesNo of me to "No"
else -- This second section will run every time regardless of the state
set the visible of image connected.png to true
set the visible of image disconnected.png to false
set the visible of button btnConnect to false
set the visible of button btnDisconnect to true
set the visible of button ckShutdown to true
set the prYesNo of me to "Yes"
end if
end cmdGetState