NetTalk Central
The Rest Of NetTalk => The Rest - Ask For Help => Topic started by: Johan van Zyl on May 17, 2013, 11:21:24 PM
-
This works:
set(locums)
loop until Access:Locums.Next()
loc:MobileNo = '27'& sub(clip(LCM:Cell),2 , len(clip(LCM:Cell)))
IF LEN(clip(loc:MobileNo)) = 11
loc:SendToBatch = clip(loc:SendToBatch)&','& clip(loc:MobileNo
END
loc:SendToBatch = sub(loc:SendToBatch,1,len(clip(loc:SendToBatch))-1)
This does not:
set(Locums)
!I# = 0
!!loop through file and concatenate numbers!
!loop until Access:Locums.Next()
! I#+=1
! !debuginfo('in the loop '&I# )
! loc:MobileNo = '27'& sub(clip(LCM:Cell),2 , len(clip(LCM:Cell)))
! debuginfo(loc:MobileNo)
! ds_Sleep(100) ! even this did not help
! IF LEN(clip(loc:MobileNo)) = 11 !and LOC:MobileNo = '27720541936'!this line does not work
!IF LEN(clip(loc:MobileNo)) = 11 and LOC:MobileNo = '27720541936' !this works - if I only send one number at a time
! do sendmessage
! end
!end
SendMessage ROUTINE
!LOC:PostURL = 'http://api.clickatell.com/http/sendmsg?user='&clip(loc:ClickatellUserName)&'&password='& clip(loc:ClickatellPassword)&'&api_id='&clip(loc:ClickatellAPIID) &'&to='&clip(loc:MobileNo) &'&text='&clip(loc:Message) !this does not work
LOC:PostURL = 'http://api.clickatell.com/http/sendmsg?user='&clip(loc:ClickatellUserName)&'&password='& clip(loc:ClickatellPassword)&'&api_id='&clip(loc:ClickatellAPIID) &'&to='&clip(loc:SendToBatch) &'&text='&clip(loc:Message) ! this works - concatenated all the numbers - but there is a limit to thi
ThisClient.Post(clip(LOC:PostURL),'') ! cookies, and fields automatically used.
DEBUGINFO(loc:MobileNo &' WAS SENT')
!do logSMSMessage
display()
! END
-
This issue is still unresolved.
I need loop through a table and send SMS's to all or some of the persons in that table.
In its simplest form:
set(locums)
loop until Access:locums.Next()
LOC:PostURL = 'http://api.clickatell.com/http/sendmsg?user='&clip(loc:ClickatellUserName)&'&password='& clip(loc:ClickatellPassword)&'&api_id='&clip(loc:ClickatellAPIID) &'&to='&clip(LCM:CellNo) &'&text='&clip(loc:Message)
ThisClient.Post(clip(LOC:PostURL),'')
Apparently there must be some kind of "pause" or ErrorTrapping here.
Are there any sample apps or code to help me here?
end
-
TCP/IP comms is asyncronous.
Meaning that you can't do a Post inside a loop likw that. You must do one Post, then wait for it to complete (in .PageReceived) before doing the next.
So you have two approaches;
a) build a queue of all the sms's
b) Post one, wait for it to complete (.PageReceived) or fail (.ErrorTrap) and at that point do the next one.
or
a) make a procedure to send one sms - which closes automaticallly in .PageReceived and .ErrorTrap and
b) call this procedure from inside your loop.
If you look at the "Sending Email from a process" example you'll see the same approach.
cheers
Bruce
-
Would
loc:Response = self.Page
in PageReceived be sufficient?
-
what you really want to do in .PageReceived is
a) handle the response in any way you like and
b) Post the next request.
you can ignore the response completely if you like, but it's going to need you to do a POST there if you want it to send another sms at that point.
cheers
Bruce
-
Decided to use a process but I cannot get it to send SMS's.
TakeRecord code:
loc:message = clip(LOC:Message)
loc:Cell = clip(SSM:Cell)
LOC:PostURL = 'http://api.clickatell.com/http/sendmsg?user='&clip(loc:ClickatellUserName)&'&password='& clip(loc:ClickatellPassword)&'&api_id='&clip(loc:ClickatellAPIID) &'&to='&clip(loc:Cell) &'&text='&clip(loc:Message)
stop(clip(LOC:PostURL)) ! this seems to be correct.
ThisClient.Post(clip(LOC:PostURL),'') !Just nothing happens
[attachment deleted by admin]
-
Putting a STOP or MESSAGE in the procedure will break the Events, and hence break the procedure itself.
Use Debugview.Exe, and thisClient._trace('whatever') lines in the code if you want to see what is happening.
cheers
Bruce
-
Did that but it seems that the code in .PageReceived is never executed.
-
have you added code to .ErrorTrap?
does it go into there instead?
cheers
Bruce
-
OK was calling the post in a routine and not in a procedure.
Now I get attached error
[attachment deleted by admin]
-
OK not passing parameters to the procedure!!!
Will get back to you.
-
OK - I have a process that calls a procedure as it goes through the loop.
But it still does not work. Just nothing happens - not even error messages!
Where exactly must I put this code?
ThisClient.Post(clip(loc:PostURL),'')
[attachment deleted by admin]
-
Resolved!
Right! - the window called by the Process had to be NON MDI and must be Immediate.
Not sure if I have the
ThisClient.Post(clip(loc:PostURL),'')
in quite the correct place - I have placed it on the Button?