mobileSensorAvailable ("location")

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: mobileSensorAvailable ("location")

Post by Dixie » Sun Jan 31, 2016 7:07 pm

Ok then, I'll bite... When does tMessage get populated ?

A1Qicks
Posts: 79
Joined: Sat Dec 26, 2015 10:47 am

Re: mobileSensorAvailable ("location")

Post by A1Qicks » Sun Jan 31, 2016 7:11 pm

Incoming message:

Code: Select all

on chatReceived s,data
put data into tMessage
put item 1 of data into tMessageType
switch tMessageType
case LOCA
#etc.
Outgoing message:

Code: Select all

on chatMessage data
if lMobileLoc is true then
set the backgroundcolor of button "Location" to green
set the label of button "Location" to uMyLocation
write "LOCA" && uMyLocation & return & field "NameField" & ":" && data to socket lChatSocket
end if
end chatMessage
Data is there because that's what was in the LC lesson about sockets and servers, I changed as little as possible from the official code.

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: mobileSensorAvailable ("location")

Post by Dixie » Sun Jan 31, 2016 7:15 pm

Ah, OK... I'll bow out here as I have not ever looked at this 'lesson'... and don't have the time to go through it...

A1Qicks
Posts: 79
Joined: Sat Dec 26, 2015 10:47 am

Re: mobileSensorAvailable ("location")

Post by A1Qicks » Sun Jan 31, 2016 7:18 pm

For reference should anyone else come across this thread:
http://lessons.livecode.com/m/4071/l/12 ... ng-sockets for conceptual stuff, and then the base code (including 'data') is one of the examples available from inside the IDE.

It works in every other regard. It's just that one line of code that's screwing with me. Why, gods of code, why?

A1Qicks
Posts: 79
Joined: Sat Dec 26, 2015 10:47 am

Re: mobileSensorAvailable ("location")

Post by A1Qicks » Sun Jan 31, 2016 7:36 pm

For the sake of argument, I swapped all instances of 'data' out for 'tMessage'.

Same error, no change. Though I guess the code is slightly tidier for it, which never hurts.

A1Qicks
Posts: 79
Joined: Sat Dec 26, 2015 10:47 am

Re: mobileSensorAvailable ("location")

Post by A1Qicks » Mon Feb 01, 2016 1:37 pm

Gonna try making it more complicated, seeing if that works. I'll swap out a simple 'put line 2 of tMessage' for changing a variable and then posting the message based on that variable, and if that doesn't work, setting up a whole new command to function when the miles < 2. It's a roundabout way of doing things, but I haven't tried it yet.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: mobileSensorAvailable ("location")

Post by jacque » Mon Feb 01, 2016 6:37 pm

Dixie wrote:Use '&' instead of 'and'
Dixie got it, my mind skipped right over the error because not only does it read right, but "and" is also a valid keyword. But it's only valid for evaluations, if you need concatenation you must use "&" . The engine is evaluating a phrase that doesn't produce a valid boolean result and returning "false" .

What you want is:

put line 2 of tMessage & return after field "displayMessage"

Aside: since "return" also has multiple uses, I always use the constant "cr" for carriage returns. I might have noticed the problem sooner if it had been written (incorrectly) as:

put line 2 of tMessage and cr after field "displayMessage"

Glad you stuck with this.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

A1Qicks
Posts: 79
Joined: Sat Dec 26, 2015 10:47 am

Re: mobileSensorAvailable ("location")

Post by A1Qicks » Mon Feb 01, 2016 7:27 pm

Oh good lord.

My heartfelt apologies to Dixie, I missed that small change when you posted it.

Of course, of course it has fixed everything. Bloody hell, I rewrote the entire loop EXCEPT for the one line that was wrong :lol:

Thank you both so much for this, it FINALLY works as planned and I can move on to the account system and settings card.

BEAUTIFUL.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: mobileSensorAvailable ("location")

Post by jacque » Mon Feb 01, 2016 7:52 pm

Great! Don't beat yourself up too much. LC reads so naturally that your brain just doesn't always process these little syntax distinctions. And I think we can all relate to the frustration. You were a trooper.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply