Triggering Events in DLLs

I am in the process of developing an SMS server using Attain. I am using a dll that has functions and events for sending and receiving SMS messages from mobile phones. I can send messages out alright, but when it comes to receiving messages in I am having some difficulty. I have created a Single Instance codeunit and declared an Automation variable for the DLL and set its property to WithEvents = YES. This exposes the DLL’s ReceiveMessage Event in the C/AL code and in here I place some code to insert a record into a table. I have tried running this codeunit from a form and just from the object designer. I then send SMS messages to the phone connected to my PC, but the event never seems to get triggered, and no records are inserted into my table, even though I know that the phone is connected. I know that events are used in other Attain codeunits, but dont see how they are different from what I am doing. I am just using a standalone database at the moment and connecting directly into it, ie not using NAS etc. Are only certain DLLs and their events supported by Attain ?? Do I need some sort of timer ??, even though I feel this should not be needed, as the event should fire any time a new message is received. Please help !!!

Hi, Attain support events only in combination with the Application Server. You must define the pipe-name and your SMS-function in the codeunit ApplicationManagement.NASHandler first. The Codeunit NASHandler must have the ID 99. This is the connection between Attain and the NAS. ParamStr := UPPERCASE(NASID); CASE ParamStr OF ‘RECSMS’: BEGIN ReceiveSMS.RUN; END; ELSE error(‘NAS error: undefined parameter’); END; The Event then must be triggered with the Pipe RECSMS. This should work.

Hi, Thanks for your help. I am not to familiar with NAS, so could you explain “The Event then must be triggered with the Pipe RECSMS.” ? I am clear on what to do up to this point, but dont understand how to trigger the event with the Pipe RECSMS. Thanks

You don’t have to use NAS to enable event-firing from an automation object in Navision. Your problem must be something else. Make a test with the Navision.Timer automation object. It fires just fine by me without using any kind of NAS. OBJECT Codeunit 80000 testtimer { OBJECT-PROPERTIES { Dato=21-11-03; Tid=17:06:23; Rettet=Ja; Versionsliste=; } PROPERTIES { SingleInstance=Ja; OnRun=BEGIN CREATE(Timer); Timer.Interval:=1000; Timer.Enabled:=TRUE; END; } CODE { VAR Timer@1000000000 : Automation “{3B311C81-140E-11D5-8B18-00D0590B4EC5} 1.0:{3B311C92-140E-11D5-8B18-00D0590B4EC5}:‘Navision Timer 1.0’.Timer” WITHEVENTS; counter@1000000001 : Integer; EVENT Timer@1000000000::Timer@1(Milliseconds@1000000000 : Integer); BEGIN BEEP(1000,1000); counter+=1; IF counter=5 THEN Timer.Enabled:=FALSE; END; EVENT Timer@1000000000::TimerError@2(ErrorString@1000000000 : Text[1024]); BEGIN MESSAGE(‘Error’); END; BEGIN END. } } I think the problem is in your DLL, perhaps communication between the DLL and the phone, perhaps you just have to kickstart the Automation object doing something like SMS.enable, just like I use Timer.enable.

quote:


Originally posted by ohlfert
You don’t have to use NAS to enable event-firing from an automation object in Navision. Your problem must be something else. Make a test with the Navision.Timer automation object.


Thanks, this was a big help to me, and I got the problem sorted out.

Hi KT, What was the problem? Cristi

quote:


Originally posted by cnicola
Hi KT, What was the problem? Cristi


The DLL was not using the VB timer, instead it had a timer function that had to be polled regularly for the events to fire.