svego Posted November 2, 2016 Share Posted November 2, 2016 hi to all... What is wrong here ??? if(ch3_DI_ulaz[0]==0) private dbase MyStringVariable = FormatDateTime("IC bariera ALARM %d:%m:%Y %H:%M", SysTime()) dbase = db.OpenEx("DSN=DF_SMS;UID=vcvcv;PWD=xxxx") // this works OK // db.Execute(dbase,'insert into smsserver.messageout(MessageTo,MessageText) values ("+385xxxx005","IC bariera")') // this do not work ok db.Execute(dbase,'insert into smsserver.messageout(MessageTo,MessageText) values ("+385xxxx005",MyStringVariable)') delay(5) db.Close(dbase) endif Link to comment Share on other sites More sharing options...
AzeoTech Posted November 2, 2016 Share Posted November 2, 2016 That's because you put your variable name inside the string. DAQFactory doesn't and can't examine the contents of strings for variables and make substitutions. This would be a huge mess if it did. You have to concatenate your strings: db.Execute(dbase,'insert into smsserver.messageout(MessageTo,MessageText) values ("+385xxxx005","' + MyStringVariable + '")') Note that I have to be sure to include the double quotes inside the string so that the result includes double quotes. Single quotes in your case are the string delimiters. Link to comment Share on other sites More sharing options...
svego Posted November 2, 2016 Author Share Posted November 2, 2016 i tried to copy / paste, but without success...what is wrong ?? so... MyStringVariable = FormatDateTime("IC bariera ALARM %d:%m:%Y %H:%M", SysTime()) db.Execute(dbase,'insert into smsserver.messageout(MessageTo,MessageText) values ("+385xxxx005","' + MyStringVariable + '")') should return...SMS message with content IC bariera ALARM 02:11:2016 20:09 ??? Link to comment Share on other sites More sharing options...
AzeoTech Posted November 2, 2016 Share Posted November 2, 2016 When concating strings inside function calls, it often helps to print the result to command/alert before, so do: ? 'insert into smsserver.messageout(MessageTo,MessageText) values ("+385xxxx005","' + MyStringVariable + '")' and see what shows up, then you can correct it. Link to comment Share on other sites More sharing options...
svego Posted November 2, 2016 Author Share Posted November 2, 2016 this works...( SMS server send SMS content to +385xxxx005 with content IC bariera ALARM 02:11:2016 20:09..) db.Execute(dbase,'insert into smsserver.messageout(MessageTo,MessageText) values ("+385xxxx005","' + FormatDateTime("IC bariera ALARM %d:%m:%Y %H:%M", SysTime()) + '")') //------- but I don't know how to do that with variable ?? for example... MyStringVariable = FormatDateTime("ALARM %d:%m:%Y %H:%M", SysTime()) Alarm_channel_value=Format("My Value: %.2f",x_300_temp1[0]) text_to_send=MyStringVariable+Alarm_channel_value db.Execute(dbase,'insert into smsserver.messageout(MessageTo,MessageText) values ("+385xxxx005",'text_to_send')') Link to comment Share on other sites More sharing options...
AzeoTech Posted November 3, 2016 Share Posted November 3, 2016 You have to concat the string just like you did in the one that worked. You just dropped the +'s for some reason (and the double quotes). You want: db.Execute(dbase,'insert into smsserver.messageout(MessageTo,MessageText) values ("+385xxxx005","' + text_to_send + '")') I'm assuming that your three variables are all declared as strings as well. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.