Re: API Question


Scott Davis
 

Hi Mike,

Yes, in hind-site, it should have been, but apparently has not been a problem.  I may add the closing tag at some point.  In the mean time, you can use code like this to cycle through and process a variable called buffer, that receives the updates from AC Log.

private static void ProcessBuffer()
        {
            try
            {
                int BeginningOfRecord = buffer.ToString().IndexOf("<CMD>");
                if (BeginningOfRecord > -1 && buffer.Length > 5)
                {
                    int EndOfRecord = buffer.ToString().IndexOf("</CMD>", BeginningOfRecord + 5);
                    while (BeginningOfRecord > -1 && EndOfRecord > -1)
                    {
                        string currentRecord = buffer.ToString().Substring(BeginningOfRecord + 5, EndOfRecord - BeginningOfRecord - 5);
                        buffer.Remove(0, EndOfRecord + 6);
YourCommandActionMethod(currentRecord); //This is where you process an individual record //from the incoming data you requested.
//See if there is anything more in the buffer BeginningOfRecord = buffer.ToString().IndexOf("<CMD>"); if (BeginningOfRecord > -1 && buffer.Length > 5) { EndOfRecord = buffer.ToString().IndexOf("</CMD>"); } } } } catch{exception ex} { //Your error resolution code here. } }


73, Scott
N3FJP

Serving the Amateur Radio community with contesting and general logging software since 1997.

1 Peter 3 vs 15: Always be prepared to give an answer to everyone who asks you to give the reason for the hope that you have. But do this with gentleness and respect...


-----Original Message-----
From: Mike Saeger <mike.saeger@...>
To: N3FJPSoftwareUsers <N3FJPSoftwareUsers@groups.io>
Sent: Fri, Feb 14, 2020 4:04 pm
Subject: Re: [N3FJPSoftwareUsers] API Question

Thanks! Next issue: After the Enter event, I receive the XML below. Shouldn't the tag <CALLTABEVENT> be closed with </CALLTABEVENT>? My XML Parser seems fussy.
<CMD>
<CALLTABEVENT>
<CALL>WA9LFO</CALL>
<BAND>20</BAND>
<MODE>PH</MODE>
      <MODETEST>PH</MODETEST>
<COUNTRY>USA</COUNTRY>
        </ENTEREVENT>
</CMD>
 
<CMD>
<ENTEREVENT>
<QSOCOUNT>18</QSOCOUNT>
<CALL>WA9LFO</CALL>
<BAND>20</BAND>
<MODE>SSB</MODE>
<MODETEST>PH</MODETEST>
<FREQ>14.252</FREQ>
<COUNTRY>USA</COUNTRY>
<DXCC>291</DXCC>
<STATE>WI</STATE>
<CONT>NA</CONT>
<QSO_DATE>20200214</QSO_DATE>
<TIME_ON>204400</TIME_ON>
</ENTEREVENT>
</CMD>

Join N3FJPSoftwareUsers@groups.io to automatically receive all group messages.