Recent

Author Topic: LazSerial how validate char  (Read 454 times)

eldonfsr

  • Hero Member
  • *****
  • Posts: 502
LazSerial how validate char
« on: September 15, 2024, 08:30:35 pm »
Hi i tried to validate this code #$0D witch is returned by device connected serial port the way to validate is string empty o line empty but i don't get validate..

procedure TFormMain.DPSerialDataAppear(Sender: TObject);
var
  Str: AnsiString;
begin
  sStr := DataPort.Pull();
begin
   Index := 1;
//    while Index <= length(Str) do
//        if (Str[Index] in [chr(0)..chr(9),chr(14)..chr(32),chr(255)]) then
//            delete(Str, Index, 1)
//       else inc(Index);
//    while Index <= length(Str) do begin
//        ca:= Copy(Str, Index,1);
//         inc(Index) ;
//    end;
    if( Str <>'#$0D' then begin // If put chr(10) and chr(13)  on previos while eliminte those chr only need validate if str don't contain more information.. if str conain only this character line is empty..
       Memo.Text := Memo.Text + Str;
    end;
    if(Length(str)>0 ) then begin
     Memo.Text := Memo.Text + Str;
     Memo.SelStart:= Length(Memo.Text);
    end; 
 
end; 
 

PascalDragon

  • Hero Member
  • *****
  • Posts: 5678
  • Compiler Developer
Re: LazSerial how validate char
« Reply #1 on: September 15, 2024, 08:56:13 pm »
procedure TFormMain.DPSerialDataAppear(Sender: TObject);

Please use [code=pascal][/code]-tags to avoid the forum software interpreting your code and to make it better viewable.

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1240
Re: LazSerial how validate char
« Reply #2 on: September 16, 2024, 12:43:31 pm »
Hello,
Code: Pascal  [Select][+][-]
  1.  sStr := DataPort.Pull();

What is DataPort ?    LazSerial or Synaser have'nt Pull Method

Friendly, J.P
« Last Edit: September 16, 2024, 12:48:45 pm by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

TRon

  • Hero Member
  • *****
  • Posts: 3271
Re: LazSerial how validate char
« Reply #3 on: September 16, 2024, 01:54:19 pm »
What is DataPort ?
I have to guess but I assume dataport from serbod (github) e.g. wrong thread  :)
This tagline is powered by AI

eldonfsr

  • Hero Member
  • *****
  • Posts: 502
Re: LazSerial how validate char
« Reply #4 on: September 17, 2024, 03:40:21 am »
yes i using dataport and also i tested on lazserial and synapse all do same , for me no problem i know what is happend the problem is with users you can see on image how look lines lines and sadly empty they think is returned 0 values or skip some values, but i know is breakline character, i remember in old app with comport never show information like that for i think to implement some validation before put the information on memo ...

why i need to do i need replace that app of comport for new can handle more lines or text comport max rows =100...

is strange don't has any additional information just escsequences...
somethink line empty line... culd be psiible to setup memo not accept empty lines...

Thanks... sorry for topic
   

eldonfsr

  • Hero Member
  • *****
  • Posts: 502
Re: LazSerial how validate char
« Reply #5 on: September 19, 2024, 05:32:22 pm »
Ok after playing with this could be better option or not but is working for me... after add text to memo i run this command

Code: Pascal  [Select][+][-]
  1.    Memo.tex:= trim(Memo.text);
  2.  

so eliminate all empty lines....witch what i need to not confuse the user return cero values or some think similar...

Thanks all for help... hope help to some body else...

 

TinyPortal © 2005-2018