Recent

Author Topic: Put Strings together + doesn't work  (Read 306 times)

coradi

  • Full Member
  • ***
  • Posts: 121
Put Strings together + doesn't work
« on: September 20, 2022, 10:27:40 am »
Is there another way, then to use concat to combine Strings?
+ doesn'T work here.
POS is always 0

Code: [Select]
program RS232_find;

Uses CRT;

VAR key : Char;
  RX : ARRAY [0..10] OF char;
  position : BYTE;
  kurzwort : string[13];

Procedure keys;
  Begin
  key := readkey;
    case key of
    #72 :  writeln('up');
    #80 :  writeln('down');
    #75 :  writeln('left');
    #77:   writeln('right');
    end; // case
end;  // if #0
//end;


begin
  RX[0] := chr($FF);
  RX[1] := chr($FF);
  RX[2] := chr($01);
  RX[3] := chr($01);
  RX[4] := chr($1B);
  RX[5] := chr($52);
  RX[6] := chr($00);
  RX[7] := chr($52);
  RX[8] := chr($30);
  RX[9] := chr($01);
  RX[10] := chr($01);
 kurzwort := chr($52)+ chr($00)+ chr($52);
  While TRUE DO
  Begin
    position := Pos(kurzwort, rx);
    Write(position);
    keys;
  end;
end.
       
Amstrad Schneider CPC 6128
Wind XP / 7 / 10

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 10399
  • FPC developer.
Re: Put Strings together + doesn't work
« Reply #1 on: September 20, 2022, 10:44:57 am »
That's because RX is not a string but an array of char. Probably it gets a conversion to pchar, and pchar's stop at $00

coradi

  • Full Member
  • ***
  • Posts: 121
Re: Put Strings together + doesn't work
« Reply #2 on: September 20, 2022, 10:59:09 am »
oh, ok.
I thought String of Char and String are the same:-(
Amstrad Schneider CPC 6128
Wind XP / 7 / 10

Zvoni

  • Hero Member
  • *****
  • Posts: 1523
Re: Put Strings together + doesn't work
« Reply #3 on: September 20, 2022, 12:24:02 pm »
oh, ok.
I thought String of Char and String are the same:-(
How do you figure that? Besides the fact that String is a managed type, and Array of char or pchar is more or less ANSI only
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Arioch

  • Sr. Member
  • ****
  • Posts: 414
Re: Put Strings together + doesn't work
« Reply #4 on: September 26, 2022, 07:07:50 pm »
oh, ok.
I thought String of Char and String are the same:-(
How do you figure that? Besides the fact that String is a managed type, and Array of char or pchar is more or less ANSI only

Well, original Pascal did not have strings (except for string literals), so school books written on top of J&W report used to call char arrays as strings, for having nothing better.

TurboPascal strings vs C strings were once a matter of hot internet debates, so everyone knew specifics, but probably no more.

 

TinyPortal © 2005-2018