Kimber
Kimber

Reputation: 3

How to get just the correct response from TComPort - Delphi?

When i send the command "AT+CUSD=1,"*200#",15" i get the response:

OK


+CUSD: 0,"Crdit :1.33DA au 21/05/20.Credit offert :0DA",15  

Is there a function or another AT command to get just

Crdit :1.33DA au 21/05/20.Credit offert :0DA 

which is the the answer i want ?

Upvotes: 0

Views: 241

Answers (1)

MBo
MBo

Reputation: 80325

Modem response is string-package divided by commas.

You can:
- assign this string to TStringList.DelimitedText to get collection of individual substrings
- identify package by 0-th item - here 'CUSD'
- get 1-th item as 'Crdit...'

Example with Memo.Lines (of type TStrings):

var
  s: string;
  sl: TStringList;
begin
  s := '+CUSD: 0,"Crdit :1.33DA au 21/05/20.Credit offert :0DA",15';
  sl := TStringList.Create; 
  try
    sl.Delimiter := ',';
    sl.StrictDelimiter := True;
    sl.DelimitedText := s;
    Memo1.Lines.Add(sl[1]);
  finally
    sl.Free;

result in sl:
 +CUSD: 0
 Crdit :1.33DA au 21/05/20.Credit offert :0DA
 15
in Memo:
 Crdit :1.33DA au 21/05/20.Credit offert :0DA

Upvotes: 2

Related Questions