Copy link to clipboard
Copied
Hi i am using the main.cfc in the examples using the onIncomingMessage event
i am gettnig back a variable
<cfset message="#data.message#">
<!--- where did it come from? --->
<cfset orig="#CFEvent.originatorID#">
<cfset retValue = structNew()>
<cfset retValue.command = "submit">
<cfset retValue.sourceAddress = arguments.CFEVENT.gatewayid>
<cfset retValue.destAddress = arguments.CFEVENT.originatorid>
<cfset retValue.shortMessage = "echo: " & message>
retValue.shortMessage contains all the data and is then written to a text file like this
"Information","Thread-15","06/30/09","21:07:17","IM_MENU","echo: id:869990453 sub:001 dlvrd:001 submit date:0906301507 done date:0906301507 stat:DELIVRD err:000 text:"
what i need is to set 2 variables
1. MessageId = this is the "id" in the echo
2. MessageStatus = this is the "stat"
i am not sure how to get to this info?
Copy link to clipboard
Copied
Hi,
could you please paste ur main.cfc
Copy link to clipboard
Copied
main.cfc below, instead of writing to a txt file i need to create 2 variables to insert into my database
<cffunction name="onIncomingMessage" output="no">
<cfargument name="CFEvent" type="struct" required="yes">
<!--- Get the message --->
<cfset data=cfevent.DATA>
<cfset message="#data.message#">
<!--- where did it come from? --->
<cfset orig="#CFEvent.originatorID#">
<cfset retValue = structNew()>
<cfset retValue.command = "submit">
<cfset retValue.sourceAddress = arguments.CFEVENT.gatewayid>
<cfset retValue.destAddress = arguments.CFEVENT.originatorid>
<cfset retValue.shortMessage = "echo: " & messageId>
<cflog file="smsTest" text="#retValue.shortMessage#">
</cffunction>
Copy link to clipboard
Copied
Hi,
try this
<cfset temp= listgetat(retValue.shortMessage,6)>
<cfset temparray= listtoarray(temp," ")>
<cfset MessageId = listgetat(temparray[2],2,":")>
<cfset MessageStatus = listgetat(temparray[9],2,":")>
Copy link to clipboard
Copied
Hi i have tried the below, which did not work, i am not sure how i can debug this to find what the error is, as its a event?
<cfcomponent>
<cffunction name="onIncomingMessage" output="no">
<cfargument name="CFEvent" type="struct" required="yes">
<!--- Get the message --->
<cfset data=cfevent.DATA>
<cfset message="#data.message#">
<!--- where did it come from? --->
<cfset orig="#CFEvent.originatorID#">
<cfset retValue = structNew()>
<cfset retValue.command = "submit">
<cfset retValue.sourceAddress = arguments.CFEVENT.gatewayid>
<cfset retValue.destAddress = arguments.CFEVENT.originatorid>
<cfset retValue.shortMessage = "echo: " & message>
<cfset temp= listgetat(retValue.shortMessage,6)>
<cfset temparray= listtoarray(temp," ")>
<cfset MessageId = listgetat(temparray[2],2,":")>
<cfset MessageStatus = listgetat(temparray[9],2,":")>
<cflog file="smsTestCraig2" text="#MessageStatus#">
</cffunction>
Copy link to clipboard
Copied
Use cflog to save information about the request to a log file.
Here's the same statement as above but this time correctly escaped in code tags:
ReFindNoCase("id:([0-9]+) .*stat:([a-z]+) ", retValue.shortMessage, 1, true)
Mack
Copy link to clipboard
Copied
ok thanks i have added the following, but nothing is written to the log file
<cflog file="smsTestCraig2" text="#ReFindNoCase("id:([0-9]+) .*stat:([a-z]+) ", retValue.shortMessage, 1, true)#">
Copy link to clipboard
Copied
That's because the ReFindNoCase returns a structure and the text
attribute expects a string (or something that can be converted to a
string).
Test the regular expression outside the cfc, in a simple test file to
make sure it's working properly and place the code inside the CFC
after that.
Mack
Copy link to clipboard
Copied
try this
<cfset st1=ReFindNoCase("id:([0-9]+) .*stat:([a-z]+) ", retValue.shortMessage, 1, true)>
<cfloop index = "i" from = "2" to = "#ArrayLen(st1.pos)#">
<cfset testval = testval & Mid(t,st1.pos,st1.len) & "|">
</cfloop>
<cflog file="smsTestCraig2" text="#testval #">
Copy link to clipboard
Copied
ok i have tried the following in a test file, but i just get 2 empty strings?
<cfset retValue.shortMessage = "echo: id:869990453 sub:001 dlvrd:001 submit date:0906301507 done date:0906301507 stat:DELIVRD err:000 text:">
<cfset testval = "">
<cfset st1=ReFindNoCase("id:([0-9]+) .*stat:([a-z]+) ", retValue.shortMessage, 1, true)>
<cfloop index = "i" from = "2" to = "#ArrayLen(st1.pos)#">
<cfset testval = testval & Mid(true, st1.pos,st1.len) & "|">
</cfloop>
<cfdump var="#testval#">
Copy link to clipboard
Copied
The first parameter of the Mid function is not a boolean but the
string from which you want to extract the substring.
Mack
Copy link to clipboard
Copied
hi so what should the first value be?
i have tried st1?
Copy link to clipboard
Copied