How to store a string as a variable
jon123456789
Posts: 11
Hi,
I'm pulling my hair out with this one, and I'm sure the answer is so simple. I just can not work it out.
So 2 browny points to the person who can point me in the right direction.
How do I store a text string in a single place in the code so I can use it in multiple locations?
I have tried:
But I get gobbledegook through on the serial interface.
The serial interface works fine as listed below:
I use the Prop linked to a GSM module to send me a text message if my house alarm is initiated.
I'm using the FullDuplexSerial object, as follows:
I would like to tidy up my code a bit·as I currently have multiple messages so I have multiple PUB's for each SMS (and duplicated again for 2 x mobile phone numbers) but it could be a lot neater and simpler.
With thanks
Jon
I'm pulling my hair out with this one, and I'm sure the answer is so simple. I just can not work it out.
So 2 browny points to the person who can point me in the right direction.
How do I store a text string in a single place in the code so I can use it in multiple locations?
I have tried:
DAT message byte "this is my message"
and then use:
Serial.str(string(message))
But I get gobbledegook through on the serial interface.
The serial interface works fine as listed below:
I use the Prop linked to a GSM module to send me a text message if my house alarm is initiated.
I'm using the FullDuplexSerial object, as follows:
PUB sendsms1 Serial.str(string("AT+CMGF=1")) {set format to text mode} Serial.tx(13) waitcnt(100_000_000 + cnt) Serial.str(string("AT+CSDH=1")) {Show Text Mode Parameters} Serial.tx(13) waitcnt(100_000_000 + cnt) Serial.str(string("AT+CSMP=17,167,0,0")) {Set Text Mode Parameters} Serial.tx(13) waitcnt(100_000_000 + cnt) Serial.str(string("AT+CMGS=")) Serial.tx(34) {" character} Serial.str(string("+44123456789")) Serial.tx(34) {" character} Serial.tx(13) {CR} waitcnt(100_000_000 + cnt) Serial.str(string("Alarm condition")) Serial.tx(26) {ctrl z} Serial.tx(13)
I would like to tidy up my code a bit·as I currently have multiple messages so I have multiple PUB's for each SMS (and duplicated again for 2 x mobile phone numbers) but it could be a lot neater and simpler.
With thanks
Jon
Comments
The following worked just fine:
This is not an RTFM message, but an ETFM "Enhance the ... Manual" message.
The information is described in gory detail in the "BYTE" section of the Propeller manual ... if you know where to look. I think the "opportunity" for the technical writers is to add a section to the manual on "data types" so that people who know what "data types" means can find it. Almost any programming language introduction I've seen has such a section. Of course the audience is not necessarily programmers so even a "data types" section might not help. Still, people with skills beyond the Basic Stamp should be considered.