Searching \ for '[EE]:pascal string handling' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=pascal+string+handling
Search entire site for: 'pascal string handling'.

Exact match. Not showing close matches.
PICList Thread
'[EE]:pascal string handling'
2001\01\02@045412 by Graham

flavicon
face
I have sent a controller to somebody that outputs response packets in 12
bytes format, the first 10 are id info consisting of a name to/from and a
designator number in ASCII character codes, and the last two bytes are a
simple binary variable in 16 bit format, lsb then msb..

he is trying to manipulate this string in delphi/pascal of which I have
close to zero knowledge and he has not done this before.

He can see the string in total, simply read as a string and displayed... he
can then see ascii character representations of the last two characters (the
data) but seems unable to find the correct pascal commands to strip these
last two from the twelve byte string and reassemble them as a 16 bit integer...

in BASIC this is trivial, I guess it must be the same in pascal ??

how ?

Graham





-Need *high IP3* AND good N/F ?? try this- http://www.rfham.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\02@052904 by Roger Frederick Chin

flavicon
face
Ok my Pascal's quite rusty so I don't remember the syntax for doing this
but I can give you a general idea and hope your friend knows how to
implement this.

you can treat the string as a character array to
access each letter depending on the platform you're running on you may
need to change the data type, but a long should be at least 16 bits

so you'll grab the last letter in the string, typecast to a long, shift
it left 8 bits, then typecast the 2nd to the last byte to a byte (from a
char) and add it to the long.

---
var data:string;
       answer:longint;
answer := (longint(data[12]) SHL 8) + (byte(data[11]));
--

if this is wrong its because i've been doing c so long i've forgotten my
pascal :)

hope it helps


Roger Chin

>
Date: Tue, 2 Jan 2001 04:54:12 -0500 > From: Graham <spam_OUTGraham.DTakeThisOuTspamWANADOO.FR>
{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\02@071404 by mike

flavicon
face
On Tue, 2 Jan 2001 04:54:12 -0500, you wrote:

>I have sent a controller to somebody that outputs response packets in 12
>bytes format, the first 10 are id info consisting of a name to/from and a
>designator number in ASCII character codes, and the last two bytes are a
>simple binary variable in 16 bit format, lsb then msb..
>
>he is trying to manipulate this string in delphi/pascal of which I have
>close to zero knowledge and he has not done this before.
>
>He can see the string in total, simply read as a string and displayed... he
>can then see ascii character representations of the last two characters (the
>data) but seems unable to find the correct pascal commands to strip these
>last two from the twelve byte string and reassemble them as a 16 bit integer...
>
>in BASIC this is trivial, I guess it must be the same in pascal ??
>
>how ?
copy(string,s,l)
returns a substring of length l starting at position s - similar to
MID$ in Basic
--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\23@192617 by Carl Ranson

flavicon
face
{Quote hidden}

Fairly close actually.

var data : String;
   answer : longint;
begin
   answer := (ord(data[12]) shl 8) + ord(data[11]);
end;


CR

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...