Don't know exactly how to phrase the subject but what I need to know is how I can take this String:
"AT+HTTPPARA=\"URL\",\"http://www.domain.com/insert.php?temperature01=200\""
and change out the '200' part, for a variable inside this string...
Should it be like:
Calc: STRING_VARIABLE = ToString$(INT_VARIABLE)
"AT+HTTPPARA=\"URL\",\"http://www.level6.se/insert2.php?temper ... G_VARIABLE\'\""
or
"AT+HTTPPARA=\"URL\",\"http://www.level6.se/insert2.php?temper ... G_VARIABLE'\""
Or is this not possible?
variable inside string?
-
- Posts: 528
- Joined: Sat Dec 01, 2012 1:23 pm
- Location: Sweden
- Has thanked: 49 times
- Been thanked: 101 times
- Contact:
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: variable inside string?
Hello,
I don't think you can place the variable inside the string but it should be possible to merge together strings into a variable.
Calc: STRING_VAR1 = ToString$(INT_VARIABLE)
Calc: STRING_VAR2 = "Fixed string data " + STRING_VAR1
I don't think you can place the variable inside the string but it should be possible to merge together strings into a variable.
Calc: STRING_VAR1 = ToString$(INT_VARIABLE)
Calc: STRING_VAR2 = "Fixed string data " + STRING_VAR1
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 528
- Joined: Sat Dec 01, 2012 1:23 pm
- Location: Sweden
- Has thanked: 49 times
- Been thanked: 101 times
- Contact:
Re: variable inside string?
Ok, the problem with that, I think, is that the variable needs to be inserted before the " and if I do this:
Temp = Temp + 1
Data_String = ToString$ (Temp)
Data_String2="AT+HTTPPARA=\"URL\",\"http://www.domain.com/insert.php?temperature01=" + Data_String
Data_String2=Data_String2 + "\""
then
Call component Macro:
SendCommand(Data_String2,1)
I get a compilation error saying "missing semi colon" in the Calculation
My guess is because the \" is "missing" from the calculation:
Data_String2="AT+HTTPPARA=\"URL\",\"http://www.domain.com/insert.php?temperature01=[b]\"[/b]" + Data_String
Or what do you think?
Temp = Temp + 1
Data_String = ToString$ (Temp)
Data_String2="AT+HTTPPARA=\"URL\",\"http://www.domain.com/insert.php?temperature01=" + Data_String
Data_String2=Data_String2 + "\""
then
Call component Macro:
SendCommand(Data_String2,1)
I get a compilation error saying "missing semi colon" in the Calculation
My guess is because the \" is "missing" from the calculation:
Data_String2="AT+HTTPPARA=\"URL\",\"http://www.domain.com/insert.php?temperature01=[b]\"[/b]" + Data_String
Or what do you think?
Last edited by hyperion007 on Wed Apr 30, 2014 12:02 pm, edited 1 time in total.
-
- Posts: 528
- Joined: Sat Dec 01, 2012 1:23 pm
- Location: Sweden
- Has thanked: 49 times
- Been thanked: 101 times
- Contact:
Re: variable inside string?
I found this from a post on some forum:
String url = "AT+HTTPPARA=\"URL\",\"http://domain.com/insert.php?";
url.concat("temperature01=");
url.concat(Temp);
url.concat("\"");
//Serial.println(url);
But I don't know how to do something similar in Flowcode
String url = "AT+HTTPPARA=\"URL\",\"http://domain.com/insert.php?";
url.concat("temperature01=");
url.concat(Temp);
url.concat("\"");
//Serial.println(url);
But I don't know how to do something similar in Flowcode
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: variable inside string?
Looks like you have found a Flowcode bug
Seems it does not like // in strings
Here is a workaround ...
Seems it does not like // in strings
Here is a workaround ...
Code: Select all
Temp = Temp + 1
Data_String = ToString$ (Temp)
Data_String2 = "AT+HTTPPARA=\"URL\",\"http:/"
Data_String2 = Data_String2 + "/www.domain.com/insert.php?temperature01="
Data_String2 = Data_String2 + Data_String
Data_String2 = Data_String2 + "\""
-
- Posts: 528
- Joined: Sat Dec 01, 2012 1:23 pm
- Location: Sweden
- Has thanked: 49 times
- Been thanked: 101 times
- Contact:
Re: variable inside string?
Hi LeighM
Thanks, now it works! I don't even need the "http://" part so I removed that and it worked (I had my strings set to [40] which was way to small, now at [80] it works fine)
Best day in a VERY long time Got the Sim900 working, sending data to my hosted MySQL database. Thanks again!
Thanks, now it works! I don't even need the "http://" part so I removed that and it worked (I had my strings set to [40] which was way to small, now at [80] it works fine)
Best day in a VERY long time Got the Sim900 working, sending data to my hosted MySQL database. Thanks again!